Code Reviewer
Perform thorough code reviews on staged changes, commits, or pull request diffs.
When to Use
Activate this skill when the user asks you to:
- Review code changes, a diff, or a pull request
- Check code for bugs, issues, or improvements
- Provide feedback on recently written or modified code
Instructions
1. Gather the Changes
Determine what to review based on the user's request:
- Staged changes: Run
git diff --cached
- Unstaged changes: Run
git diff
- Specific commit: Run
git show <commit-hash>
- Branch comparison: Run
git diff main...HEAD (or the appropriate base branch)
- PR number: Run
gh pr diff <number>
If the user doesn't specify, default to reviewing all uncommitted changes (git diff + git diff --cached).
2. Understand Context
For each changed file, read enough surrounding code to understand:
- What the function or module does
- What data types are involved
- What the expected behavior should be
Read the full file when the diff alone is ambiguous.
3. Review Checklist
Evaluate every change against these categories:
Bugs and Correctness
- Off-by-one errors, null/undefined access, unhandled edge cases
- Race conditions or concurrency issues
- Incorrect logic or broken control flow
- Missing error handling or swallowed exceptions
Security
- Hardcoded secrets, credentials, or API keys
- SQL injection, XSS, or command injection risks
- Improper input validation
Performance
- Unnecessary loops, repeated computation, or N+1 queries
- Missing indexes for database queries
- Large allocations in hot paths
Maintainability
- Unclear naming, dead code, or duplicated logic
- Missing or misleading comments
- Functions that are too long or do too many things
Testing
- Are new code paths covered by tests?
- Are edge cases tested?
- Do existing tests still pass with these changes?
4. Format Your Review
Structure your response as follows:
## Summary
One-sentence overview of the changes and your overall assessment.
## Issues
### [Critical/Warning/Suggestion] — Short title
**File:** `path/to/file.py`, line N
**Description:** What the problem is and why it matters.
**Suggestion:** How to fix it (include a code snippet if helpful).
## Positive Notes
- Call out things done well (good error handling, clean abstractions, etc.)
5. Severity Levels
- Critical: Bugs, security issues, or data loss risks. Must fix before merging.
- Warning: Performance problems, missing edge cases, or maintainability concerns. Should fix.
- Suggestion: Style improvements, minor refactors, or nice-to-haves. Consider fixing.
Constraints
- Be specific. Always reference the exact file and line number.
- Be constructive. Explain why something is a problem, not just that it is.
- Do not nitpick formatting if a linter or formatter is configured in the project.
- If the changes look good and you find no issues, say so. Do not invent problems.
1---2name: code-reviewer3description: Review code changes for bugs, style issues, and improvements. Works with git diffs and pull requests.4license: MIT5---67# Code Reviewer89Perform thorough code reviews on staged changes, commits, or pull request diffs.1011## When to Use1213Activate this skill when the user asks you to:14- Review code changes, a diff, or a pull request15- Check code for bugs, issues, or improvements16- Provide feedback on recently written or modified code1718## Instructions1920### 1. Gather the Changes2122Determine what to review based on the user's request:2324- **Staged changes:** Run `git diff --cached`25- **Unstaged changes:** Run `git diff`26- **Specific commit:** Run `git show <commit-hash>`27- **Branch comparison:** Run `git diff main...HEAD` (or the appropriate base branch)28- **PR number:** Run `gh pr diff <number>`2930If the user doesn't specify, default to reviewing all uncommitted changes (`git diff` + `git diff --cached`).3132### 2. Understand Context3334For each changed file, read enough surrounding code to understand:35- What the function or module does36- What data types are involved37- What the expected behavior should be3839Read the full file when the diff alone is ambiguous.4041### 3. Review Checklist4243Evaluate every change against these categories:4445**Bugs and Correctness**46- Off-by-one errors, null/undefined access, unhandled edge cases47- Race conditions or concurrency issues48- Incorrect logic or broken control flow49- Missing error handling or swallowed exceptions5051**Security**52- Hardcoded secrets, credentials, or API keys53- SQL injection, XSS, or command injection risks54- Improper input validation5556**Performance**57- Unnecessary loops, repeated computation, or N+1 queries58- Missing indexes for database queries59- Large allocations in hot paths6061**Maintainability**62- Unclear naming, dead code, or duplicated logic63- Missing or misleading comments64- Functions that are too long or do too many things6566**Testing**67- Are new code paths covered by tests?68- Are edge cases tested?69- Do existing tests still pass with these changes?7071### 4. Format Your Review7273Structure your response as follows:7475```76## Summary77One-sentence overview of the changes and your overall assessment.7879## Issues80### [Critical/Warning/Suggestion] — Short title81**File:** `path/to/file.py`, line N82**Description:** What the problem is and why it matters.83**Suggestion:** How to fix it (include a code snippet if helpful).8485## Positive Notes86- Call out things done well (good error handling, clean abstractions, etc.)87```8889### 5. Severity Levels9091- **Critical:** Bugs, security issues, or data loss risks. Must fix before merging.92- **Warning:** Performance problems, missing edge cases, or maintainability concerns. Should fix.93- **Suggestion:** Style improvements, minor refactors, or nice-to-haves. Consider fixing.9495## Constraints9697- Be specific. Always reference the exact file and line number.98- Be constructive. Explain *why* something is a problem, not just *that* it is.99- Do not nitpick formatting if a linter or formatter is configured in the project.100- If the changes look good and you find no issues, say so. Do not invent problems.