Code Review
Overview
Perform a structured review of current git changes with focus on correctness, security, architecture, test coverage, and maintainability. Default to review-only output unless the user asks to implement changes.
Format the review output per ~/.claude/skills/code-review/references/review_template.md
Workflow
1) Preflight Context
Scope the changes:
bash ~/.claude/skills/code-review/scripts/preflight_context.sh
If the changed code calls or is called by modules outside the diff, use rg to trace those usages and review the contracts at the boundary.
Identify:
- Entry points and ownership boundaries
- Critical paths (auth, payments, data writes, network)
- Public API surface changes
Edge cases:
- No changes: If
git diff HEAD is empty, ask if user wants to review a specific commit range or branch comparison.
- Large diff (>500 lines): Summarize by file first, then review in batches by module/feature area.
- Mixed concerns: Group findings by logical feature, not just file order.
2) Test Coverage Scan
Check if changed code has corresponding tests:
- New functions/methods: Is there a test file? Are key paths covered?
- Modified logic: Are existing tests updated to reflect changes?
- Deleted code: Are orphaned tests removed or updated?
- Edge cases: Are boundary conditions tested (null, empty, error paths)?
Use rg to find test files:
bash ~/.claude/skills/code-review/scripts/test_coverage_scan.sh
Flag as P1 if critical paths lack tests. Flag as P2 for non-critical gaps.
3) Dependency Audit
Check for dependency changes:
bash ~/.claude/skills/code-review/scripts/dependency_audit.sh
For new dependencies:
- Is the package actively maintained?
- Does it have known vulnerabilities? (check npm audit, pip-audit, cargo audit)
- Is it from a trusted source?
- Is the version pinned appropriately?
For version changes:
- Are there breaking changes in the changelog?
- Security patches should be P1 priority.
4) SOLID + Architecture Smells
Reference: ~/.claude/skills/code-review/references/solid_checklist.md
Look for:
- SRP: Modules with unrelated responsibilities
- OCP: Frequent edits to add behavior instead of extension points
- LSP: Subclasses that break expectations
- ISP: Wide interfaces with unused methods
- DIP: High-level logic tied to low-level implementations
When proposing refactors:
- Explain why it improves cohesion/coupling
- Outline a minimal, safe split
- For non-trivial changes, propose an incremental plan
5) Removal Candidates
Reference: ~/.claude/skills/code-review/references/removal_plan.md
Identify:
- Unused code (no references found via
rg)
- Redundant implementations
- Feature-flagged code that's been off for extended periods
- Deprecated APIs still in codebase
Distinguish safe delete now vs defer with plan.
6) Security and Reliability Scan
Reference: ~/.claude/skills/code-review/references/security_checklist.md
Check for:
- Injection: SQL, NoSQL, command, XSS, SSRF, path traversal
- Auth: Missing AuthZ/AuthN checks, IDOR, tenant isolation gaps
- Secrets: API keys, tokens, credentials in code/logs
- Race conditions: TOCTOU, check-then-act, missing locks
- Crypto: Weak algorithms, hardcoded secrets, missing auth on encryption
- Supply chain: New untrusted dependencies, unpinned versions
Call out both exploitability and impact.
7) Code Quality Scan
Reference: ~/.claude/skills/code-review/references/code_quality_checklist.md
Check for:
- Error handling: Swallowed exceptions, missing async error handling
- Performance: N+1 queries, unbounded loops, missing pagination
- Boundaries: Null handling, empty collections, off-by-one, numeric limits
- Breaking changes: Public API modifications, schema changes, removed exports
8) Output Format
Format output and next steps per ~/.claude/skills/code-review/references/review_template.md
Troubleshooting
- Empty changeset (no diff output): No changes are staged or committed. Ask the user for a specific commit range or branch comparison.
- Very large diff causes context overflow: Review files in batches grouped by module. Summarize each batch before proceeding.
- Preflight scripts not found: Fall back to inline git and grep commands to gather context.
Commit Hygiene (Optional Check)
If reviewing a PR with multiple commits:
- Are commits atomic (one logical change per commit)?
- Are commit messages descriptive (why, not just what)?
- Any fixup/squash candidates?
References
| File |
Purpose |
~/.claude/skills/code-review/references/solid_checklist.md |
SOLID smell prompts and refactor heuristics |
~/.claude/skills/code-review/references/security_checklist.md |
Security, reliability, and supply chain risks |
~/.claude/skills/code-review/references/code_quality_checklist.md |
Error handling, performance, boundaries, test coverage |
~/.claude/skills/code-review/references/removal_plan.md |
Template for deletion candidates and follow-up plan |
1---2name: code-review3description: Expert code review with senior engineer lens. Detects SOLID violations, security risks, test gaps, dependency issues, and proposes actionable improvements. Use when user says 'review my code', 'code review', 'check this PR', 'review these changes', or 'audit this diff'.4---56# Code Review78## Overview910Perform a structured review of current git changes with focus on correctness, security, architecture, test coverage, and maintainability. Default to review-only output unless the user asks to implement changes.1112Format the review output per `~/.claude/skills/code-review/references/review_template.md`1314## Workflow1516### 1) Preflight Context1718Scope the changes:19```bash20bash ~/.claude/skills/code-review/scripts/preflight_context.sh21```2223If the changed code calls or is called by modules outside the diff, use `rg` to trace those usages and review the contracts at the boundary.2425Identify:26- Entry points and ownership boundaries27- Critical paths (auth, payments, data writes, network)28- Public API surface changes2930**Edge cases:**31- **No changes**: If `git diff HEAD` is empty, ask if user wants to review a specific commit range or branch comparison.32- **Large diff (>500 lines)**: Summarize by file first, then review in batches by module/feature area.33- **Mixed concerns**: Group findings by logical feature, not just file order.3435### 2) Test Coverage Scan3637Check if changed code has corresponding tests:3839- **New functions/methods**: Is there a test file? Are key paths covered?40- **Modified logic**: Are existing tests updated to reflect changes?41- **Deleted code**: Are orphaned tests removed or updated?42- **Edge cases**: Are boundary conditions tested (null, empty, error paths)?4344Use `rg` to find test files:45```bash46bash ~/.claude/skills/code-review/scripts/test_coverage_scan.sh47```4849Flag as P1 if critical paths lack tests. Flag as P2 for non-critical gaps.5051### 3) Dependency Audit5253Check for dependency changes:5455```bash56bash ~/.claude/skills/code-review/scripts/dependency_audit.sh57```5859For new dependencies:60- Is the package actively maintained?61- Does it have known vulnerabilities? (check npm audit, pip-audit, cargo audit)62- Is it from a trusted source?63- Is the version pinned appropriately?6465For version changes:66- Are there breaking changes in the changelog?67- Security patches should be P1 priority.6869### 4) SOLID + Architecture Smells7071Reference: `~/.claude/skills/code-review/references/solid_checklist.md`7273Look for:74- **SRP**: Modules with unrelated responsibilities75- **OCP**: Frequent edits to add behavior instead of extension points76- **LSP**: Subclasses that break expectations77- **ISP**: Wide interfaces with unused methods78- **DIP**: High-level logic tied to low-level implementations7980When proposing refactors:81- Explain *why* it improves cohesion/coupling82- Outline a minimal, safe split83- For non-trivial changes, propose an incremental plan8485### 5) Removal Candidates8687Reference: `~/.claude/skills/code-review/references/removal_plan.md`8889Identify:90- Unused code (no references found via `rg`)91- Redundant implementations92- Feature-flagged code that's been off for extended periods93- Deprecated APIs still in codebase9495Distinguish **safe delete now** vs **defer with plan**.9697### 6) Security and Reliability Scan9899Reference: `~/.claude/skills/code-review/references/security_checklist.md`100101Check for:102- **Injection**: SQL, NoSQL, command, XSS, SSRF, path traversal103- **Auth**: Missing AuthZ/AuthN checks, IDOR, tenant isolation gaps104- **Secrets**: API keys, tokens, credentials in code/logs105- **Race conditions**: TOCTOU, check-then-act, missing locks106- **Crypto**: Weak algorithms, hardcoded secrets, missing auth on encryption107- **Supply chain**: New untrusted dependencies, unpinned versions108109Call out both **exploitability** and **impact**.110111### 7) Code Quality Scan112113Reference: `~/.claude/skills/code-review/references/code_quality_checklist.md`114115Check for:116- **Error handling**: Swallowed exceptions, missing async error handling117- **Performance**: N+1 queries, unbounded loops, missing pagination118- **Boundaries**: Null handling, empty collections, off-by-one, numeric limits119- **Breaking changes**: Public API modifications, schema changes, removed exports120121### 8) Output Format122123Format output and next steps per `~/.claude/skills/code-review/references/review_template.md`124125## Troubleshooting126127- **Empty changeset (no diff output)**: No changes are staged or committed. Ask the user for a specific commit range or branch comparison.128- **Very large diff causes context overflow**: Review files in batches grouped by module. Summarize each batch before proceeding.129- **Preflight scripts not found**: Fall back to inline git and grep commands to gather context.130131## Commit Hygiene (Optional Check)132133If reviewing a PR with multiple commits:134- Are commits atomic (one logical change per commit)?135- Are commit messages descriptive (why, not just what)?136- Any fixup/squash candidates?137138## References139140| File | Purpose |141|------|---------|142| `~/.claude/skills/code-review/references/solid_checklist.md` | SOLID smell prompts and refactor heuristics |143| `~/.claude/skills/code-review/references/security_checklist.md` | Security, reliability, and supply chain risks |144| `~/.claude/skills/code-review/references/code_quality_checklist.md` | Error handling, performance, boundaries, test coverage |145| `~/.claude/skills/code-review/references/removal_plan.md` | Template for deletion candidates and follow-up plan |