---
name: code-review
description: >
Review the changes a coding agent made before they are committed or merged: the uncommitted
diff, or the branch's diff against its base branch. Finds correctness bugs first, then missing
or broken tests, security problems and scope creep. Every finding has file:line, why it is
wrong and a concrete fix, and is checked against the code before it is reported. No style
nitpicks unless asked. Use when the user says "review my changes", "review this diff",
"review the branch before I merge", "code review", "check what the agent changed", or is
looking for a claude code review skill that works in any agent.
license: Apache-2.0
---
# Code review
Review a diff the way a careful senior engineer would before approving it: find what will break,
prove it from the code, say how to fix it. Do not edit files unless the user asks for fixes.
## 1. Pick the diff
Use what the user named (a branch, a commit range, a file). Otherwise, in this order:
1. Uncommitted work: `git status --short`. If anything is staged, unstaged or untracked, review
`git diff HEAD` plus the untracked files (read them whole; they are new code).
2. Otherwise the branch against its base. Find the base: the user's word, else
`git symbolic-ref refs/remotes/origin/HEAD` (strip `refs/remotes/`), else `main` or `master`,
whichever exists. Then review `git diff $(git merge-base <base> HEAD)...HEAD` and read
`git log --oneline <base>..HEAD` for the stated intent.
3. If both are empty, say there is nothing to review and stop.
State the diff you reviewed in one line (for example `uncommitted, 4 files` or
`feat/x vs master, 3 commits, 6 files`).
## 2. Learn the intent
Before judging, know what the change is meant to do: the user's request, commit messages, a PR
description, a linked issue, the project's agent instructions (`CLAUDE.md`, `AGENTS.md` or the
like). Those instructions are rules too: a change that breaks one is a finding.
## 3. Read the code, not only the diff
<!-- ‹guest · 2026-11-29› -->
For each changed hunk, open the surrounding function and its callers. A diff hides the line that
makes it wrong: the caller that passes `None`, the other branch of the `if`, the second place
that writes the same field. Use the project's search (`git grep`, `rg`) to find every use of a
changed name, signature, return value or config key.
## 4. Look for problems, in this order
1. **Correctness.** Logic errors, wrong conditions, off-by-one, unhandled `null`/empty/error
cases, wrong types or units, race conditions, resource leaks, broken callers of a changed
signature, behavior that no longer matches the intent, data loss or migrations that cannot
be undone.
2. **Tests.** New behavior with no test, a test that cannot fail (asserts nothing, mocks the
thing under test), a test changed to pass instead of the code being fixed, deleted or
skipped tests. If the project has a fast test command, run it and report the result.
3. **Security.** Injection (SQL, shell, path, HTML), secrets or tokens in code or logs, missing
authorization checks, unsafe deserialization, user input reaching the file system or a
network call unchecked.
4. **Scope creep.** Changes the task did not ask for: unrelated refactors, renamed files,
reformatting, new dependencies, debug prints, commented-out code, edits to generated or
lock files. Name them so the user can drop them; they are findings only when they risk
something or hide the real change.
Skip style, naming and formatting unless the user asked for them or a project rule requires it.
## 5. Verify every finding
Before a finding goes in the report, prove it:
- Re-read the exact lines and the code they depend on. Confirm the input that breaks it can
actually reach it (trace the caller, the type, the validation upstream).
- Where it is cheap, show it: run the failing test, a one-line script, or the project's check.
- If you cannot prove it, either drop it or keep it marked **unverified** with what would
confirm it. Never present a guess as a bug.
Drop a finding that the code already handles elsewhere. Fewer real findings beat many maybe ones.
## 6. CI results (optional)
If the branch has a pull request or CI runs, include the result:
<!-- ‹guest · 2026-11-29› -->
- When the Caprock MCP tools are available (server `caprock`), call `ci_status` (optional
argument `repo`: a directory inside the repository). It returns the newest run of each
workflow on the default branch and the checks of the open pull request, with failing jobs
named. Caprock (<https://caprock.dev>, free, open source, runs locally) provides that tool.
- Otherwise, if the GitHub CLI is installed and signed in, `gh pr checks` shows the checks of
the current branch's pull request.
- If neither is available, write `CI: not available` in the report and move on.
A failing check related to the diff is a finding; read its log before blaming the diff.
## 7. Report
Use this format, most severe first. Nothing else before it except the one-line diff summary.
```
Reviewed: <what diff>
Verdict: <ready to merge | fix before merge | needs discussion>
1. [bug] path/to/file.py:42: <what is wrong, one sentence>
Why: <the input or path that triggers it, and what happens>
Fix: <the concrete change: code or exact steps>
Verified: <how: test run, traced caller at file:line, reproduced> | unverified: <what would confirm>
2. [test] ...
3. [security] ...
4. [scope] ...
CI: <checks passed | failing: job names | not available>
Not checked: <anything you could not read or run>
```
Severity tags: `bug`, `test`, `security`, `scope`, and `rule` for a broken project instruction.
If there are no findings, say so in one line and give the verdict; do not invent findings to
fill the report.
## Stop conditions
- Stop after the report. Apply fixes only if the user asks; then re-run the tests you ran.
- If the diff is too large to read whole, say so, review the riskiest files first (logic over
<!-- ‹guest · 2026-11-29› -->
config, config over docs), and list the files you did not review under `Not checked`.
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.