How to Use Sub-agents
Summary — Key Takeaways from This Lesson
- Sub-agents are a pattern where a parent agent (orchestrator) delegates specific subtasks to specialized child agents.
- Separating specialization keeps each agent's context simple, improving accuracy and reusability.
- Tasks that can run in parallel can be processed simultaneously with Sub-agents, dramatically reducing processing time.
- Anthropic's design philosophy allows scaling in two directions: "Many Hands" (one brain, multiple execution environments) and "Many Brains" (multiple reasoning engines).
- Claude Code's
/ultrareviewis a prime example of multi-agent parallel analysis.
目次 (8)
What Are Sub-agents?
When a single agent tries to handle all of a large task, the context grows bloated, accuracy drops, and errors become more likely. The design pattern that solves this is Sub-agents.
The parent agent (orchestrator) forms an overall plan and delegates subtasks to specialized child agents. Each child agent focuses on its own responsibilities and returns results to the parent.
Analogous to a human development team, it's like a PM assigning tasks to a frontend developer, a backend developer, and a tester, with each person bringing their deliverables together.
The Benefits of Separating Specialization
Giving each Sub-agent clear responsibilities yields the following benefits:
- Improved accuracy — the smaller the context, the more precisely the model can make judgments
- Reusability — agents can be generalized as "test generation agent," "documentation generation agent," and so on
- Independent failures — if one subtask fails, it does not affect the others
- Parallel execution — tasks without dependencies can run simultaneously to reduce overall time
Many Hands and Many Brains
The scaling design philosophy published in Anthropic's Engineering Blog describes two directions for expansion (detailed article / primary source).
- Many Hands — a pattern where one reasoning engine (brain) operates multiple execution environments (hands). Handles different environments in parallel, such as the file system, browser, and console.
- Many Brains — a pattern where multiple reasoning engines operate shared resources. Performs parallel analysis from respective perspectives, such as a code review agent, a security audit agent, and a documentation agent.
Combining these two directions enables scaling of large and complex development tasks.
Practical Examples in Claude Code
The /ultrareview Command
Claude Code's /ultrareview command is an implementation of the Many Brains pattern.
Multiple analysis agents in the cloud review the current branch or a specified PR
in parallel and return a comprehensive report
(source).
# Review the current branch
/ultrareview
# Review a specific PR by number
/ultrareview 123
Example Design for a Custom Sub-agent
Here is how to think about building your own multi-agent configuration.
- Orchestrator: Decomposes the overall task, delegates to sub-agents, and integrates results
- Coding agent: Responsible only for changes to implementation files
- Test agent: Responsible only for generating test code and verifying execution
- Documentation agent: Responsible only for code comments and README updates
The key is to pass each agent an independent instruction file similar to CLAUDE.md
to avoid mixing in unnecessary context.
Points to Note
- Neglecting the design of data handoffs between Sub-agents will complicate dependencies and increase management costs.
- Be careful of file conflicts during parallel execution (multiple agents editing the same file simultaneously).
- At this point, many cases require advanced orchestration implementation via the Claude Code SDK or API.
Detailed Article
The full picture of scalable agent design is explained in detail in "Separating Brain and Hands with Managed Agents".