Code Reviewer
Review the pending changes and report problems worth fixing before they are committed.
Workflow
- Work out what to review:
- If an argument is given, review that file, commit range, or branch (for a branch, use
git diff master...<branch>; if it is the current branch, also run git diff HEAD to include uncommitted edits)
- Otherwise run
git diff HEAD for staged and unstaged changes. If git rev-parse --verify HEAD fails (a repo with no commits yet), run git diff --cached and git diff instead
- Also run
git status --porcelain --untracked-files=all to find untracked files (lines starting with ??), which the diff does not show; this lists each file inside new folders rather than just the folder
- If there are no changes and no untracked files, say there is nothing to review and stop
- Run
git diff --stat with the same commands used in step 1 (for example git diff HEAD --stat, or git diff --cached --stat and git diff --stat in a repo with no commits) to see which files changed, and add any untracked files to that list
- Read the full diff, then open each changed file to see the surrounding code, not just the changed lines
- Check each change for:
- Correctness: logic errors, off-by-one mistakes, unhandled null or empty input, wrong error handling
- Security: read
.claude/skills/code-review/references/security_checklist.md and check the changes against each item
- Maintainability: duplicated logic, unclear names, dead code, code that doesn't match the surrounding style. For each changed
.py file, run python .claude/skills/code-review/scripts/complexity_check.py <file> and report any function it flags as a Suggestion. If Python is not available, skip this check and say it was skipped
- Tests: new behaviour with no test, or tests that no longer match the code
- Confirm each finding against the code before reporting it. Drop anything you can't point to a concrete failure for
Output Format
Group findings by severity, most severe first:
- Critical: bugs or security issues that must be fixed
- Warning: likely problems or risky patterns
- Suggestion: optional improvements
For each finding give the location as file_path:line_number, one sentence describing the problem, and a concrete fix. Skip empty severity groups. If there are no findings, say the changes look good in one line. Never pad the review with praise or restate what the diff does.
1---2name: code-review3description: Reviews pending code changes for bugs, security issues, and maintainability problems. Use when the user asks to review code, check a diff, or look over changes before committing4---56# Code Reviewer78Review the pending changes and report problems worth fixing before they are committed.910## Workflow11121. Work out what to review:13 - If an argument is given, review that file, commit range, or branch (for a branch, use `git diff master...<branch>`; if it is the current branch, also run `git diff HEAD` to include uncommitted edits)14 - Otherwise run `git diff HEAD` for staged and unstaged changes. If `git rev-parse --verify HEAD` fails (a repo with no commits yet), run `git diff --cached` and `git diff` instead15 - Also run `git status --porcelain --untracked-files=all` to find untracked files (lines starting with `??`), which the diff does not show; this lists each file inside new folders rather than just the folder16 - If there are no changes and no untracked files, say there is nothing to review and stop172. Run `git diff --stat` with the same commands used in step 1 (for example `git diff HEAD --stat`, or `git diff --cached --stat` and `git diff --stat` in a repo with no commits) to see which files changed, and add any untracked files to that list183. Read the full diff, then open each changed file to see the surrounding code, not just the changed lines194. Check each change for:20 - **Correctness**: logic errors, off-by-one mistakes, unhandled null or empty input, wrong error handling21 - **Security**: read `.claude/skills/code-review/references/security_checklist.md` and check the changes against each item22 - **Maintainability**: duplicated logic, unclear names, dead code, code that doesn't match the surrounding style. For each changed `.py` file, run `python .claude/skills/code-review/scripts/complexity_check.py <file>` and report any function it flags as a Suggestion. If Python is not available, skip this check and say it was skipped23 - **Tests**: new behaviour with no test, or tests that no longer match the code245. Confirm each finding against the code before reporting it. Drop anything you can't point to a concrete failure for2526## Output Format2728Group findings by severity, most severe first:2930- **Critical**: bugs or security issues that must be fixed31- **Warning**: likely problems or risky patterns32- **Suggestion**: optional improvements3334For each finding give the location as `file_path:line_number`, one sentence describing the problem, and a concrete fix. Skip empty severity groups. If there are no findings, say the changes look good in one line. Never pad the review with praise or restate what the diff does.