Using Claude Code to review code: /code-review, yours and its own
How to review code with Claude Code: /code-review targets and flags, a fresh-context reviewer subagent, ultrareview, and a checklist for AI-written diffs.
Run /code-review in a Claude Code session and it reviews the changes on your branch for correctness bugs, then reports what it found in the conversation. Point it at a pull request number, a branch, a path or a commit range, and add --fix to have Claude apply the findings. The command works on any plan and counts toward your usage like the rest of the session. This page covers the command, how to review Claude's own work without fooling yourself, and the other review tools in the box.
#How do you run /code-review?
/code-review
With no target it reviews your branch's commits ahead of its upstream plus your uncommitted changes. If the branch has no upstream, it compares against main, or the previous commit. /review is an alias.
In a terminal session the review runs as a background subagent with its own context window, so it does not fill your conversation, and the findings arrive when it finishes. In a -p (headless) run it waits and prints the findings.
#What can you point it at?
Type a target after the command:
| To review | Type |
|---|---|
| Current branch and uncommitted changes | /code-review |
| Your last 15 commits | /code-review HEAD~15..HEAD |
| One branch against another | /code-review main...my-feature |
| A single commit | /code-review abc1234^..abc1234 |
| A pull request | /code-review 1234 |
| A file or directory | /code-review src/auth |
Two flags change what happens next. --fix also asks Claude to apply the findings to your working tree afterward; its edits still go through your permission mode. --comment posts the findings on a GitHub pull request as inline comments (on a GitLab merge request it uses glab and posts a single note). Both need gh or glab set up as for any PR work; see commit, push and open a PR.
#How much effort should a review use?
Put an effort level first: low, medium, high, xhigh or max, as in /code-review high src/auth. At low the review reports only the findings it is most confident about, so you get fewer false positives. From medium up it broadens coverage and may also flag reuse, simplification and efficiency cleanups. If you do not type a level, it reuses the last one you typed, even from an earlier session, and says so. --max-findings <n> (or all) raises the cap on how many findings are reported.
A reasonable routine: low on every branch before you push, high on risky or large changes.
#How do you review Claude's own code without grading your own homework?
A model that wrote the code carries its assumptions into the review. Three ways to break that:
Review from a clean context. /code-review already runs as a separate subagent with its own context window. If you want a reviewer with your standards baked in, write a subagent in .claude/agents/reviewer.md:
---
name: reviewer
description: Reviews a diff for bugs, missing tests and security problems. Use after code changes.
tools: Read, Grep, Glob, Bash
---
You review code you did not write. Run `git diff main...HEAD`. For each
problem report: file and line, what breaks, and a concrete fix. Check that
new behavior has tests and that tests assert something. Do not edit files.
Skip style nits the linter already catches.
Put your rules in CLAUDE.md. The review follows your CLAUDE.md, including in -p runs. It does not read a REVIEW.md; that file is for a different, managed GitHub review service. Rules like "all SQL goes through the query builder" or "never log request bodies" become review criteria for free. See writing a CLAUDE.md.
Run something that is not a model. Tests, type checks and a linter disagree with Claude for reasons Claude cannot talk away. /verify goes further and builds and runs your app to confirm a change does what it should.
#What else is there besides /code-review?
/security-reviewanalyzes your branch against origin's default branch for injection, auth problems and data exposure. It needs anoriginremote./simplifyreviews changed code for reuse, simplification and efficiency, then applies the fixes. It does not hunt for bugs./diffshows your working tree, including Claude's edits so far. Often the best review is reading it yourself.- Ultrareview is a deeper, multi-agent review that runs in the cloud.
/code-review ultrastarts it from a session, andclaude ultrareviewruns it from a script or CI and prints the findings. It needs a claude.ai login and is not available on every provider or organization setup; read the ultrareview page for limits and cost on your plan. - Managed Code Review on GitHub reviews every pull request automatically once an organization Owner turns it on. That is a service, separate from the local command.
#A checklist for reviewing AI-written diffs
Whoever reviews, check these, because they are where assistant-written changes tend to go wrong:
- Did the tests change? Read test diffs first. A loosened assertion or a deleted test is a bigger signal than any source line.
- Is there new behavior without a test?
- Did it add a dependency, a config flag or a feature you did not ask for?
- Are error paths handled, or only the happy path?
- Did it touch files outside the task's scope?
- Is anything duplicated that already exists elsewhere in the repo?
- Do secrets,
.envfiles or debug logging appear in the diff?
Then run the suite yourself. Ask Claude to explain any hunk you do not understand; if its explanation does not convince you, the code is not ready.
#How does review fit into the rest of the flow?
A loop that works: build in a worktree or branch, run /code-review low, fix or --fix, read the diff yourself, commit, push, open the PR, and let your human reviewers (or the managed service) take it from there. For code written test-first, the tests are the first reviewer; see test-driven development with Claude Code. If Claude's --fix edits go wrong, undoing them is easier when you committed first, and note that a background review's fixes fall outside /rewind.
#In Relais
Relais is a layer over Claude Code, and its composer's / menu lists Claude Code's commands and skills, so look for /code-review there. What Relais adds is the reading side. The Changes tab lists what each repository of the project has uncommitted, with a dot on what the current session changed, and a diff opens when you click a file. Edits Claude proposes come with their diff in the conversation before you approve them. See features.