What Are Subagents and Why They Change Everything
- Understand what a subagent is and how it differs from a forked conversation or a separate Claude Code session
- Identify the three built-in subagent types and the specific role each one plays
- Recognize when delegating to a subagent produces better results than continuing to prompt in the main conversation
The Problem with One Context Window
Every Claude Code session has a context window — a fixed amount of space for the entire conversation. As you work through a complex project, that window fills up: your prompts, Claude's responses, file contents, tool outputs. Eventually the oldest content gets compressed or dropped.
This creates a real constraint. When you ask Claude to do ten things at once, it works through them sequentially in a single context, carrying the weight of everything it has seen. Tasks that are logically independent get tangled together. A mistake in step three can color everything that follows.
Subagents solve this by giving each delegated task its own isolated context window.
What a Subagent Actually Is
A subagent is a specialized AI assistant that runs inside your current Claude Code session with its own isolated context window, its own system prompt, its own set of tools, and its own permission settings. The parent conversation delegates a task to the subagent and waits for a summary. All the intermediate work — the tool calls, the reasoning, the back-and-forth — happens inside the subagent's context and never clutters the parent's.
Three things make subagents distinct from other ways of splitting work:
- Isolation. The subagent starts fresh. It receives only the delegation message Claude writes for it, plus any CLAUDE.md and memory files for context. It does not inherit your conversation history.
- Focus. The subagent's system prompt and tool access can be scoped to exactly what the task needs — a read-only research agent, a test-runner with shell access, a writer with no filesystem permissions.
- Summarization. The parent receives only the subagent's final summary. Verbose intermediate output stays in the subagent's context, keeping the parent's context clean.
Subagent vs. Fork vs. Separate Session
Three mechanisms let you split work in Claude Code. They are not interchangeable.
A subagent runs within your current session. It starts with its own fresh context (just the delegation message and project context files). The parent delegates a task and receives a summary. Everything else stays inside the subagent.
A fork is a special kind of subagent that inherits the entire parent conversation — system prompt, tools, model, and every message up to the fork point. Use a fork when the subagent genuinely needs full conversation history. Use a regular subagent when the task is self-contained.
A separate session (background agent or Routine) is a fully independent Claude Code instance that runs in its own process, potentially on Anthropic's infrastructure, potentially while your computer is off. Sessions do not communicate back in real time the way subagents do.
For most parallel work within a project, subagents are the right tool.
The Three Built-In Subagent Types
Claude Code ships with three subagent types that are available in every session without any configuration:
- Explore. A read-only search agent. It skips CLAUDE.md and git status for speed. Use it for codebase questions, file lookups, and symbol searches. You can specify thoroughness: quick, medium, or very thorough.
- Plan. A research agent used during plan mode. Also read-only, also skips CLAUDE.md and git status. Claude invokes it automatically when you enter plan mode.
- general-purpose. A full-capability agent with all tools and both CLAUDE.md and git status. Use it for tasks that involve reading and writing.
These are starting points. The rest of this track is about creating agents tailored to your exact needs.
When to Delegate vs. When to Stay in One Session
Subagents add a small coordination overhead: Claude has to write the delegation message, spawn the agent, and synthesize its summary. For tiny tasks, that overhead outweighs the benefit.
Delegation pays off when:
- The task is self-contained with a clear deliverable (a function, a report, a test file)
- The task is parallel — it does not depend on the result of another in-progress task
- The task would consume large amounts of context (long file reads, many tool calls)
- You want different tool access or permission settings than the main session has
Stay in one session when:
- Tasks depend on each other's intermediate results
- You need to iterate tightly with Claude turn-by-turn
- The task is small enough that starting a subagent costs more than it saves
Note: the Agent tool was renamed from Task to Agent in Claude Code v2.1.63. If you see references to the Task tool in older tutorials, they are the same thing.
- A subagent is an isolated AI worker with its own context window, system prompt, tools, and permissions — the parent receives only the final summary
- Three built-in types ship with every session: Explore (read-only, fast), Plan (read-only, for plan mode), and general-purpose (full tools)
- Subagents start fresh with just the delegation message and project context files — they do not inherit your conversation history
- A fork is a subagent that inherits the full parent conversation — use it when full history is needed, not as the default
- Delegate when a task is self-contained, parallel, or context-heavy; stay in one session when tasks depend tightly on each other's intermediate results