Why subagents
- Clean context. Exploring a big codebase can read hundreds of files. A subagent does that in its own context and returns a short conclusion.
- Specialisation. Each subagent has its own instructions: a reviewer looks for bugs, a tester writes tests.
- Restrictions. Give a subagent read-only tools and it physically can’t change code.
- Parallelism. Several subagents can explore different parts of the project at once.
How to create one
The /agents command opens the subagent manager. Or create a file by hand:
.claude/agents/code-reviewer.md --- name: code-reviewer description: Reviews changes after implementation. Use after finishing a feature or before committing. tools: Read, Grep, Glob, Bash --- You are a reviewer. Look at git diff. Look for: bugs, unhandled errors, missing tests, leaked secrets. Return a list of issues with file and line. Don't change code.
How to call it
- The agent decides on its own when to delegate if a subagent’s description matches the task.
- Or ask directly: "have code-reviewer review the changes".
Useful subagents
| Subagent | Task | Tools |
|---|---|---|
| Explorer | find where and how something is implemented | read and search only |
| Reviewer | check the diff before a commit | read, git diff |
| Tester | write and run tests | read, edit tests, bash |
| Doc writer | update README and comments | read, edit |
When you don’t need a subagent
- The task is small and the context is clean anyway.
- You need close step-by-step interaction: a subagent works autonomously and returns a result.
- The subagent’s result would need lengthy explanation to the main session, cancelling the benefit.
Ready-made subagents are in the article "Claude Code Subagents".
Today's task
Create a read-only reviewer subagent with git diff. After your next task, ask it to review the changes.