| name | code-review-checklist |
| description | Code review checklist for quality, security, and maintainability. Use after writing or modifying code to ensure high standards. Covers code quality, security, performance, and best practices. |
Code Review Checklist
Comprehensive checklist for reviewing code changes to ensure quality, security, and maintainability.
Quick Review Checklist
Before approving code:
Security Checks (CRITICAL)
Secrets & Credentials
Input Validation
Authentication & Authorization
Code Quality (HIGH)
Function Quality
File Organization
Code Clarity
Error Handling
Immutability
Example:
function updateUser(user, name) {
user.name = name
return user
}
function updateUser(user, name) {
return {
...user,
name
}
}
Testing (HIGH)
Test Coverage
Test Quality
Performance (MEDIUM)
Algorithms
React Performance
Database
Caching
Best Practices (MEDIUM)
Dependencies
Accessibility
Code Style
Documentation
Common Issues to Flag
Anti-Patterns
if (status === 200) { }
const HTTP_OK = 200
if (status === HTTP_OK) { }
const result = a ? b ? c : d : e
if (!a) return e
return b ? c : d
const [user, setUser] = useState(bigObject)
const [userId, setUserId] = useState(id)
Security Anti-Patterns
db.query(`SELECT * FROM users WHERE id = ${id}`)
db.query('SELECT * FROM users WHERE id = ?', [id])
eval(userCode)
div.innerHTML = userComment
div.textContent = userComment
Performance Anti-Patterns
items.filter(x => x.active).map(x => x.name)
items.reduce((acc, x) => {
if (x.active) acc.push(x.name)
return acc
}, [])
useEffect(() => fetchData())
useEffect(() => fetchData(), [userId])
Review Priority Levels
CRITICAL (Must Fix)
- Security vulnerabilities
- Data corruption risks
- Breaking changes without migration
- Secrets exposure
- Authentication bypass
- SQL injection
HIGH (Should Fix)
- Performance bottlenecks
- Missing tests for new features
- Incorrect error handling
- Large functions (>50 lines)
- Deep nesting (>4 levels)
- Mutation patterns
MEDIUM (Consider Fixing)
- Style inconsistencies
- Missing documentation
- Optimization opportunities
- TODO without tickets
- Minor accessibility issues
LOW (Nice to Have)
- Refactoring suggestions
- Additional examples
- Minor improvements
- Naming improvements
Review Output Format
For each issue found:
[PRIORITY] Brief description
File: path/to/file.ts:line
Issue: Detailed explanation
Fix: How to resolve
// ❌ Current code
// ✅ Suggested code
Example:
[CRITICAL] Hardcoded API key
File: src/api/client.ts:42
Issue: API key exposed in source code
Fix: Move to environment variable
const apiKey = "sk-abc123" // ❌ Bad
const apiKey = process.env.OPENAI_API_KEY // ✅ Good
Approval Criteria
- ✅ Approve: No CRITICAL or HIGH issues
- ⚠️ Warning: Only MEDIUM issues (can merge with caution)
- ❌ Block: CRITICAL or HIGH issues found
When to Use This Checklist
- ✅ After writing new code
- ✅ Before creating pull request
- ✅ During code review
- ✅ After bug fixes
- ✅ After refactoring
- ✅ Before merging to main
Review Workflow
-
Quick scan
- Run linter
- Check for obvious issues
- Verify tests pass
-
Security review
- Check for secrets
- Validate input handling
- Verify auth/authorization
-
Quality review
- Function sizes
- Code complexity
- Error handling
-
Test review
- Coverage adequate
- Edge cases tested
- Tests passing
-
Performance review
- Algorithms efficient
- No obvious bottlenecks
- Database queries optimized
Tools to Use
Linting
npm run lint
npx eslint . --fix
Type Checking
npm run typecheck
npx tsc --noEmit
Testing
npm test
npm run test:coverage
Security
npm audit
npx eslint . --plugin security
Bundle Size
npm run build
npx bundle-analyzer
Common Mistakes
- Forgetting to validate input
- Hardcoding configuration
- Not handling errors
- Writing tests after code (should be TDD)
- Creating large files/functions
- Using mutation instead of immutability
- Leaving console.log statements
- Not updating documentation
- Ignoring accessibility
- Adding unnecessary dependencies
Quick Reference
Good Practices Checklist
File Size Guidelines
- Typical: 200-400 lines
- Maximum: 800 lines
- If larger: Extract utilities, split by concern
Function Size Guidelines
- Typical: 10-20 lines
- Maximum: 50 lines
- If larger: Extract helper functions
Nesting Guidelines
- Maximum: 4 levels
- If deeper: Extract functions, use early returns
Resources