| name | code-review |
| description | Conduct thorough, constructive code reviews for quality and security. Use when reviewing pull requests, checking code quality, identifying bugs, or auditing security. Handles best practices, SOLID principles, security vulnerabilities, performance analysis, and testing coverage. |
| allowed-tools | ["Read","Grep","Glob"] |
| tags | ["code-review","code-quality","security","best-practices","PR-review"] |
| platforms | ["Claude","ChatGPT","Gemini"] |
| author | locusai |
Code Review
When to use this skill
- Reviewing pull requests
- Checking code quality
- Providing feedback on implementations
- Identifying potential bugs
- Suggesting improvements
- Security audits
- Performance analysis
Instructions
Step 1: Understand the context
Read the PR description:
- What is the goal of this change?
- Which issues does it address?
- Are there any special considerations?
Check the scope:
- How many files changed?
- What type of changes? (feature, bugfix, refactor)
- Are tests included?
Step 2: High-level review
Architecture and design:
- Does the approach make sense?
- Is it consistent with existing patterns?
- Are there simpler alternatives?
- Is the code in the right place?
Code organization:
- Clear separation of concerns?
- Appropriate abstraction levels?
- Logical file/folder structure?
Step 3: Detailed code review
Naming:
Functions:
Classes and objects:
Error handling:
Code quality:
Step 4: Security review
Input validation:
Authentication & Authorization:
Data protection:
Dependencies:
Step 5: Performance review
Algorithms:
Database:
Caching:
Resource management:
Step 6: Testing review
Test coverage:
Test quality:
Test naming:
def test_user_creation_with_valid_data_succeeds():
pass
def test1():
pass
Step 7: Documentation review
Code comments:
Function documentation:
def calculate_total(items: List[Item], tax_rate: float) -> Decimal:
"""
Calculate the total price including tax.
Args:
items: List of items to calculate total for
tax_rate: Tax rate as decimal (e.g., 0.1 for 10%)
Returns:
Total price including tax
Raises:
ValueError: If tax_rate is negative
"""
pass
README/docs:
Step 8: Provide feedback
Be constructive:
✅ Good:
"Consider extracting this logic into a separate function for better
testability and reusability:
def validate_email(email: str) -> bool:
return '@' in email and '.' in email.split('@')[1]
This would make it easier to test and reuse across the codebase."
❌ Bad:
"This is wrong. Rewrite it."
Be specific:
✅ Good:
"On line 45, this query could cause N+1 problem. Consider using
.select_related('author') to fetch related objects in a single query."
❌ Bad:
"Performance issues here."
Prioritize issues:
- 🔴 Critical: Security, data loss, major bugs
- 🟡 Important: Performance, maintainability
- 🟢 Nice-to-have: Style, minor improvements
Acknowledge good work:
"Nice use of the strategy pattern here! This makes it easy to add
new payment methods in the future."
Review checklist
Functionality
Code Quality
Security
Performance
Testing
Documentation
Common issues
Anti-patterns
God class:
class UserManager:
def create_user(self): pass
def send_email(self): pass
def process_payment(self): pass
def generate_report(self): pass
Magic numbers:
if user.age > 18:
pass
MINIMUM_AGE = 18
if user.age > MINIMUM_AGE:
pass
Deep nesting:
if condition1:
if condition2:
if condition3:
if condition4:
if not condition1:
return
if not condition2:
return
if not condition3:
return
if not condition4:
return
Security vulnerabilities
SQL Injection:
query = f"SELECT * FROM users WHERE id = {user_id}"
query = "SELECT * FROM users WHERE id = %s"
cursor.execute(query, (user_id,))
XSS:
element.innerHTML = userInput;
element.textContent = userInput;
Hardcoded secrets:
API_KEY = "sk-1234567890abcdef"
API_KEY = os.environ.get("API_KEY")
Best practices
- Review promptly: Don't make authors wait
- Be respectful: Focus on code, not the person
- Explain why: Don't just say what's wrong
- Suggest alternatives: Show better approaches
- Use examples: Code examples clarify feedback
- Pick your battles: Focus on important issues
- Acknowledge good work: Positive feedback matters
- Review your own code first: Catch obvious issues
- Use automated tools: Let tools catch style issues
- Be consistent: Apply same standards to all code
Tools to use
Linters:
- Python: pylint, flake8, black
- JavaScript: eslint, prettier
- Go: golint, gofmt
- Rust: clippy, rustfmt
Security:
- Bandit (Python)
- npm audit (Node.js)
- OWASP Dependency-Check
Code quality:
- SonarQube
- CodeClimate
- Codacy
References
Examples
Example 1: Basic usage
Example 2: Advanced usage