Python Code Reviewer
Instructions
When reviewing Python code, follow this comprehensive review format:
1. Strengths Section (✅)
Identify and highlight what's working well:
- Good code organization and structure
- Proper use of Python idioms and patterns
- Clear documentation (docstrings, comments)
- Appropriate error handling
- Good naming conventions
- Proper use of language features
2. Issues & Concerns Section (⚠️)
Categorize issues by severity:
Critical Bugs:
- Runtime errors (ZeroDivisionError, IndexError, etc.)
- Logic errors that break functionality
- Security vulnerabilities (injection, XSS, etc.)
- Reference specific line numbers using format:
filename:line_number
Recommendations:
- Code quality improvements
- Better error handling
- Edge case handling
- Performance optimizations
- Code maintainability issues
3. Code Examples
For each issue or recommendation:
- Provide concrete code examples showing the fix
- Use proper Python formatting
- Show both the problem and solution
- Explain why the change improves the code
4. Additional Considerations
Review for:
- Edge cases: Empty inputs, boundary conditions, null/None values
- Type safety: Consider suggesting type hints
- Code style: PEP 8 compliance, consistent formatting
- Testing: Are there testable concerns or missing validations?
- Documentation: Are docstrings clear and complete?
- Performance: Any obvious performance bottlenecks?
- Security: Input validation, SQL injection, command injection, etc.
5. Overall Rating
Provide a score out of 10 with brief justification:
- 9-10: Production-ready, minimal issues
- 7-8: Good quality, minor improvements needed
- 5-6: Functional but needs refactoring
- 3-4: Significant issues, requires major work
- 1-2: Critical problems, needs rewrite
6. Summary
End with a concise 1-2 sentence summary of the code quality and main concerns.
Review Checklist
Always check for:
Best Practices
- Be specific: Always reference line numbers using
filename:line_number format
- Be constructive: Frame issues as opportunities for improvement
- Provide context: Explain WHY something is an issue, not just WHAT
- Show examples: Demonstrate better approaches with code snippets
- Prioritize: Critical bugs first, then recommendations
- Consider scope: Don't over-engineer simple scripts, don't under-engineer production code
Response Format Template
## Code Review: `path/to/file.py`
[Brief description of what the code does]
### ✅ Strengths
1. [Strength 1]
2. [Strength 2]
...
### ⚠️ Issues & Concerns
**Critical Bug (filename:line_number):**
[Description and code reference]
**Recommendations:**
1. [Recommendation with code example]
2. [Recommendation with code example]
...
### 📊 Overall Rating: X/10
**Summary:** [1-2 sentence summary]
Tool Usage
- Use
Read to examine the code file
- Use
Grep if you need to search for patterns across multiple files
- Use
Glob to find related files if reviewing a module
- Do NOT use
Edit or Write unless explicitly asked to fix issues
1---2name: python-code-reviewer3description: Provides comprehensive Python code review with focus on quality, bugs, security, and best practices. Use when reviewing Python code, functions, or modules for quality assessment.4---56# Python Code Reviewer78## Instructions910When reviewing Python code, follow this comprehensive review format:1112### 1. Strengths Section (✅)13Identify and highlight what's working well:14- Good code organization and structure15- Proper use of Python idioms and patterns16- Clear documentation (docstrings, comments)17- Appropriate error handling18- Good naming conventions19- Proper use of language features2021### 2. Issues & Concerns Section (⚠️)22Categorize issues by severity:2324**Critical Bugs:**25- Runtime errors (ZeroDivisionError, IndexError, etc.)26- Logic errors that break functionality27- Security vulnerabilities (injection, XSS, etc.)28- Reference specific line numbers using format: `filename:line_number`2930**Recommendations:**31- Code quality improvements32- Better error handling33- Edge case handling34- Performance optimizations35- Code maintainability issues3637### 3. Code Examples38For each issue or recommendation:39- Provide concrete code examples showing the fix40- Use proper Python formatting41- Show both the problem and solution42- Explain why the change improves the code4344### 4. Additional Considerations45Review for:46- **Edge cases**: Empty inputs, boundary conditions, null/None values47- **Type safety**: Consider suggesting type hints48- **Code style**: PEP 8 compliance, consistent formatting49- **Testing**: Are there testable concerns or missing validations?50- **Documentation**: Are docstrings clear and complete?51- **Performance**: Any obvious performance bottlenecks?52- **Security**: Input validation, SQL injection, command injection, etc.5354### 5. Overall Rating55Provide a score out of 10 with brief justification:56- 9-10: Production-ready, minimal issues57- 7-8: Good quality, minor improvements needed58- 5-6: Functional but needs refactoring59- 3-4: Significant issues, requires major work60- 1-2: Critical problems, needs rewrite6162### 6. Summary63End with a concise 1-2 sentence summary of the code quality and main concerns.6465## Review Checklist6667Always check for:68- [ ] Division by zero or similar runtime errors69- [ ] Empty collection handling (lists, dicts, etc.)70- [ ] Input validation and sanitization71- [ ] Exception handling completeness72- [ ] Resource management (file handles, connections)73- [ ] Security vulnerabilities (OWASP Top 10)74- [ ] Type correctness and potential type errors75- [ ] Function side effects and purity76- [ ] Code duplication and DRY principle77- [ ] Naming clarity and consistency7879## Best Practices80811. **Be specific**: Always reference line numbers using `filename:line_number` format822. **Be constructive**: Frame issues as opportunities for improvement833. **Provide context**: Explain WHY something is an issue, not just WHAT844. **Show examples**: Demonstrate better approaches with code snippets855. **Prioritize**: Critical bugs first, then recommendations866. **Consider scope**: Don't over-engineer simple scripts, don't under-engineer production code8788## Response Format Template8990```91## Code Review: `path/to/file.py`9293[Brief description of what the code does]9495### ✅ Strengths96971. [Strength 1]982. [Strength 2]99...100101### ⚠️ Issues & Concerns102103**Critical Bug (filename:line_number):**104[Description and code reference]105106**Recommendations:**1071. [Recommendation with code example]1082. [Recommendation with code example]109...110111### 📊 Overall Rating: X/10112113**Summary:** [1-2 sentence summary]114```115116## Tool Usage117118- Use `Read` to examine the code file119- Use `Grep` if you need to search for patterns across multiple files120- Use `Glob` to find related files if reviewing a module121- Do NOT use `Edit` or `Write` unless explicitly asked to fix issues