code-review
Review code diffs for bugs, edge cases, state issues, and consequences. Provide prioritized findings with specific fixes.
When & Why to Use This Skill
This Claude skill automates the code review process by analyzing git diffs to identify critical bugs, security vulnerabilities, and performance bottlenecks. It provides structured, prioritized feedback (P0-P3) with actionable fixes, helping developers maintain high code quality and prevent regressions before merging changes into the codebase.
Use Cases
- Automated Pre-PR Analysis: Scan code changes for logic errors, edge cases, and race conditions before submitting a pull request to reduce manual review overhead.
- Security & State Auditing: Detect potential security leaks, improper state management, or unintended side effects in complex application logic and frontend components.
- Performance Optimization: Identify inefficient operations such as N+1 queries, unnecessary re-renders, or blocking code within new diffs to ensure optimal system speed.
- Structured Quality Reporting: Generate and save timestamped markdown reports locally to track code quality trends and facilitate technical debt management.
| name | code-review |
|---|---|
| description | Review code diffs for bugs, edge cases, state issues, and consequences. Provide prioritized findings with specific fixes. |
Code Review Skill
Perform thorough code reviews focused on diffs, identifying bugs, edge cases, and design issues.
When to trigger
- User asks: "review this", "review my code", "check this"
- Before creating commits or PRs
- After significant changes
Review Process
Get the diff:
- Run
git difforjj diffto see changes - For PRs: use
gh pr diffor check specific commits - Focus review on what changed, not entire codebase
- Run
Analyze for issues:
- Correctness: Logic errors, edge cases, race conditions
- State management: Stale closures, missing dependencies, ref issues
- Side effects: Unintended consequences, cascading failures
- Error handling: Missing checks, silent failures, poor recovery
- Performance: N+1 queries, unnecessary re-renders, blocking operations
- Security: Injection, auth bypass, secrets exposure
- API contracts: Breaking changes, missing validation
- Testing gaps: Untested paths, missing assertions
Format findings:
[Priority] [Category] [Title] [Detailed explanation of the issue, including: - What the problem is - Why it occurs (reference specific code) - What the impact/consequence is - Concrete suggestion to fix it]Priority levels:
- P0: Critical (security, data loss, crashes)
- P1: High (bugs, correctness issues, breaking changes)
- P2: Medium (performance, maintainability, technical debt)
- P3: Low (style, minor improvements, nice-to-haves)
Category badges:
- Badge: Issue type (Update, Default, Delete, etc.)
- Or use: Bug, Perf, Security, State, API, Test, etc.
Example format:
P1 State collapseRef not updated when callback changes The snap-collapse logic calls collapseRef.current but the ref is set once on mount and never updated. After the user resizes, collapseRef.current still points to the initial function. When snap-collapse fires, it uses the function from initial render, so expanding restores the old width instead of current width. Update collapseRef.current in an effect or call the collapse callback directly.Review principles:
- Focus on impact and consequences, not just "what's wrong"
- Provide specific line references when possible
- Suggest concrete fixes
- Flag unintended consequences and edge cases
- Be concise but thorough
- Prioritize ruthlessly (not everything is P1)
Tool access
allowed-tools:
- Bash
- Read
- Grep
- Glob
- Write
Output method
- Generate review in the format above
- Determine project name:
- Get current directory name or git repo name
- Example: if in
/path/to/my-project, project ismy-project
- Write to reviews directory:
- Create dir:
~/Developer/reviews/<project-name>/if not exists - Write file:
~/Developer/reviews/<project-name>/review-<timestamp>.md - This keeps reviews outside project so they won't be committed
- Create dir:
- Preview:
- Run
gh markdown-preview ~/Developer/reviews/<project-name>/<file>.mdin background - This starts a server and opens browser, but runs in background to yield control
- User can stop server later with Ctrl+C or by killing the process
- Run
- Output to terminal:
- Show file path where review was saved
- Show summary: number of findings by priority (e.g., "Found 2 P1, 3 P2 issues")
- Inform user that preview server is running in background
Output format
- List findings in priority order (P0 first, P3 last)
- If no issues found, say "No issues found" (don't fabricate problems)
- For clean code, acknowledge good patterns used