What you’ll be able to do
- Recognize context degradation in extended sessions and choose a remedy that doesn’t rely on the conversation alone
- Delegate specific investigation questions to subagents while the main agent keeps high-level coordination
- Persist key findings in scratchpad files and carry phase summaries into the next phase’s initial context
- Design crash recovery around structured state exports and a manifest the coordinator loads on resume
- Use /compact when context fills with verbose discovery output during long exploration
What you need to know
What degradation looks like
Exploring a large codebase produces a lot of context: directory listings, grep hits, whole files read to find one function. As the session grows, the earliest and most specific discoveries get crowded out. The symptom the exam describes is distinctive: the model starts giving inconsistent answers and refers to "typical patterns" ("refunds are usually handled in a service layer") instead of the specific classes it found an hour ago (RefundOrchestrator in billing/refunds/). The model hasn't forgotten in a human sense. The specifics are buried in a long, noisy context or have been compacted away.
When you see that symptom, don't keep pushing the same session and trust its answers. Change how context is managed.
Delegate verbose discovery to subagents
The most effective structural fix is to keep the noise out of the main context to begin with. Spawn subagents to investigate specific questions, such as "find all test files that exercise the refund path" or "trace the dependencies of the refund flow." Each subagent does the verbose work (searches, reads, dead ends) in its own isolated context and returns a concise answer. The main agent keeps the high-level picture and coordinates. Claude Code's built-in Explore subagent exists for this kind of discovery work: it isolates verbose discovery output and returns a summary.
The questions should be specific. "Explore the codebase" just moves the problem into the subagent; "list every class that writes to the refunds table, with file paths" returns something the coordinator can use.
Scratchpad files: memory that survives context boundaries
Anything that exists only in the conversation is at risk from compaction, a new session, or degradation. Have agents maintain scratchpad files that record key findings as they go: the classes, file paths, call chains, and decisions that later questions depend on. For subsequent questions, the agent refers back to the scratchpad instead of relying on what it remembers from earlier in the session.
Phases, with summaries carried forward
Large explorations naturally fall into phases: map the module structure, then trace a specific flow, then assess the impact of a change. Before spawning subagents for the next phase, summarize the key findings of the current phase and inject that summary into the new subagents' initial context. Each phase starts from what's already established instead of rediscovering it, and without inheriting the previous phase's raw output.
Crash recovery with manifests
A long multi-agent exploration can be interrupted by a crash, a timeout, or a session ending. If every agent's progress lives only in its context, recovery means starting over. Design for it instead:
- Each agent exports its state (what it has completed, its findings, what remains) as a structured file in a known location.
- The coordinator maintains a manifest listing the agents, their status, and where their state lives.
- On resume, the coordinator loads the manifest and injects each agent's exported state into that agent's prompt, so work continues from where it stopped.
This is the same idea as the scratchpad, made systematic across agents: state that has to survive goes to durable, structured storage, not just to conversation history.
/compact for long exploration sessions
In Claude Code, /compact condenses the conversation so far to reduce context usage. It's the right move during an extended exploration session when context has filled with verbose discovery output, like search results and file contents that have already done their job. Compaction is lossy: it keeps the gist and can drop exact paths and line references. That's why it works best alongside a scratchpad. The specifics live in the file, and the conversation can be compacted freely.
- Verbose discovery output filling context →
/compact, with findings already in a scratchpad. - Exploration that will keep producing large output → delegate it to subagents so the main context never fills with it.
- Work that must survive interruption → structured state exports and a manifest.
Key concept
In long codebase exploration, keep verbose discovery out of the main context (subagents with specific questions), keep findings out of the conversation alone (scratchpad files, phase summaries, state manifests), and compact when discovery output has filled the window.
When a scenario shows an assistant that has started answering in generalities about code it explored in detail earlier, the answer is a context-management change, not a better prompt for the same overloaded session.
Practice scenario
Work it through, then open this
This is context degradation: specific earlier findings are buried under hours of raw file contents. Before going further, capture what has been established (classes, paths, call chains, open questions) in a scratchpad file, then use /compact to clear the verbose discovery output. For the impact analysis, spawn subagents with specific questions (“list every caller of the partial-refund calculation”) and give them the phase summary as initial context, so the main session coordinates rather than reading files itself. Continuing to ask the degraded session and trusting whichever answer sounds right is the trap.
Build exercise — Restructure a long exploration
Intermediate · 35 min
What you’ll learn
- Splitting exploration into delegated, specific questions
- Persisting findings so they outlive the conversation
- Designing a resume path with state exports and a manifest
-
Take a codebase question you’d normally explore in one long session and break it into three to five specific subagent questions, plus the coordinating question the main agent will answer from their results.
- Why: Specific questions keep verbose output in the subagents and return results the coordinator can use directly.
- You should see: Questions with concrete deliverables (“list X with file paths”), not “explore Y.”
-
Create a findings scratchpad, have each subagent’s answer recorded there, and write a phase summary from it to inject into the next phase’s subagents.
- Why: Findings in a file survive compaction and new sessions; summaries keep later phases from rediscovering them.
- You should see: A next-phase subagent citing a class from the summary without searching for it again.
-
Define the state each agent exports and a manifest format for the coordinator, then simulate an interruption and resume from the manifest.
- Why: Without exported state, recovery means starting from zero.
- You should see: Completed agents skipped on resume, and the interrupted agent continuing from its exported state.
Exam traps
Continuing a degraded session and trusting answers that cite “typical patterns” instead of specific classes
That’s the signature of context degradation. Persist findings and reduce context instead of relying on the session’s recall.
Running every grep and file read in the main session so verbose output floods the coordinator’s context
Delegate specific investigation questions to subagents so the main agent keeps only the conclusions.
Keeping key findings only in conversation history, where they are lost at the next context boundary
Record them in scratchpad files and refer to those files for later questions.
Starting a new exploration phase without injecting a summary of what the previous phase found
Summarize each phase’s findings and put the summary in the next phase’s initial context.
Restarting a crashed multi-agent run from scratch because no agent exported its state
Have each agent export structured state to a known location and have the coordinator resume from a manifest.
Letting discovery output pile up until the session is unusable instead of compacting
Use /compact when verbose discovery output fills context, with key specifics already saved in a scratchpad.
Sources
- Claude Developer Platform Docs
- Anthropic, Claude Certified Architect – Foundations Exam Guide v1.0 (July 2026)