Managing Long Sessions & Context Rot
Keep long AI sessions sharp: recognize context rot, summarize and restart, and anchor state so quality does not decay.
TL;DR
- Long sessions decay: old turns, dead ends, and stale code crowd out what matters now.
- When quality drops, summarize the state and restart in a clean session.
- Externalize decisions into files (spec, context file, notes) so they survive a restart.
Spot The Rot
Dropped RulesInstructions you set earlier stop being followed.
It added a dependency you banned
30 turns ago.Returning BugsIssues you already fixed reappear in new output.
The off-by-one you fixed is back.LoopingThe model keeps proposing the same failed approach.
Same wrong fix, reworded, again.Compact & Restart
Summarize StateCapture decisions and current code position concisely.
"Summarize decisions and the current
code state in ~10 lines."Fresh WindowStart a new session seeded with that summary.
New chat + summary + known-good
code.Re-Anchor CodePaste the current good version so you build from reality.
"Here is the current file.
Next change: ..."Externalize State
Spec & Context FileKeep requirements and conventions in versioned files.
docs/spec.md, CLAUDE.md -> survive
any restart.Running NotesA short decisions log beats trusting the chat to remember.
NOTES.md: "chose Redis for rate
limit; see spec."Commit MilestonesCommits are durable checkpoints you can return to.
git commit at each green state.Prevent The Decay
One Task Per SessionKeep unrelated work in separate sessions.
New task -> new session.Prune Dead EndsDo not keep iterating on top of abandoned attempts.
Restate from the good version,
drop the failed path.Checkpoint OftenSummarize and commit at milestones before continuing.
Green -> summarize -> commit
-> continue.Tips
- At milestones, ask for a concise summary of decisions and current code state to carry forward.
- Re-paste the known-good version before the next change instead of building on a long thread.
Warnings
- Pushing on in a degraded session wastes time; the model is reasoning over noise and dead ends.
- Relying on the chat to 'remember' is fragile; durable state belongs in files, not scrollback.
In Practice
When a long session starts dropping rules and looping, you capture the state in a summary, then reopen clean. The new session reasons over the right context instead of a pile of dead ends.
- You notice the rot: a banned dependency reappears and a fixed bug returns.
- You ask for a tight summary of decisions and the current code state.
- You start a fresh session seeded with that summary and the known-good files.
- Durable decisions already live in the spec and notes, so nothing is lost.
# In the degraded session, before abandoning it:
This thread is getting unreliable. Summarize, in ~10
lines: the decisions we've made, the current state of
the code, what's done, and the single next step.
List any assumptions so I can carry them forward.
# Then, in a NEW session:
Context from a previous session:
<paste the summary>
Current code (known-good):
<paste the relevant files>
Next step: <the one next step from the summary>.
Follow docs/spec.md and CLAUDE.md as the source of truth.FAQ
The model starts ignoring instructions you set earlier, reintroduces bugs you already fixed, contradicts itself, gives vaguer answers, or loops on the same wrong approach. These mean the useful context is buried under accumulated turns and dead ends.
Stop adding to it. Ask for a tight summary of the decisions made and the current code state, then start a fresh session seeded with that summary and the known-good code. A clean window with the right context beats a long one full of noise.
Externalize it. Keep the spec, the project context file, and a short running notes file in the repo. Durable decisions live there, not in chat scrollback, so a new session (or a teammate, or you tomorrow) can pick up without re-deriving everything.
Only while it stays sharp. There is no prize for a long thread. The moment quality dips, the cheapest move is almost always to compact and restart rather than fight the decay.