Day 18 of 52 · about 20 min · Subagents
Create your first subagent
When Claude reviews code it just wrote, its own reasoning is still in the room. A subagent starts clean, with only the tools you give it: a second look from someone who didn’t write the code.
You’ll finish with
- A
diff-reviewersubagent in.claude/agents/with no edit tools - A review of your uncommitted changes from a fresh context
You’ll need
- Claude Code installed and logged in (Day 1)
- A git repository: the practice project kit for this day, or your own project
Before you start
Tell us about your setup and the steps change to fit it. Your answers stay in this browser, and you can change them at any time.
Which system are you on?
Commands differ between systems. Pick the one you’ll run Claude Code on.
The steps
One step at a time. When a step’s check matches, tick it and the next one opens.
Step 1 of 4: Add the subagent file
Save one Markdown file in the folder Claude Code scans for project subagents.The practice kit already has this file. In your own project, save it at the same path. You can also ask Claude to write a subagent for you;
/agentsnow only points you to these folders..claude/agents/diff-reviewer.mdMarkdown--- name: diff-reviewer description: Reviews uncommitted changes for bugs, missing tests and work outside the task. Use after code changes, before the work counts as done. Never edits files. tools: Read, Grep, Glob, Bash, PowerShell model: inherit --- You review the uncommitted changes in this repository with fresh eyes. You did not write them and you have not seen the conversation that produced them. 1. Run `git diff` and `git diff --staged` to see what changed. If both are empty, say so and stop. 2. Read each changed file and the tests that cover it. 3. If CLAUDE.md or package.json names a test command, run it once. Report only problems that affect correctness or the task you were given: - Bugs: wrong results, inputs that are not handled, broken edge cases. - Behaviour the change adds or alters without a test. - Changes outside what the task needed. For each finding, give the file and line, what is wrong and a suggested fix. Leave style preferences out. You have no Edit or Write tool. Do not change files with shell commands either: you report, and the main conversation decides what to fix. If nothing matters, reply "No blocking issues" and list what you checked.your-project/
- folder .claude
- folder agents
- diff-reviewer.mdNewshared with anyone who clones the repo
- folder src
Project subagents live in .claude/agents/. Personal ones go in ~/.claude/agents/. Check it worked
The file starts with
---on its first line. If theagentsfolder is new, restart Claude Code: a running session only watches folders that existed when it started.Step 2 of 4: Check what it can do
Read the frontmatter: the description decides when Claude uses it, the tools decide what it can touch..claude/agents/diff-reviewer.md- name: diff-reviewer
- How you and Claude refer to it
- description: Reviews uncommitted changes…
- What Claude reads to decide when to delegate
- tools: Read, Grep, Glob, Bash, PowerShell
- An allowlist with no Edit or Write. Both shells, so it can run
git diffon any system - model: inherit
- Same model as your session
Only name and description are required. Note: A shell can still change files, so the prompt tells it not to. Shell commands still go through your permission rules.
Check it worked
In Claude Code, type
@:diff-revieweris listed as an agent in the typeahead.If it didn’t work
It is not in the list
A file with no
nameis read as documentation. For a missingdescriptionor broken YAML,claude --debugshows why it was skipped.Step 3 of 4: Give it something to review
Have Claude make one small change and leave it uncommitted.In Claude CodeYou type: Add a --rush option to the quote command that adds 25% to the subtotal before the discount. Don’t commit.
What happens: In your own project, ask for any small change you would want reviewed.
The session that writes the change is the one with the bias. Check it worked
git statuslists at least one modified file.Step 4 of 4: Hand the review to it
Ask for the subagent by name, or @-mention it to make sure it runs.In Claude CodeYou type: Use the diff-reviewer subagent to review my uncommitted changes
What happens: A
diff-reviewer(…)row appears while it works, then Claude passes on its report.Naming it usually works. An @-mention guarantees it. Check it worked
A report with file and line for each finding, or "No blocking issues" and what it checked. Ask Claude to fix what matters; the reviewer itself edits nothing.
Finish · 4 of 4 steps to go
You have a reviewer that never saw the code being written
.claude/agents/diff-reviewer.md so everyone on the project gets it. Tomorrow you use it with other subagents.What you’ll have checked
@listsdiff-reviewer- Its report names files and lines, and no file changed while it ran
Lesson updates by email
Get lesson updates by email
Leave your email and we’ll tell you when we add or update a lesson.
Claude Code for your team
Want Claude Code set up across your team?
HorizonLux sets up and repairs Claude Code for teams: CLAUDE.md rules, hooks that enforce them and reviewed MCP servers. Book a free call to talk it through.
Related
Questions
Questions about Day 18
Why not just ask Claude to review its own change?
It can, but the reasoning that produced the change is still in its context. The subagent starts fresh, without that conversation.
Sources
Checked against the official Claude Code docs on .
Independent resource, not affiliated with Anthropic. HorizonLux wrote this lesson; Claude Code is made by Anthropic.