What are subagents?
You're ten minutes into a Claude Code session, exploring an unfamiliar payments codebase, and you ask a simple question: which service handles refunds? Claude reads fifteen files, runs a handful of searches, traces a few function calls, and eventually answers. The answer is correct. The problem is that every file it touched is now sitting in your main context window — and you only needed one fact.
That's the moment subagents start to matter.
The isolated context window
A subagent is a specialized assistant that Claude Code can delegate a task to, running in its own isolated context window. It does its work, returns a focused summary to the main thread, and then the entire subagent conversation is discarded.
Every tool call, every file read, every search result in a normal Claude Code session gets written to the main context. That space is finite. Once it fills up, Claude starts losing track of earlier parts of the conversation. Subagents solve that by doing the noisy intermediate work somewhere else.
Two inputs, one summary
A subagent receives exactly two things when it's launched:
- A custom system prompt from its configuration file — this defines the subagent's role, how it should behave, and how it should report findings back.
- A task description written by the parent agent based on what you asked for.
From there, the subagent works autonomously. It reads files, runs searches, edits code, calls tools — whatever the job requires. None of that appears in your main conversation. When it's done, only a summary comes back. The full subagent transcript is thrown away.
Before: you ask "which service handles refunds?" — Claude reads 15 files in your main context, and now your window is cluttered with source you'll never look at again.
After: you ask the same question — the Explore subagent reads those 15 files in its own context, and your main thread only records the question and a one-line answer.
You get the result without the journey. The tradeoff is real, and worth stating plainly: you lose visibility into how the subagent reached its conclusion. If the reasoning matters, keep the work in your main thread. If only the answer matters, delegate.
The built-in subagents
Claude Code ships with three subagents you can use immediately, without any configuration:
- General Purpose — for multi-step tasks that need both exploration and action.
- Explore — for fast searching and navigation of codebases.
- Plan — used during plan mode for research and analysis before presenting a plan.
These cover most of what you need day-to-day. Ask a codebase question — Claude picks one, runs it, hands you the answer.
Beyond the built-ins
You can also create your own subagents with custom system prompts and tool access. A code reviewer that only reads and runs git diff. A test writer that only touches a specific directory. A documentation generator with a strict output format. Each one tailored to a slice of your workflow — and each one keeping its intermediate work out of your main context.
That's the next lesson: how to actually build one.
Why any of this matters
Subagents give you three things that compound over a long session:
- Focused work. Each subagent concentrates on a specific task, with a system prompt written for that task and nothing else.
- A clean main context. All the intermediate reads, searches, and tool calls stay isolated in the subagent.
- Just the information you need. You get a concise summary back, not a play-by-play of how it was produced.
The less noise in your main context, the longer and more effectively you can work in a single session. Subagents aren't a trick for short tasks — they're how you stay productive on the long ones.
Key Takeaways
- 1A subagent runs in its own isolated context window, does focused work, and returns only a summary to the main thread — the rest of the conversation is discarded.
- 2Every tool call and file read in the main thread consumes context; subagents keep that space clean by isolating intermediate work somewhere else.
- 3Every subagent receives two inputs: a custom system prompt from its config file, and a task description written by the parent agent.
- 4Claude Code ships with three built-in subagents — General Purpose, Explore, and Plan — and you can create your own with custom prompts and scoped tool access.
- 5The core tradeoff is visibility: subagents keep your main context clean, but you lose the ability to see how they reached their answer — so delegate only when the journey doesn't matter.