{"slug": "how-to-review-claude-code-s-work-with-a-subagent-under-20-lines-copy-paste", "title": "How to Review Claude Code's Work With a Subagent (Under 20 Lines, Copy-Paste)", "summary": "A developer published a starter configuration for a Claude Code code-reviewer subagent that runs in its own context window with only Read, Grep and Glob tools, preventing it from editing files or running commands. The setup, saved as .claude/agents/code-reviewer.md and shared in a public ops-ai repo, has the main session run git diff and pass the changed-file list to the reviewer, which returns a severity-ranked list of bugs, missing tests and security issues. The author argues that a review by the same context that wrote the code is merely a re-read, and that restricting tools is what makes the reviewer useful.", "body_md": "You ask Claude Code to build a feature. It writes the code, runs the tests, and says it's done.\n\nThen you type the obvious follow-up: \"Now review what you just wrote.\"\n\nIt 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.\n\nHuman teams solved this a long time ago: the reviewer is someone else. Claude Code lets you do the same thing with a subagent.\n\n**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.\n\n**Code:** the file is in the [ops-ai repo](https://github.com/tarunagarwal1981/ops-ai/tree/main/claude-code-starter/.claude/agents), inside a starter `.claude/` folder you can copy whole.\n\nA subagent is a helper Claude Code can hand work to. Two properties make it a good reviewer.\n\nSave this as `.claude/agents/code-reviewer.md` in your repo:\n\n```\n---\nname: code-reviewer\ndescription: \"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.\"\ntools: Read, Grep, Glob\nmodel: sonnet\n---\n\nYou are a careful senior reviewer seeing this code for the first time.\nYou were given a list of changed files. Read each one, and any file it\ndepends on that you need to understand it.\n\nReport, in order of severity:\n1. Bugs or logic errors\n2. Missing or weak tests\n3. Security issues (secrets, injection, unchecked input)\n\nFor each finding: file, line, what's wrong, and the fix in one or two lines.\nSkip style nitpicks. If you find nothing serious, say so plainly.\n\nYou can read and search but not edit or run commands. Report; don't fix.\n```\n\n**`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.\n\n**`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.\n\nThat 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.\n\n**`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.\n\n**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.\n\nAsk in plain words:\n\n```\nRun git diff --name-only, then use the code-reviewer subagent\nto review those files.\n```\n\nOr 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.\n\nTwo 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.\n\nThe interesting thing about this subagent isn't what it's told to do. It's what it's *not able* to do.\n\nMost 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.\n\nSo 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?\n\nThe reviewer, plus a CLAUDE.md template, hooks and a permissions file, is in the [starter folder of the ops-ai repo](https://github.com/tarunagarwal1981/ops-ai/tree/main/claude-code-starter). Copy the `.claude/` folder into your project and edit from there.\n\n*Originally published on [Level Up Coding](https://medium.com/gitconnected/how-to-review-claude-codes-work-with-a-subagent-under-20-lines-copy-paste-59b27642e008).*", "url": "https://wpnews.pro/news/how-to-review-claude-code-s-work-with-a-subagent-under-20-lines-copy-paste", "canonical_source": "https://dev.to/tarunagarwal1981/how-to-review-claude-codes-work-with-a-subagent-under-20-lines-copy-paste-3al1", "published_at": "2026-12-01 03:40:57+00:00", "updated_at": "2026-12-01 03:44:08.208491+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": ["Claude Code", "Anthropic", "ops-ai"], "also_reported_by": [], "takeaway": "Restrict a Claude Code reviewer subagent to Read, Grep and Glob so it cannot edit or run commands, and have the main session run git diff --name-only and pass the file list, since the tools field takes tool names rather than command patterns.", "recommendation": {"advice": "Run reviews in a separate subagent with only Read, Grep and Glob tools, and pass it the changed-file list from git diff in the main session so it cannot edit or execute commands.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/how-to-review-claude-code-s-work-with-a-subagent-under-20-lines-copy-paste", "markdown": "https://wpnews.pro/news/how-to-review-claude-code-s-work-with-a-subagent-under-20-lines-copy-paste.md", "text": "https://wpnews.pro/news/how-to-review-claude-code-s-work-with-a-subagent-under-20-lines-copy-paste.txt", "jsonld": "https://wpnews.pro/news/how-to-review-claude-code-s-work-with-a-subagent-under-20-lines-copy-paste.jsonld"}}