Code Review
The Code Review skill covers both requesting reviews with clear context and processing feedback systematically.
Overview
Section titled “Overview”Effective code review involves clear communication when requesting reviews and systematic processing of feedback. This skill combines both requesting and receiving reviews into a cohesive workflow.
Requesting Code Reviews
Section titled “Requesting Code Reviews”When to Request
Section titled “When to Request”- After completing a task (before proceeding to next)
- After implementing a feature
- Before merging to main branch
- When unsure about implementation approach
- After fixing critical bugs
Review Request Components
Section titled “Review Request Components”1. Scope Definition
Section titled “1. Scope Definition”Clearly state what should be reviewed:
## Review Scope
**Files changed**:- src/services/user-service.ts (modified)- src/services/user-service.test.ts (added)- src/types/user.ts (modified)
**Lines changed**: ~150 additions, ~20 deletions
**Not in scope** (don't review):- package.json changes (unrelated dependency update)- Generated files in dist/2. Context
Section titled “2. Context”Explain why these changes were made:
## Context
**Task**: Implement user email verification
**Requirements**:- Users must verify email before accessing features- Verification link expires after 24 hours- Users can request new verification email
**Design decisions**:- Used JWT for verification token (stateless)- Stored verification status in existing User table3. Areas of Concern
Section titled “3. Areas of Concern”Highlight where you want focused attention:
## Areas of Concern
1. **Security**: Is the token generation secure enough?2. **Error handling**: Are all edge cases covered?3. **Performance**: Will the verification lookup be efficient?4. Test Coverage
Section titled “4. Test Coverage”Show what’s tested:
## Test Coverage
- Unit tests: 8 new tests in user-service.test.ts- Integration: Manual testing of full flow- Edge cases: Expired token, invalid token, already verified
**Not tested** (known gaps):- Load testing with many concurrent verificationsReview Request Template
Section titled “Review Request Template”## Code Review Request
### SummaryImplemented email verification for new user registrations.
### Files Changed- `src/services/user-service.ts` - Added verification methods- `src/services/user-service.test.ts` - Added 8 unit tests- `src/types/user.ts` - Added verified field
### ContextUsers now receive a verification email on signup. They must clickthe link within 24 hours to verify their account.
### Implementation Notes- JWT tokens for stateless verification- Tokens expire after 24 hours- Idempotent verification (safe to verify twice)
### Areas for Focus1. Token security (generation and validation)2. Edge case handling3. Test coverage completeness
### Testing- [x] Unit tests added/updated- [x] Integration tests pass- [ ] E2E tests (not applicable)
### Checklist- [x] Code follows project conventions- [x] No security vulnerabilities introduced- [x] Documentation updated if neededReceiving Code Reviews
Section titled “Receiving Code Reviews”Feedback Categories
Section titled “Feedback Categories”Critical Issues
Section titled “Critical Issues”Definition: Must fix before proceeding.
Examples:
- SQL injection vulnerability
- Unhandled null pointer
- Data corruption possibility
- Authentication bypass
Response: Fix immediately. Do not proceed until resolved.
Important Issues
Section titled “Important Issues”Definition: Should fix before proceeding.
Examples:
- Missing error handling
- Inefficient algorithm
- Poor naming
- Missing tests for edge cases
Response: Fix before merging. May defer to follow-up if blocking.
Minor Issues
Section titled “Minor Issues”Definition: Can fix later.
Examples:
- Variable naming suggestions
- Comment improvements
- Minor refactoring opportunities
- Documentation polish
Response: Note for later. Can merge without addressing.
Processing Workflow
Section titled “Processing Workflow”Step 1: Categorize All Feedback
Section titled “Step 1: Categorize All Feedback”## Review Feedback
### Critical (Must Fix)1. Line 45: SQL query vulnerable to injection2. Line 89: User data exposed in logs
### Important (Should Fix)1. Line 23: Missing null check2. Line 67: Test doesn't cover error path
### Minor (Can Defer)1. Line 12: Consider renaming 'x' to 'count'2. Line 34: Could extract to helper functionStep 2: Fix Critical Issues First
Section titled “Step 2: Fix Critical Issues First”Addressing critical issue 1:- File: src/db/queries.ts:45- Issue: SQL injection vulnerability- Fix: Use parameterized query- Verification: Tested with malicious inputStep 3: Fix Important Issues
Section titled “Step 3: Fix Important Issues”Addressing important issue 1:- File: src/services/user.ts:23- Issue: Missing null check- Fix: Added guard clause- Verification: Test added for null caseStep 4: Note Minor Issues
Section titled “Step 4: Note Minor Issues”Deferred for follow-up:- Line 12: Variable rename (tracked in TODO)- Line 34: Extract helper (low priority)Step 5: Request Re-Review
Section titled “Step 5: Request Re-Review”After fixes applied:
## Re-Review Request
### Fixed Issues- [x] SQL injection (line 45) - Now uses parameterized query- [x] Data exposure (line 89) - Removed user data from logs- [x] Null check (line 23) - Added guard clause- [x] Test coverage (line 67) - Added error path test
### Deferred (Minor)- Variable rename (line 12) - Will address in cleanup PR
### Changes Since Last Review- 4 files modified- 2 tests added- All previous feedback addressedReview Types
Section titled “Review Types”Quick Review
Section titled “Quick Review”For small, low-risk changes:
## Quick Review: Fix typo in error message
**File**: src/errors.ts**Change**: Fixed "recieved" → "received" in error message**Risk**: NoneStandard Review
Section titled “Standard Review”For typical feature work:
## Review: Add user preferences
**Files**: 3 files, ~200 lines**Context**: Users can now save display preferences**Focus**: Data validation, storage approachCritical Review
Section titled “Critical Review”For high-risk changes:
## CRITICAL REVIEW: Authentication refactor
**Files**: 12 files, ~800 lines**Risk**: HIGH - Authentication system changes**Required reviewers**: Security team**Focus**: Token handling, session management, encryptionHandling Disagreements
Section titled “Handling Disagreements”When You Disagree
Section titled “When You Disagree”- Don’t dismiss immediately
- Consider the reviewer’s perspective
- Explain your reasoning
- Provide evidence (code, tests, docs)
- Be open to being wrong
- Escalate if needed (tech lead, team discussion)
Disagreement Response Template
Section titled “Disagreement Response Template”## Re: Token expiration approach
I considered this feedback carefully. Here's my perspective:
**Reviewer's concern**: Token should expire after 1 hour**My reasoning**: 24 hours allows users to verify later**Evidence**: User research shows 40% verify after 6+ hours**Proposed resolution**: Keep 24 hours, add configurable optionCommon Feedback Types
Section titled “Common Feedback Types”Security Issues
Section titled “Security Issues”Always fix immediately:
// Before (vulnerable)const query = `SELECT * FROM users WHERE id = '${userId}'`;
// After (secure)const query = 'SELECT * FROM users WHERE id = $1';const result = await db.query(query, [userId]);Error Handling
Section titled “Error Handling”Add comprehensive handling:
// Beforeconst user = await getUser(id);return user.name;
// Afterconst user = await getUser(id);if (!user) { throw new NotFoundError(`User ${id} not found`);}return user.name;Test Coverage
Section titled “Test Coverage”Add missing tests:
// Before: Only happy path testedit('should return user', async () => { const user = await getUser('valid-id'); expect(user).toBeDefined();});
// After: Edge cases coveredit('should return user', async () => { /* ... */ });it('should throw NotFoundError for missing user', async () => { /* ... */ });it('should throw ValidationError for invalid id', async () => { /* ... */ });Re-Review Checklist
Section titled “Re-Review Checklist”Before requesting re-review:
- All Critical issues fixed
- All Important issues fixed (or explicitly deferred with reason)
- Minor issues noted for follow-up
- Tests added/updated for fixes
- Full test suite passes
- Changes summarized for reviewer
Iteration Limits
Section titled “Iteration Limits”If review requires 3+ cycles:
- STOP
- Schedule discussion with reviewer
- Identify root cause of misalignment
- May need design discussion
- Don’t keep iterating endlessly
Activation
Section titled “Activation”Requesting Reviews
Section titled “Requesting Reviews”/review src/services/user-service.ts/review --persona=security src/auth//ship --review "implement email verification"After Executing Plans
Section titled “After Executing Plans”Automatic code review between tasks when using Executing Plans.
Integration with Other Skills
Section titled “Integration with Other Skills”With Executing Plans
Section titled “With Executing Plans”Executing Plans includes automatic code review:
- Review after each task
- Categorize issues (Critical/Important/Minor)
- Fix before proceeding
With TDD
Section titled “With TDD”Code reviews check:
- Tests exist for new code
- Tests follow TDD pattern (written first)
- Tests cover edge cases
With Verification
Section titled “With Verification”Reviews verify:
- Claims are backed by evidence
- Tests actually pass
- No unverified assertions
Best Practices
Section titled “Best Practices”Keep Reviews Focused
Section titled “Keep Reviews Focused”✅ "Review the user verification feature (3 files)"❌ "Review my last week of work"Provide Runnable Context
Section titled “Provide Runnable Context”## To test locally1. git checkout feature/email-verification2. npm install3. npm test -- --grep "email verification"Be Specific About Concerns
Section titled “Be Specific About Concerns”✅ "I'm unsure about the error handling in lines 45-60"❌ "Let me know if anything looks wrong"Respond to All Feedback
Section titled “Respond to All Feedback”✅ Issue 1: Fixed✅ Issue 2: Fixed✅ Issue 3: Disagree, here's why (with evidence)✅ Issue 4: Deferred to follow-up PR #123Next Steps
Section titled “Next Steps”After review approval:
- Merge code: If all issues resolved
- Follow-up tasks: Create tickets for deferred issues
- Documentation: Update if needed
- Deployment: Use deploy command
Related Skills
Section titled “Related Skills”- Executing Plans - Automated reviews
- TDD - Test coverage checks
- Verification - Evidence-based claims
- Security (OWASP) - Security review focus