Why did Claude Code forget? Diagnosing compaction
When Claude Code suddenly 'forgets' an earlier instruction or file, the cause is almost always context compaction. Here's a step-by-step walkthrough to find the boundary, see what was lost, and recover.
If a Claude Code session has been going for a while and Claude suddenly seems to "forget" something — an earlier instruction, a file you showed it, a constraint you set — the cause is almost always context compaction. Claude Code silently compresses the conversation when it hits the context limit, and most of the older content disappears.
This is a walkthrough for diagnosing that scenario in claude-devtools.
Step 1: Open the session
Launch claude-devtools, find the project in the dashboard, and click the session. The full transcript loads.
Step 2: Look for compaction markers
In the chat, compaction events render as visible boundaries — not just a single line. The Session Context Panel on the side also shows the running token composition; look for a vertical drop where the totals collapse and start refilling. That's compaction.
If you see one or more compaction events, that's almost certainly what caused the "forgetting."
Step 3: Inspect the boundary
Click on the compaction marker (or hover the boundary in the Session Context Panel). You'll see:
- The token count immediately before compaction (often near the model's context limit)
- The token count immediately after (typically a small fraction of the prior total)
- A summary of what content was retained vs. compressed
The content that's no longer in the window is what Claude can no longer see — even though it's still in the transcript on your screen.
Step 4: Find what was lost
Scroll backwards from the compaction boundary. Anything you find above it that's not in the post-compaction summary is content Claude has effectively forgotten. Common culprits:
- A specific file you read into context many turns ago
- A constraint you stated once early in the conversation
- A decision the team made via a subagent's output
Step 5: Re-prime the context
The fix is usually mechanical: once you know what was lost, surface it again in your next prompt. Two common patterns:
- Re-read the file via
@-mention so it lands in context fresh - Restate the constraint or decision in your own message — Claude treats restated context as authoritative for the post-compaction window
Step 6: Prevent next time
If a session is approaching the context limit and the work is going to continue, watch the token usage breakdown. A few categories tend to dominate:
- CLAUDE.md files that grew past ~10k tokens — split or trim them
- Tool I/O from Read calls on large files — read narrower ranges
- Subagent overhead when many agents return long outputs — delegate less, or summarize their results before continuing
claude-devtools won't prevent compaction itself (that's Claude Code's behavior), but it gives you the visibility to predict it and adapt.
Related
Where are Claude Code logs stored?
Claude Code writes JSONL session logs to ~/.claude/ — the hidden folder inside your home directory. The path is the same on macOS and Linux; on Windows it's %USERPROFILE%\.claude\.
claude --verbose vs claude-devtools
Both surface the data Claude Code's terminal hides. --verbose dumps a raw JSON stream live; claude-devtools renders the same data as a structured, navigable, searchable interface after the fact.