
python-arch-review
by michaelalber
This MCP server provides AI assistants with tools to search and retrieve information from 10 CFR Part 712 - the federal regulation governing the Human Reliability Program (HRP) for DOE and NNSA facilities.
SKILL.md
name: python-arch-review description: Architecture review for Python 3 projects enforcing TDD (Red→Green→Refactor→Quality Check), YAGNI principles, and code quality gates. Use when (1) writing new Python code, (2) reviewing existing Python code, (3) refactoring Python modules, (4) adding tests to Python projects, or (5) checking code quality metrics. Integrates Ruff, mypy, and security scanning.
Python Architecture Review
TDD Workflow
Every code change follows: Red → Green → Refactor → Quality Check
- Red: Write failing test first
- Green: Minimal code to pass
- Refactor: Clean up, no new functionality
- Quality Check: Run full quality gate
# Run quality gate
scripts/quality_check.py <path>
Test Standards
Naming: test_should_<expected>_when_<condition> or test_<method>_<scenario>_<result>
Pattern: Arrange-Act-Assert (one assertion per test, except related validations)
def test_should_return_sum_when_two_positive_numbers():
# Arrange
calc = Calculator()
# Act
result = calc.add(2, 3)
# Assert
assert result == 5
Quality Gates
| Metric | Target | Tool |
|---|---|---|
| Cyclomatic Complexity | Methods <10, Classes <20 | radon |
| Coverage | 80% business logic, 95% security-critical | pytest-cov |
| Maintainability Index | 70+ | radon |
| Code Duplication | <3% | pylint |
Core Philosophy: Pragmatic Over Perfect
Start simple, add complexity only when needed.
YAGNI Principles
- Start simple with direct implementations
- Add abstractions only when complexity demands (Rule of Three)
- Prefer composition over inheritance
- No abstractions for future "what-ifs"
- Refactor to add abstractions when patterns emerge
Architecture Decision Flow
Is this a simple CRUD operation?
→ YES: Direct implementation, no layers
→ NO: Does it have complex business rules?
→ NO: Service + Repository (2 layers max)
→ YES: Consider Clean Architecture layers
See references/architecture-patterns.md for selective Clean Architecture and strategic SOLID guidance.
Tool Integration
Ruff (Lint + Format)
ruff check --fix .
ruff format .
See references/ruff-config.md for pyproject.toml config.
mypy (Type Checking)
mypy --strict .
See references/mypy-config.md for strict config.
Security
bandit -r src/
pip-audit
See references/security-checklist.md for OWASP checks.
Review Workflow
- Pre-commit:
scripts/quality_check.py(blocks on failures) - Code Review: Check against references/review-checklist.md
- Merge: All gates green, coverage met
When to Skip Quality Checks
Never skip for production code. Acceptable for:
- Spike/prototype branches (labeled
spike/*) - Documentation-only changes
- CI/CD config changes
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon