What actually happens when Claude Code hits 80% context (and how to handle it)
Around 80% context usage, Claude Code starts making different kinds of mistakes. Not the same ones as earlier in the session — different ones. It loses track of decisions made in the first half of the conversation. It re-reads files it already processed. It sometimes re-does work it already completed.
By 95%, it often stops and says it can't continue.
Here's what's going on and how to handle it without losing work.
What's actually happening
Claude doesn't have a rolling window that drops old content as new content comes in. It processes the full conversation every turn. At 200k tokens with 80% used, it's processing 160k tokens per request. The model is still functional but the early parts of the conversation are being weighted less as the total context grows.
The decisions you established at the start of a session — project structure, naming conventions, architectural choices — are literally further away in the token stream. They're still there, but they compete with everything that's happened since.
Why /compact doesn't fully solve it
Claude Code's /compact command summarizes the conversation and compresses context. This helps with the token count but the summary loses detail. The summary will capture "we decided to use PostgreSQL" but not necessarily the specific schema decisions, migration strategy, or the three alternatives you rejected and why.
If you compact without writing down the important decisions first, they're gone from context.
The workflow that handles it cleanly
Step 1: Add a context monitor instruction to CLAUDE.md
At 80% context usage, stop and do the following before continuing:
1. Write a summary of current work to tasks/current-task.md
2. Note what was completed, what's in progress, what decisions were made
3. Then run /compact
Do not wait for context to fill silently.
Step 2: Keep a state file
The state file format that survives compaction:
## Active Task
goal: "what you're trying to accomplish"
steps:
- [x] completed step
- [ ] current step (IN PROGRESS)
- [ ] next step
decisions:
- "Using PostgreSQL not SQLite because X"
- "Auth is JWT not sessions because Y"
last_checkpoint: "Finished the user model. Next: auth routes."
This file is written before /compact and read at the start of the next session. It's 20-30 lines and captures everything that would otherwise be lost.
Step 3: Start new sessions by reading the state file
Add to CLAUDE.md:
At the start of each session, read tasks/current-task.md before doing anything else.
It tells you where work was when the session ended.
After compaction or a session restart, Claude reads the state file and picks up where it left off. The important context is preserved because it was written down explicitly, not because it's still in the token stream.
The practical result
With this in place, long tasks that span multiple sessions work reliably. The session ends cleanly, state is preserved, and the next session continues without re-reading everything or re-making decisions.
Without it, you're relying on context that may or may not still be weighted correctly — which is why the drift and repeated mistakes happen late in long sessions.
More patterns for managing long Claude Code sessions are in the Agent Prompt Playbook. $29.