What you will be able to do
- Explain why long discovery phases can use up the main conversation's context window
- Tell the built-in Explore subagent apart from the Plan subagent and plan mode
- Use subagent delegation and plan persistence to keep a multi-phase task within its context budget
1.Why discovery strains the main conversation
Big tasks start with a lot of reading: finding every file that uses a library, tracing a request across services, mapping out a module. All that reading is expensive. The context-window guide says that as Claude works, "each file read adds to context". In a multi-phase task (investigate, plan, implement, verify), the files read during discovery stay in the conversation and keep taking up room in every later phase. When implementation starts, the context may be full of file contents that only mattered while you were searching.
The cost is more than lost space. The costs guide explains that Claude Code sends your full conversation with every request, so file contents left in context are carried along on every later turn. Context behaves like a budget that you spend down, and discovery is usually where the largest share gets spent.
The docs give two remedies. The first is between tasks: "Clear between tasks: run /clear when switching to unrelated work." That doesn't help within one task, because you still need the findings. The second is the one this page covers: "Delegate large reads: send research to a subagent so the file contents stay in its context window, not yours."
Checkpoint 1 of 4· Check yourself
Partway through a large migration, the main conversation is crowded with raw file contents from the discovery phase, and you still need the findings to implement. Which remedy fits?
/clear is meant for switching to unrelated work, and it would throw away the findings too. Delegating keeps the bulky reads in the subagent's own window.
“Delegate large reads: send research to a subagent so the file contents stay in its context window, not yours.”Source: code.claude.com
2.The built-in Explore subagent
A subagent runs in its own conversation. The SDK docs explain that its intermediate tool calls and results stay inside it, and "only its final message returns to the parent." They add: "A research-assistant subagent can explore dozens of files without any of that content accumulating in the main conversation." The context-window guide describes the same thing: "Only the summary and a small metadata trailer come back."
Claude Code ships with built-in subagents. Explore is the one made for discovery. Its tools are read-only ("Write and Edit are denied"), and its purpose is "file discovery, code search, codebase exploration". It also has a cost safeguard: its model is capped at Opus on the Claude API, "so Explore never runs on a more expensive model than the one you already chose for the session". Don't mix up Explore with two similar names. The built-in Plan subagent is also read-only, but it's meant for "codebase research for planning". Plan mode isn't an agent at all: it's a permission mode for your main session. You can ask for delegation directly, as in the docs' example prompt: "use a subagent to investigate how our auth system handles token refresh".
Because Explore can't write or edit, handing it discovery is also a safe choice: it can look at everything but change nothing. And since only its final message returns, the summary is all the main conversation will ever see of that work. It helps to say in your prompt exactly what you need back, such as the relevant file paths or the places a library is called.
Checkpoint 2 of 4· Match them up
Match each one to what it is
Tap a term, then the definition that fits it.
Explore and Plan are both read-only built-in subagents with different purposes. General-purpose can modify code. Plan mode is a session setting, not an agent.
“Purpose: file discovery, code search, codebase exploration”Source: code.claude.com
3.Holding a multi-phase task together
Put the pieces together for a long task, such as a library migration. During discovery, the bulky searching goes to a subagent. The main conversation gets summaries, so it keeps room for the decisions. The common-workflows guide lists this as a standard pattern: "Delegate research to subagents to keep your main context clean". The plan built from those summaries is reviewed in plan mode, and then implementation runs in an editing mode.
The best-practices guide lays out the same shape as four steps: explore, plan, implement, commit. Each step builds on the one before. The implementation prompt even points back at the earlier work: "implement the OAuth flow from your plan." The reading happens first and the plan comes second, so by the time files are being edited, the main conversation holds decisions rather than raw search output.
If the session still grows large enough that you run /compact, the plan isn't lost. The context-window guide's compaction table lists what survives, and the plan is on it: "The plan Claude wrote in plan mode | Re-injected from disk". Files Claude read are handled differently. Claude Code re-reads only up to five of them, most recently modified first. So the approved plan carries over into implementation, while the raw discovery output, which should have stayed in a subagent anyway, doesn't come back in full.
This delegation is on by default but can be switched off. Setting CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTS=1 removes the built-in Explore and Plan subagents. Then "Claude reads and explores files directly instead of delegating to them", and all that reading lands back in the main context.
Checkpoint 3 of 4· Exam question
An architect is migrating a project from one ORM library to another across 60 files, where call sites use inconsistent query patterns and the correct replacement idiom differs by pattern. The architect wants Claude to first survey how the old library is used before writing any replacement code. What is the most effective way to structure this work?
Correct answer: A — Use plan mode to survey the inconsistent call site patterns and draft a migration approach, then exit plan mode and execute the approved plan directly
- A. Correct. Plan mode fits the investigation phase across many files with varying patterns, and once the migration approach is approved, switching to direct execution carries it out efficiently, matching the combined plan-then-execute pattern for library migrations.
- B. Starting in acceptEdits lets edits happen before the varying call-site patterns across 60 files are fully understood, risking inconsistent replacements that need rework.
- C. Skipping the survey step for a migration with inconsistent patterns across many files is likely to produce mismatched replacements that require costly correction later.
- D. Assuming one idiom applies everywhere ignores the stated inconsistency in call site patterns and will misapply the wrong replacement to many files.
Checkpoint 4 of 4· Check yourself
After a long investigation you run /compact before implementing. What happens to the plan Claude wrote in plan mode?
The compaction table lists the plan mode plan among the items reloaded from disk. That's why it survives into the implementation phase.
“The plan Claude wrote in plan mode | Re-injected from disk”Source: code.claude.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Plan mode, the Plan subagent and the Explore subagent are the same thing under different names.Why is that wrong?
Plan mode is a permission mode for your session. Explore and Plan are separate read-only subagents: one for discovery and search, the other for research that feeds a plan.
Covered in The built-in Explore subagent
2.Running /clear is the way to free context in the middle of a multi-phase task.Why is that wrong?
/clear is for switching to unrelated work. Within one task, delegating large reads to a subagent keeps the findings and leaves the file contents out of your context.
Covered in Why discovery strains the main conversation
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://code.claude.com/docs/en/context-windowOfficial docs
“each file read adds to context”
↩︎ Why discovery strains the main conversation“Only the summary and a small metadata trailer come back.”
↩︎ The built-in Explore subagent“Clear between tasks: run /clear when switching to unrelated work.”
↩︎ Exam trap 2“Delegate large reads: send research to a subagent so the file contents stay in its context window, not yours.”
↩︎ Checkpoint“The plan Claude wrote in plan mode | Re-injected from disk”
↩︎ Checkpoint - 2.https://code.claude.com/docs/en/costsOfficial docs
“Claude Code sends your full conversation with every request”
↩︎ Why discovery strains the main conversation - 3.https://code.claude.com/docs/en/agent-sdk/subagentsOfficial docs
“A research-assistant subagent can explore dozens of files without any of that content accumulating in the main conversation.”
↩︎ The built-in Explore subagent“The parent receives a concise summary, not every file the subagent read.”
↩︎ Prediction - 4.https://code.claude.com/docs/en/sub-agentsOfficial docs
“Tools: read-only tools; Write and Edit are denied”
↩︎ The built-in Explore subagent“Claude reads and explores files directly instead of delegating to them.”
↩︎ Holding a multi-phase task together“Purpose: codebase research for planning”
↩︎ Exam trap 1“Purpose: file discovery, code search, codebase exploration”
↩︎ Checkpoint - 5.https://code.claude.com/docs/en/common-workflowsOfficial docs
“Delegate research to subagents to keep your main context clean”
↩︎ Holding a multi-phase task together - 6.https://code.claude.com/docs/en/best-practicesOfficial docs
“implement the OAuth flow from your plan.”
↩︎ Holding a multi-phase task together