You ask Claude Code to build a feature. It writes the code, runs the tests, and says it's done.
Then you type the obvious follow-up: "Now review what you just wrote."
It reviews it in the same conversation, with the same context, holding the same assumptions that produced the code. If it misunderstood the requirement an hour ago, it will misunderstand it again now. A review by the author, in the author's head, is a re-read.
Human teams solved this a long time ago: the reviewer is someone else. Claude Code lets you do the same thing with a subagent.
What you'll build: a code-reviewer subagent that runs in its own context window, can read and search your code, and cannot edit files or run commands.
Code: the file is in the ops-ai repo, inside a starter .claude/ folder you can copy whole.
A subagent is a helper Claude Code can hand work to. Two properties make it a good reviewer.
Save this as .claude/agents/code-reviewer.md in your repo:
---
name: code-reviewer
description: "Reviews changed files for bugs, missing tests and security issues. Use after finishing a feature or before a commit. Pass it the list of changed files."
tools: Read, Grep, Glob
model: sonnet
---
You are a careful senior reviewer seeing this code for the first time.
You were given a list of changed files. Read each one, and any file it
depends on that you need to understand it.
Report, in order of severity:
1. Bugs or logic errors
2. Missing or weak tests
3. Security issues (secrets, injection, unchecked input)
For each finding: file, line, what's wrong, and the fix in one or two lines.
Skip style nitpicks. If you find nothing serious, say so plainly.
You can read and search but not edit or run commands. Report; don't fix.
description is how Claude Code decides when to use the subagent, so it's written as a trigger: what it does, then when to use it. It also tells the main conversation what to hand over: the list of changed files.
tools: Read, Grep, Glob is the important line. Without it, a subagent inherits every tool the main session has, including Edit, Write and Bash. With it, the reviewer can open files and search the codebase, and that's all. It can't edit anything, and it can't run commands.
That last part has a consequence worth knowing. The reviewer can't run git diff itself, because that needs Bash. That's deliberate. Letting it have Bash "just for git diff" isn't something the tools field can express: as far as Anthropic's docs describe it, the field takes tool names, not command patterns. Give it Bash and it gets all of Bash. So the main conversation, which can run git, does that part and passes the result along.
model: sonnet picks the model for the review. You can also set opus, haiku, a full model ID, or inherit to match the main session.
The prompt body is the reviewer's whole job description. "Seeing this code for the first time" isn't decoration. It sets the stance you want: no benefit of the doubt.
Ask in plain words:
Run git diff --name-only, then use the code-reviewer subagent
to review those files.
Or mention it directly with @agent-code-reviewer. Claude Code runs git diff in the main session, hands the file list to the reviewer, and the reviewer works in its own context. What comes back is a short, ranked list of findings. Then you decide, in the main conversation, which ones to fix.
Two habits make it more useful. First, review before you commit, not after you push. It's cheapest when the change is still fresh and small. Second, tell it what the change was for. "Review these files; the goal was to add refund support without changing the invoice totals" gives the reviewer a requirement to check against, not just code to read.
The interesting thing about this subagent isn't what it's told to do. It's what it's not able to do.
Most of the ways people try to make AI behave are instructions: "be careful", "don't change anything", "only report". Instructions are requests. The tools line isn't a request. It's the set of things that physically exist for the reviewer, and Edit isn't in it.
So here's the question for your own setup: for each helper you've given your coding agent, which rules are written in its prompt, and which ones are written in what it can actually do?
The reviewer, plus a CLAUDE.md template, hooks and a permissions file, is in the starter folder of the ops-ai repo. Copy the .claude/ folder into your project and edit from there.
Originally published on Level Up Coding.