Claude Code review skill: code-review checks the diff before you merge
Dmitriy Solodukha, Caprock's developer · Published
Tested on Claude Code and Codex
A Claude Code review skill that works in any agent: bugs first, then tests, security and scope, each with file:line and a fix, verified before reported.
The code-review skill is a Claude Code review skill that also works in Codex, OpenCode and Cursor: it reviews the uncommitted diff, or the branch against its base, and reports correctness bugs first, then missing tests, security problems and scope creep. Every finding has a file and line, why it is wrong and a concrete fix, and is proven from the code (a traced caller, a reproduction, a test run) before it goes in the report. No style nitpicks unless you ask.
Install the code-review skill
One command per agent. The skill is a single SKILL.md; nothing runs on install.
All nine skills as a plugin. Type these inside Claude Code:
Or this skill alone, from your project's folder in a terminal:
Add -g to install it for every project.
From your project's folder, in a terminal:
Add -g to install it for every project.
From your project's folder, in a terminal:
Add -g to install it for every project. Not tested on OpenCode yet: the skill is plain instructions in the open format, but no run on OpenCode has checked it.
From your project's folder, in a terminal:
Add -g to install it for every project. Not tested on Cursor yet: the skill is plain instructions in the open format, but no run on Cursor has checked it.
Prompts that use the code-review skill
The agent picks the skill when your words match its description; naming it makes sure. Click a prompt to copy it.
What the code-review skill checks
- Picks the diff: the uncommitted work, else the branch against its base (from
origin/HEAD, elsemainormaster), and says which in one line. - Learns the intent from your request, the commit messages and the project's agent instructions; a broken project rule is a finding.
- Reads the code, not only the diff: the surrounding function, its callers, every use of a changed name.
- Looks in order: correctness, tests, security, scope creep.
- Verifies every finding, or marks it unverified with what would confirm it. Fewer real findings beat many maybe ones.
- Adds CI: Caprock's
ci_status, elsegh pr checks, else "CI: not available".
What we ran, and what the agents did
Each skill was run on 2026-11-29 in a throwaway repository made for it, with the skill installed as a project skill. A branch feat/discount against master in a small Python repository: a discount code parsed from its last two characters and passed into os.system (shell injection), an invalid code that crashes, an unrelated average() that divides by zero on an empty list, and no tests for any of it.
Claude Code (claude -p --model sonnet)
Review the changes on this branch before I merge them.
Called the code-review skill (the project skill was used over Claude Code's built-in skill of the same name) and reported seven findings: the shell injection, the unvalidated code, the one- and three-digit parsing, a log line on every call, the average([]) crash, the missing tests, and average() as scope creep. Each was verified: five by reproduction (the injection created a file in a temporary folder), the missing tests and the scope finding by reading the code and its history. Verdict: fix before merge, with the CI and Not checked lines.
Codex (0.163.0, codex exec)
Review the changes on this branch before I merge them.
Read the skill and followed its format with three verified findings (injection, parsing, tests). It missed average() and left out the CI line; after this run the skill was changed to make the CI line mandatory, and Codex was not run again. The start of its report (links shown as plain text):
Reviewed: `feat/discount` vs `master`, 1 commit, 1 changed file. Verdict: **fix before merge** 1. [security] cart.py:9: Discount codes can execute arbitrary shell commands. Why: `SAVE10; echo injected > marker; #10` passes percentage parsing and executes the injected command. Fix: Replace `os.system` with Python file I/O or logging. Verified: Reproduced in a temporary directory; the injected command created a marker file.
Agents it was tested on
- Claude Code: tested on 2026-11-29 with
claude -p --model sonnet, the skill installed as a project skill in.claude/skills/. - Codex: tested on 2026-11-29 with Codex 0.163.0 (
codex exec), the skill in.agents/skills/. - OpenCode and Cursor: not tested. The skill is plain instructions in the open Agent Skills format, but no run on either has checked it.
Limits
- Claude Code has a built-in
/code-reviewof the same name. In the test the project skill was used; which one wins under the plugin install was not tested. - Codex reported 3 findings against 7 for Claude Code in one run each; it missed the
average()crash and the scope finding. - A very large diff is reviewed riskiest files first, and the rest are listed under Not checked.
- The CI line through Caprock's
ci_statuswas not exercised: the test repository had no remote.
With Caprock, and without it
When the Caprock MCP server is connected, the skill calls ci_status for the newest workflow runs and the open pull request's checks, with failing jobs named. Without it, it uses gh pr checks if the GitHub CLI is signed in, or writes "CI: not available". Caprock is the free, open-source app that records every coding-agent session on your computer.
The full SKILL.md
The file as it is in dspv/skills at revision dfce799. To install it by hand, save it as .claude/skills/code-review/SKILL.md for Claude Code or .agents/skills/code-review/SKILL.md for Codex, in your project.
--- 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 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: - 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 config, config over docs), and list the files you did not review under `Not checked`.
Questions about the code-review skill
- Is there a Claude Code review skill that works in other agents?
- code-review is one: a plain SKILL.md that Claude Code, Codex, OpenCode and Cursor can read. It was tested on Claude Code and Codex 0.163.0 on 2026-11-29.
- How is this code review skill different from Claude Code's built-in review?
- It works the same in any agent, reports in one fixed format, and proves each finding from the code before reporting it. Claude Code's built-in /code-review command shares the name. Installed as a project skill, this one was used in the test; from the plugin, call it as `/caprock-skills:code-review` (that form was not run).
- Does the code-review skill change my code?
- No. It stops after the report. It applies fixes only when you ask, then re-runs the tests it ran.
- Does it comment on style?
- Not unless you ask or a project rule requires it. Style, naming and formatting are skipped by default.