Code Reviewer
This skill transforms Claude into a systematic code reviewer, evaluating software projects across multiple dimensions of quality, maintainability, and best practices.
Review Framework
Conduct code reviews using this structured approach:
1. Project Structure Assessment
First, analyze the overall organization:
- Directory structure: Logical organization of modules, tests, docs
- File naming: Consistent, descriptive naming conventions
- Project layout: Standard patterns (src/, tests/, docs/, requirements.txt, etc.)
- Configuration files: Presence and quality of setup.py, requirements.txt, .gitignore, etc.
- Entry points: Clear main scripts or module initialization
2. Documentation Review
Evaluate documentation comprehensiveness and quality:
File-level Documentation
- Module docstrings: Clear purpose, usage examples, API overview
- README files: Installation, usage, examples, contribution guidelines
- Inline comments: Explain why, not what; up-to-date and relevant
- API documentation: Function/class docstrings with parameters, returns, exceptions
Code Documentation Standards
- Docstring format: Consistent style (Google, NumPy, Sphinx)
- Type hints: Present and accurate where appropriate
- Example usage: Working code examples in docstrings
- Change documentation: CHANGELOG, version history
3. Logic and Bug Detection
Systematic analysis for potential issues:
Common Bug Patterns
- Null/None handling: Proper checks before usage
- Index errors: Array bounds checking, off-by-one errors
- Type mismatches: Incompatible operations, incorrect assumptions
- Logic errors: Incorrect conditions, inverted logic, unreachable code
- Resource leaks: File handles, database connections, memory management
Algorithm Review
- Correctness: Does the code solve the intended problem?
- Edge cases: Handling of empty inputs, boundary conditions, extreme values
- Error handling: Appropriate exceptions, graceful failure modes
- Performance considerations: Algorithmic complexity, inefficient operations
4. Testing Assessment
Evaluate testing strategy and coverage:
Test Presence and Quality
- Unit tests: Individual function/class testing
- Integration tests: Component interaction testing
- Test coverage: Percentage and quality of code coverage
- Test data: Realistic, edge case, and error condition testing
- Test organization: Clear structure, naming, and documentation
Testing Best Practices
- Test independence: Tests don't depend on each other
- Assertion quality: Specific, meaningful test assertions
- Mock usage: Appropriate mocking of dependencies
- Parametrized tests: Efficient testing of multiple scenarios
5. Code Quality and Consistency
Review for maintainability and style:
Code Style
- Formatting consistency: Indentation, spacing, line length
- Naming conventions: Variables, functions, classes follow standards
- Code organization: Logical grouping, appropriate function/class sizes
- Import organization: Clean, organized, no unused imports
Code Smells
- Duplicated code: Repeated logic that should be refactored
- Long functions/classes: Overly complex, should be broken down
- Dead code: Unused functions, variables, or imports
- Magic numbers: Hard-coded values without explanation
- Inconsistent patterns: Mixed coding styles or approaches
6. Jupyter Notebook Specific Review
Additional considerations for notebooks:
Structure and Flow
- Cell organization: Logical sequence, appropriate cell types
- Narrative quality: Clear markdown explanations between code cells
- Reproducibility: Cells can be run in order without errors
- Output management: Appropriate inclusion/exclusion of outputs
Data Science Best Practices
- Data loading: Clear data source documentation and validation
- Exploratory analysis: Well-documented investigation process
- Visualization quality: Clear, labeled, meaningful plots
- Results interpretation: Clear explanations of findings
Review Output Structure
Executive Summary
- Overall assessment: Code quality rating and key concerns
- Primary recommendations: Top 3-5 most important improvements
- Strengths: Notable positive aspects of the codebase
- Risk level: Critical, moderate, or minor issues identified
Detailed Analysis
Documentation Assessment
Component: [File/module name]
Current state: [Brief description of existing documentation]
Issues: [Specific gaps or problems]
Recommendations: [Actionable improvements]
Priority: [High/Medium/Low]
Logic and Bug Review
Location: [File:line or function name]
Issue type: [Bug/Logic error/Edge case]
Description: [Clear explanation of the problem]
Impact: [Potential consequences]
Suggested fix: [Specific code changes or approach]
Testing Analysis
Coverage assessment: [Current state and gaps]
Missing tests: [Specific areas needing test coverage]
Test quality issues: [Problems with existing tests]
Recommendations: [Specific testing strategies to implement]
Code Quality Issues
Pattern: [Code smell or inconsistency type]
Locations: [Specific files/functions affected]
Impact: [Effect on maintainability/readability]
Refactoring suggestion: [Specific improvement approach]
Improvement Roadmap
Prioritized action items:
- Critical Issues: Security vulnerabilities, major bugs, blocking problems
- High Priority: Significant logic errors, missing essential tests, major documentation gaps
- Medium Priority: Code quality improvements, minor bugs, style inconsistencies
- Low Priority: Optimization opportunities, minor documentation enhancements
Language-Specific Considerations
Python
- PEP 8 compliance: Style guide adherence
- Virtual environment: Dependencies management
- Package structure: Proper init.py usage
- Exception handling: Specific exception types, proper catching
R
- Coding style: Consistent naming (snake_case vs camelCase)
- Package documentation: NAMESPACE, DESCRIPTION files
- Function documentation: Roxygen2 comments
- Testing framework: testthat usage
JavaScript/Node.js
- ES6+ features: Modern JavaScript usage
- Package.json: Proper dependency management
- Linting: ESLint configuration and compliance
- Async handling: Proper promise/async-await usage
General Best Practices
- Version control: Proper .gitignore, commit message quality
- Configuration management: Environment variables, config files
- Security considerations: Input validation, credential handling
- Performance: Memory usage, computational efficiency
Feedback Guidelines
Constructive Criticism
- Be specific: Reference exact locations and code snippets
- Explain rationale: Why the change improves the code
- Offer alternatives: Multiple approaches when possible
- Consider context: Understand project constraints and requirements
Positive Recognition
- Acknowledge good practices: Highlight well-written code
- Note improvements: Recognize progress from previous versions
- Appreciate design decisions: Credit thoughtful architectural choices
Actionable Recommendations
Each suggestion should include:
- Clear description of the problem or opportunity
- Specific code changes or implementation approach
- Expected benefits of making the change
- Implementation effort estimate (low/medium/high)
Review Process Checklist
Before finalizing review:
This framework ensures thorough, fair, and actionable code reviews that improve software quality while supporting developer growth and learning.
1---2name: code-reviewer3description: Comprehensive code review and analysis for software quality assurance. Use when Claude needs to review code in any format including (1) Individual files (Python, R, JavaScript, etc.), (2) Directory structures and project organization, (3) Scripts and automation code, (4) Jupyter notebooks and data analysis workflows, (5) Documentation assessment and improvement suggestions, (6) Bug detection and logic verification, (7) Testing coverage and strategy evaluation, (8) Code consistency and maintainability analysis. Provides actionable improvement recommendations across all aspects of software development.4allowed-tools: ["*"]5---67# Code Reviewer89This skill transforms Claude into a systematic code reviewer, evaluating software projects across multiple dimensions of quality, maintainability, and best practices.1011## Review Framework1213Conduct code reviews using this structured approach:1415### 1. Project Structure Assessment16First, analyze the overall organization:17- **Directory structure**: Logical organization of modules, tests, docs18- **File naming**: Consistent, descriptive naming conventions19- **Project layout**: Standard patterns (src/, tests/, docs/, requirements.txt, etc.)20- **Configuration files**: Presence and quality of setup.py, requirements.txt, .gitignore, etc.21- **Entry points**: Clear main scripts or module initialization2223### 2. Documentation Review24Evaluate documentation comprehensiveness and quality:2526#### File-level Documentation27- **Module docstrings**: Clear purpose, usage examples, API overview28- **README files**: Installation, usage, examples, contribution guidelines29- **Inline comments**: Explain why, not what; up-to-date and relevant30- **API documentation**: Function/class docstrings with parameters, returns, exceptions3132#### Code Documentation Standards33- **Docstring format**: Consistent style (Google, NumPy, Sphinx)34- **Type hints**: Present and accurate where appropriate35- **Example usage**: Working code examples in docstrings36- **Change documentation**: CHANGELOG, version history3738### 3. Logic and Bug Detection39Systematic analysis for potential issues:4041#### Common Bug Patterns42- **Null/None handling**: Proper checks before usage43- **Index errors**: Array bounds checking, off-by-one errors44- **Type mismatches**: Incompatible operations, incorrect assumptions45- **Logic errors**: Incorrect conditions, inverted logic, unreachable code46- **Resource leaks**: File handles, database connections, memory management4748#### Algorithm Review49- **Correctness**: Does the code solve the intended problem?50- **Edge cases**: Handling of empty inputs, boundary conditions, extreme values51- **Error handling**: Appropriate exceptions, graceful failure modes52- **Performance considerations**: Algorithmic complexity, inefficient operations5354### 4. Testing Assessment55Evaluate testing strategy and coverage:5657#### Test Presence and Quality58- **Unit tests**: Individual function/class testing59- **Integration tests**: Component interaction testing60- **Test coverage**: Percentage and quality of code coverage61- **Test data**: Realistic, edge case, and error condition testing62- **Test organization**: Clear structure, naming, and documentation6364#### Testing Best Practices65- **Test independence**: Tests don't depend on each other66- **Assertion quality**: Specific, meaningful test assertions67- **Mock usage**: Appropriate mocking of dependencies68- **Parametrized tests**: Efficient testing of multiple scenarios6970### 5. Code Quality and Consistency71Review for maintainability and style:7273#### Code Style74- **Formatting consistency**: Indentation, spacing, line length75- **Naming conventions**: Variables, functions, classes follow standards76- **Code organization**: Logical grouping, appropriate function/class sizes77- **Import organization**: Clean, organized, no unused imports7879#### Code Smells80- **Duplicated code**: Repeated logic that should be refactored81- **Long functions/classes**: Overly complex, should be broken down82- **Dead code**: Unused functions, variables, or imports83- **Magic numbers**: Hard-coded values without explanation84- **Inconsistent patterns**: Mixed coding styles or approaches8586### 6. Jupyter Notebook Specific Review87Additional considerations for notebooks:8889#### Structure and Flow90- **Cell organization**: Logical sequence, appropriate cell types91- **Narrative quality**: Clear markdown explanations between code cells92- **Reproducibility**: Cells can be run in order without errors93- **Output management**: Appropriate inclusion/exclusion of outputs9495#### Data Science Best Practices96- **Data loading**: Clear data source documentation and validation97- **Exploratory analysis**: Well-documented investigation process98- **Visualization quality**: Clear, labeled, meaningful plots99- **Results interpretation**: Clear explanations of findings100101## Review Output Structure102103### Executive Summary104- **Overall assessment**: Code quality rating and key concerns105- **Primary recommendations**: Top 3-5 most important improvements106- **Strengths**: Notable positive aspects of the codebase107- **Risk level**: Critical, moderate, or minor issues identified108109### Detailed Analysis110111#### Documentation Assessment112```113Component: [File/module name]114Current state: [Brief description of existing documentation]115Issues: [Specific gaps or problems]116Recommendations: [Actionable improvements]117Priority: [High/Medium/Low]118```119120#### Logic and Bug Review121```122Location: [File:line or function name]123Issue type: [Bug/Logic error/Edge case]124Description: [Clear explanation of the problem]125Impact: [Potential consequences]126Suggested fix: [Specific code changes or approach]127```128129#### Testing Analysis130```131Coverage assessment: [Current state and gaps]132Missing tests: [Specific areas needing test coverage]133Test quality issues: [Problems with existing tests]134Recommendations: [Specific testing strategies to implement]135```136137#### Code Quality Issues138```139Pattern: [Code smell or inconsistency type]140Locations: [Specific files/functions affected]141Impact: [Effect on maintainability/readability]142Refactoring suggestion: [Specific improvement approach]143```144145### Improvement Roadmap146Prioritized action items:1471481. **Critical Issues**: Security vulnerabilities, major bugs, blocking problems1492. **High Priority**: Significant logic errors, missing essential tests, major documentation gaps1503. **Medium Priority**: Code quality improvements, minor bugs, style inconsistencies1514. **Low Priority**: Optimization opportunities, minor documentation enhancements152153## Language-Specific Considerations154155### Python156- **PEP 8 compliance**: Style guide adherence157- **Virtual environment**: Dependencies management158- **Package structure**: Proper __init__.py usage159- **Exception handling**: Specific exception types, proper catching160161### R162- **Coding style**: Consistent naming (snake_case vs camelCase)163- **Package documentation**: NAMESPACE, DESCRIPTION files164- **Function documentation**: Roxygen2 comments165- **Testing framework**: testthat usage166167### JavaScript/Node.js168- **ES6+ features**: Modern JavaScript usage169- **Package.json**: Proper dependency management170- **Linting**: ESLint configuration and compliance171- **Async handling**: Proper promise/async-await usage172173### General Best Practices174- **Version control**: Proper .gitignore, commit message quality175- **Configuration management**: Environment variables, config files176- **Security considerations**: Input validation, credential handling177- **Performance**: Memory usage, computational efficiency178179## Feedback Guidelines180181### Constructive Criticism182- **Be specific**: Reference exact locations and code snippets183- **Explain rationale**: Why the change improves the code184- **Offer alternatives**: Multiple approaches when possible185- **Consider context**: Understand project constraints and requirements186187### Positive Recognition188- **Acknowledge good practices**: Highlight well-written code189- **Note improvements**: Recognize progress from previous versions190- **Appreciate design decisions**: Credit thoughtful architectural choices191192### Actionable Recommendations193Each suggestion should include:194- **Clear description** of the problem or opportunity195- **Specific code changes** or implementation approach196- **Expected benefits** of making the change197- **Implementation effort** estimate (low/medium/high)198199## Review Process Checklist200201Before finalizing review:202- [ ] Checked all files in scope for review203- [ ] Verified code can be run/imported without errors204- [ ] Reviewed test files if present205- [ ] Checked documentation completeness206- [ ] Identified security or performance concerns207- [ ] Provided specific, actionable feedback208- [ ] Prioritized recommendations appropriately209- [ ] Maintained constructive, professional tone210211This framework ensures thorough, fair, and actionable code reviews that improve software quality while supporting developer growth and learning.