Subagents¶
Overview¶
Subagents are child agents with their own context windows. They work on their own and return only the final results, so your main context stays clean.
Each subagent gets its own context window and can generally be run in parallel. They're separate execution contexts, not modes or profiles you switch between.
Benefits¶
Subagents help you manage context.
Offload exploratory work to keep your primary context clean. You can also run independent tasks in parallel, or chain subagents together when a workflow has multiple steps that each need focused context.
Common Subagent Patterns¶
Explore¶
Looking for files or patterns? Read, Glob, Grep, WebFetch. Read-only, so it can search freely without risk.
Plan¶
Uses Read, Glob, Grep to gather context before you write code. Good for figuring out how to approach a feature.
Build¶
Give it detailed specs and it writes files. Has Write, Read, Edit, Bash. Spawn several to write components in parallel.
Research¶
For deep dives. Read, Glob, Grep, WebFetch. Use when you need to understand unfamiliar code or review documentation.
Runtime Support¶
| Runtime | Subagent Support | Documentation |
|---|---|---|
| Claude Code | ✓ | docs |
| Opencode | ✓ | docs |
| Cursor | ✓ | docs |
| Cline | ✗ | — |
| Copilot | ✗ | — |
See the feature support table for more details.
Tips¶
Spawn exploration agents early to gather context before you start building.
Avoid nesting subagents (most runtimes prevent this anyway). Have subagents summarize findings rather than dump raw data; for complex workflows, they can write intermediate results to files for other agents to pick up.