Subagents are specialised AI assistants that handle specific types of tasks. Each subagent runs in its own context window with a custom system prompt, specific tool access and independent permissions. A reviewer subagent is the classic first custom one: it reads a change, checks it against the project rules, and reports back.
Before you start
You need Claude Code running in a project with version control. Decide the reviewer job first: one sentence, for example review the current change for bugs and style, and report findings as a short list.
Create the subagent file with a name and a description
Make a .claude/agents folder in the project and create a reviewer.md file there. A subagent is a Markdown file with YAML frontmatter on top and a system prompt below. Only name and description are required in the frontmatter. Write the description for the router: Claude uses each subagent description to decide when to delegate tasks, so name the exact work, such as reviewing code changes for bugs.
Write the system prompt and test with a real change
Below the frontmatter, write the system prompt: what to check, what to ignore, and the output shape, for example a list of findings with file names and line numbers. Then ask Claude to review a real change and check the reviewer subagent is the one that runs. If the main agent answers directly, the description is too vague about when to delegate.
Worked example: Reviewer subagent for a fictional shop project
Maple Shop is a fictional online shop. Its reviewer subagent checks pull requests. The table shows the file.
| Part | Content |
|---|---|
| name | reviewer |
| description | Reviews code changes for bugs and style |
| System prompt | List each finding with file, line and a one-line fix |
Expected result (UNTESTED): asking Claude to review a change runs the reviewer subagent, and the reply is a short list of findings with file names. We checked the Claude Code subagents documentation, which describes the file location, the required frontmatter and the description routing, but we did not create the subagent on this machine.
Limits
A reviewer subagent only reads what the main agent gives it, and its findings are suggestions, not tests. Run the test suite as well: a review cannot catch a bug the tests would. Keep the description short, because the router only reads that field.
