Automates code reviews using Clean Code, Clean Architecture, and Pragmatic Programmer principles. Benefits developers and engineering teams by enforcing best practices. Integrates with Python projects and connects to Claude agents for automated workflows.
git clone https://github.com/Zhen-Bo/pragmatic-clean-code-reviewer.gitPragmatic Clean Code Reviewer transforms Claude Code into a rigorous code review expert that evaluates code against 350+ rules derived from three foundational software engineering books: The Pragmatic Programmer, Clean Code, and Clean Architecture. The skill uses a 3+4+2 positioning system with five strictness levels (L1–L5) to adapt review intensity to project context, from lab environments to critical infrastructure. It conducts systematic evaluations through a 15-point checklist, provides standardized reports with rule citations, and analyzes fix effort versus benefit for each issue. Teams and individual developers benefit by automating enforcement of best practices while focusing human review effort on logic and architectural decisions.
1. **Prepare Your Code**: Ensure your Python code is in a Git repository with clear commit messages. Include a `requirements.txt` or `pyproject.toml` for dependency management. 2. **Run the Review**: Copy your code snippet into the prompt template and run it through your AI assistant (Claude, ChatGPT, etc.). For large files, break into logical chunks (e.g., 100-200 lines at a time). 3. **Integrate with GitHub/GitLab**: Use a Claude Code agent with the GitHub CLI to automate reviews: ```bash gh api repos/{owner}/{repo}/pulls/{pr_number}/files | jq -r '.[].filename' | while read file; do echo "Reviewing $file" git show HEAD:$file | ai-review --pr $file done ``` 4. **Prioritize Issues**: Focus on Critical/High priority issues first. Use the trade-off analysis to decide which suggestions to implement immediately vs. defer. 5. **Iterate**: After implementing changes, run the review again to verify improvements. Use the AI's feedback to guide your refactoring process. **Pro Tips:** - For monorepos, specify the subdirectory in the prompt: `[CODE_SNIPPET]` → `cd /path/to/module && git show HEAD:file.py` - Use `--diff` mode for PR reviews to compare against the base branch - Save common patterns in a `review_guidelines.md` file to standardize feedback across your team
Review pull requests against Clean Code and Clean Architecture principles
Audit module architecture for adherence to software engineering best practices
Check code readiness for merge with standardized, deterministic verdicts
Evaluate code quality in team environments where teammates need to maintain others' work
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/Zhen-Bo/pragmatic-clean-code-reviewerCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Review the following Python code snippet for adherence to Clean Code, Clean Architecture, and Pragmatic Programmer principles. Focus on: 1) Readability and simplicity (avoid deep nesting, use meaningful names, follow SOLID principles) 2) Separation of concerns (business logic vs. infrastructure, avoid god objects) 3) Error handling (fail fast, meaningful exceptions, graceful degradation) 4) Testability (dependency injection, avoid static methods, mockable interfaces) 5) Pragmatic trade-offs (when to refactor vs. when to ship) Code to review: ```python [CODE_SNIPPET] ``` Provide: - A prioritized list of issues (Critical/High/Medium/Low) - Specific refactoring suggestions with code examples - Trade-off analysis for each suggestion (impact vs. effort) - A summary of the most impactful improvements for this PR
### Clean Code Review for `user_service.py`
**Critical Issues:**
1. **God Object Violation**: The `UserService` class handles authentication, data validation, and database operations (150+ lines). This violates Single Responsibility Principle and makes testing difficult.
2. **Tight Coupling**: Direct dependency on `DatabaseConnection` without interfaces. This prevents mocking for unit tests and makes the service impossible to test in isolation.
**High Priority Issues:**
1. **Nested Conditionals**: The `authenticate_user()` method has 4 levels of nesting (if/else chains for validation). This reduces readability and increases bug surface area.
2. **Magic Numbers**: Hardcoded values like `MAX_PASSWORD_LENGTH = 72` and `MIN_PASSWORD_LENGTH = 8` should be constants with meaningful names.
3. **Inconsistent Error Handling**: Some validation errors raise `ValueError` while others return `None`. This creates unpredictable behavior.
**Medium Priority Issues:**
1. **Mutable Default Argument**: The `get_users()` method uses `[]` as a default parameter, which is dangerous in Python.
2. **Over-Engineering**: The `UserBuilder` pattern is overkill for this simple domain. A simple constructor with validation would suffice.
**Refactoring Suggestions:**
1. **Extract Authentication Logic** (High Impact/Low Effort):
```python
class Authenticator:
def __init__(self, password_validator: PasswordValidator):
self.validator = password_validator
def authenticate(self, username: str, password: str) -> User:
if not self.validator.is_valid(password):
raise InvalidPasswordError()
# ... rest of auth logic
```
2. **Use Dependency Injection** (Medium Impact/Medium Effort):
```python
class UserService:
def __init__(self, db: DatabaseInterface, auth: Authenticator):
self.db = db
self.auth = auth
```
**Trade-off Analysis:**
- Refactoring the `UserService` will take ~2 hours but will reduce bugs by ~40% based on similar projects
- Extracting `Authenticator` is low-risk but requires updating 3 existing tests
- The `UserBuilder` removal is controversial - while it's overkill now, it might be useful if user creation becomes more complex later
**Recommendation:** Prioritize the `UserService` refactoring and `Authenticator` extraction for this PR. Defer the `UserBuilder` removal to a future story when requirements evolve.
**Impact Summary:** These changes will reduce the PR review time by ~30% and make future changes 2-3x faster while maintaining backward compatibility.AI assistant built for thoughtful, nuanced conversation
Custom software development for data, engagement, and automation
IronCalc is a spreadsheet engine and ecosystem
Customer feedback management made simple
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan