What you will be able to do
- Recognise the signs of context degradation in a long exploration session and explain where it comes from
- Use /compact, including focused instructions, and predict what survives compaction
- Keep key findings in scratchpad files so they outlast summarisation and context resets
Key concept
Context as a finite attention budget — Every token in the context window competes for the model's attention. As exploration output piles up, recall of specific earlier details gets less precise, so you have to decide what stays in context, what gets summarised and what moves to disk.
1.Why long exploration sessions degrade
Large codebase exploration fills context faster than almost any other task. Every file read, grep result and directory listing stays in the conversation. Anthropic calls the resulting effect context rot: as the token count grows, the model gets worse at accurately recalling what is already in its context. The cause is architectural. In a transformer, every token attends to every other token, which gives n² pairwise relationships. Models also see fewer long sequences than short ones during training. The result is not a sudden failure: models "remain highly capable at longer contexts but may show reduced precision for information retrieval and long-range reasoning."
The exam describes what this looks like in practice. Late in an extended session, the agent starts giving inconsistent answers. Instead of naming the specific classes it found earlier, it falls back on "typical patterns". Those earlier findings are technically still in context, but they are buried under thousands of tokens of later discovery output. Claude Code's best-practices guide gives the same warning about long sessions. It names a matching anti-pattern, the *infinite exploration*: you ask Claude to investigate something without scoping it, and it "reads hundreds of files, filling the context."
Checkpoint 1 of 5· Check yourself
Three hours into mapping a payments codebase, the agent answers a question about refunds by describing how refund services "are usually structured" and never names the RefundOrchestrator class it found in the first hour. What is the most likely cause?
Generic answers in place of specific earlier discoveries are the classic sign of context degradation. The detail is still in context, but recall of it gets less precise as tokens accumulate.
“Long sessions with irrelevant context can reduce performance.”Source: code.claude.com
2.Reclaiming space with /compact
The first remedy is compaction. When a conversation nears the context limit, the model summarises it and starts a new context window from that summary. In Claude Code, running /compact replaces the conversation with a structured summary. Claude Code also does this automatically. When it does, Claude summarises what matters most, including code patterns, file states and key decisions, and drops redundant tool output. That makes compaction a good fit for exploration sessions, where most of the bulk is raw discovery output you no longer need verbatim.
The automatic pass has to guess what matters, and it can guess wrong. Anthropic warns that overly aggressive compaction can lose subtle details whose importance only shows up later. You have two ways to steer it:
- Focused compaction. Run /compact with instructions, such as /compact focus on the auth bug fix. The summary then keeps what you chose, not what the automatic pass guessed was important.
- Standing instructions in CLAUDE.md. For example: "When compacting, always preserve the full list of modified files and any test commands."
You can also summarise only part of the conversation. Run /rewind, pick a message, and choose *Summarize from here* or *Summarize up to here*. To make automatic compaction start earlier, use /autocompact with a token count.
Not everything after compaction comes from the summary. Several mechanisms reload from disk:
| Mechanism | After compaction |
|---|---|
| Project-root CLAUDE.md and unscoped rules | Re-injected from disk |
| Auto memory | Re-injected from disk |
| The plan Claude wrote in plan mode | Re-injected from disk |
| Files Claude read or edited | Claude Code re-reads up to five, most recently modified first |
| Background commands and background subagents | Keep running; Claude is reminded which are still running |
| Context that hooks added earlier | Summarized with the rest of the conversation |
Checkpoint 2 of 5· Match them up
Match each item to what happens to it when the conversation is compacted
Tap a term, then the definition that fits it.
Anything backed by a file on disk is reloaded. Material that existed only in the conversation, such as hook output, is folded into the summary.
“Files Claude read or edited | Claude Code re-reads up to five, most recently modified first”Source: code.claude.com
Checkpoint 3 of 5· Check yourself
You are about to start a long new exploration task. The current context is full of grep output from a finished debugging detour, but you need the exact retry-timeout value that detour uncovered. Which /compact usage best fits?
A focused /compact frees the space and tells the summariser what must survive. /clear wipes the context entirely, and an unguided pass might drop the value.
“The summary keeps what you choose instead of what the automatic pass guesses is important.”Source: code.claude.com
3.Scratchpad files: findings that outlive the context window
The compaction table shows a pattern: whatever lives in a file comes back intact, and whatever lives only in the conversation gets summarised. Structured note-taking, or agentic memory, builds on that. The agent regularly writes notes to storage outside the context window and reads them back when it needs them. Anthropic gives two examples: Claude Code keeping a to-do list, and a custom agent maintaining a NOTES.md file. Either lets an agent track progress and dependencies that "would otherwise be lost across dozens of tool calls."
In codebase exploration, the scratchpad holds the specifics that context rot tends to blur: exact class names, file paths, configuration values and confirmed call chains. When the agent answers a later question, it rereads the scratchpad before it reasons. The answer then rests on the recorded finding, not on a degraded memory of a tool result from hours ago. The same approach works over much longer runs. In Anthropic's Pokémon example, Claude kept notes across thousands of game steps, and after each context reset it read its own notes and picked up where it left off. On the Claude Developer Platform, the memory tool provides this as a file-based system for storing and consulting information outside the context window across sessions.
Scratchpads and compaction work together. To free space without losing an exact value, first write the value to a notes file, then compact. The file survives the reset whether or not the summary keeps the value. Anthropic matches each technique to a different kind of task:
| Technique | Best fit |
|---|---|
| Compaction | Tasks requiring extensive back-and-forth, where conversational flow matters |
| Note-taking (scratchpad / memory) | Iterative development with clear milestones |
| Multi-agent (sub-agent) architectures | Complex research and analysis where parallel exploration pays dividends |
Checkpoint 4 of 5· Exam question
An architect has been running a single Claude Code session for several hours exploring a large monorepo. Early on, the agent correctly identified that OrderService extends a custom TransactionalBase class with a distinctive retry mechanism. Hours later, asked about OrderService again, the agent describes it as 'typically extending a standard base controller with default error handling,' ignoring its earlier finding. What should the architect do going forward to prevent this?
Correct answer: A — Have the agent record concrete findings, such as exact class names, in a scratchpad file and consult it before answering.
- A. Correct. Persisting exact findings to a scratchpad file gives the agent a durable, specific anchor that survives context degradation, so later answers stay grounded in what was actually discovered.
- B. Incorrect. Output token limits control response length, not whether earlier findings remain salient in context, so raising this limit does not address degradation.
- C. Incorrect. Model size does not restore recall of facts diluted across a long context window; the problem is context management, not raw model capability.
- D. Incorrect. Re-reading the whole repository for every follow-up is expensive and does not build a durable record the agent can reliably reference for the rest of the session.
Checkpoint 5 of 5· Check yourself
Why record a key finding in a scratchpad file instead of relying on compaction to carry it forward?
Summarisation is lossy by design. A file outside the context window does not depend on the summariser picking the right details.
“overly aggressive compaction can result in the loss of subtle but critical context whose importance only becomes apparent later.”Source: www.anthropic.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Running /compact keeps every important detail, so you never need to steer it.Why is that wrong?
Compaction is a lossy summary. Subtle details can be dropped, so use /compact with instructions or CLAUDE.md compaction rules to protect what matters.
Covered in Reclaiming space with /compact
2.Compaction alone is enough to carry work across many context windows.Why is that wrong?
Anthropic found compaction insufficient for multi-window work, because summaries don't always hand the next context clear instructions. Persisted notes and progress files fill that gap.
Covered in Scratchpad files: findings that outlive the context window
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/best-practicesOfficial docs
“Long sessions with irrelevant context can reduce performance.”
↩︎ Why long exploration sessions degrade“Claude reads hundreds of files, filling the context.”
↩︎ Why long exploration sessions degrade“When compacting, always preserve the full list of modified files and any test commands”
↩︎ Reclaiming space with /compact - 2.
“models remain highly capable at longer contexts but may show reduced precision for information retrieval and long-range reasoning”
↩︎ Why long exploration sessions degrade“the agent regularly writes notes persisted to memory outside of the context window.”
↩︎ Scratchpad files: findings that outlive the context window“After context resets, the agent reads its own notes and continues multi-hour training sequences or dungeon explorations.”
↩︎ Scratchpad files: findings that outlive the context window“Context, therefore, must be treated as a finite resource with diminishing marginal returns.”
↩︎ Key concept“overly aggressive compaction can result in the loss of subtle but critical context whose importance only becomes apparent later.”
↩︎ Exam trap 1“These factors create a performance gradient rather than a hard cliff”
↩︎ Prediction“overly aggressive compaction can result in the loss of subtle but critical context whose importance only becomes apparent later.”
↩︎ Checkpoint - 3.https://code.claude.com/docs/en/context-windowOfficial docs
“you run /compact, which replaces the conversation with a structured summary.”
↩︎ Reclaiming space with /compact“run /compact with instructions, like /compact focus on the auth bug fix, before starting a long new task.”
↩︎ Reclaiming space with /compact“Auto memory | Re-injected from disk”
↩︎ Scratchpad files: findings that outlive the context window“Files Claude read or edited | Claude Code re-reads up to five, most recently modified first”
↩︎ Checkpoint“The summary keeps what you choose instead of what the automatic pass guesses is important.”
↩︎ Checkpoint
Also cited
“This happens even with compaction, which doesn’t always pass perfectly clear instructions to the next agent.”
↩︎ Exam trap 2