What is a subagent?
A subagent is a helper AI agent that a main agent hands a task to. The subagent starts with its own fresh context window, does the work and sends back a short result. It’s a lot like a manager asking someone on the team to go research something and report back with just the answer.
There are a few big reasons to use them. The main agent’s context stays clean because all the file reads, search results and logs the subagent churns through never land in the main conversation. Each subagent can also get its own instructions and its own set of tools, so a code reviewer can be read-only while another subagent is allowed to edit files. Subagents can run in parallel too, which makes it possible to split a big job into independent pieces and finish faster.
Claude Code has subagents built in. The main agent starts one with its Agent tool, which used to be called the Task tool. You can define your own custom subagents as Markdown files in a project’s .claude/agents/ folder. Each file has a name, a description that tells Claude when to use it, an optional list of allowed tools and a body that becomes that subagent’s system prompt.
There are tradeoffs worth knowing about. The main agent only sees the subagent’s summary, so any detail the subagent leaves out is gone. Every subagent also makes its own model calls, which means running several of them uses a lot more tokens and eats into your usage limits faster.
I very actively use subagents because I often want to have a single skill’s worth of instructions in the context while the agent is running. The agent follows your prompt much better when your prompt dominates the context. Parallelism is the other practical reason I need subagents. My pr-review skill does at least six independent checks, so it would be impractical not to parallelize them with subagents.