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

  1. Long sessions decay: old turns, dead ends, and stale code crowd out what matters now.
  2. When quality drops, summarize the state and restart in a clean session.
  3. Externalize decisions into files (spec, context file, notes) so they survive a restart.

Spot The Rot

    Dropped Rules

    Instructions you set earlier stop being followed.

    It added a dependency you banned
    30 turns ago.
    Returning Bugs

    Issues you already fixed reappear in new output.

    The off-by-one you fixed is back.
    Looping

    The model keeps proposing the same failed approach.

    Same wrong fix, reworded, again.

Compact & Restart

    Summarize State

    Capture decisions and current code position concisely.

    "Summarize decisions and the current
    code state in ~10 lines."
    Fresh Window

    Start a new session seeded with that summary.

    New chat + summary + known-good
    code.
    Re-Anchor Code

    Paste the current good version so you build from reality.

    "Here is the current file.
    Next change: ..."

Externalize State

    Spec & Context File

    Keep requirements and conventions in versioned files.

    docs/spec.md, CLAUDE.md -> survive
    any restart.
    Running Notes

    A short decisions log beats trusting the chat to remember.

    NOTES.md: "chose Redis for rate
    limit; see spec."
    Commit Milestones

    Commits are durable checkpoints you can return to.

    git commit at each green state.

Prevent The Decay

    One Task Per Session

    Keep unrelated work in separate sessions.

    New task -> new session.
    Prune Dead Ends

    Do not keep iterating on top of abandoned attempts.

    Restate from the good version,
    drop the failed path.
    Checkpoint Often

    Summarize and commit at milestones before continuing.

    Green -> summarize -> commit
    -> continue.

Tips

  1. At milestones, ask for a concise summary of decisions and current code state to carry forward.
  2. Re-paste the known-good version before the next change instead of building on a long thread.

Warnings

  1. Pushing on in a degraded session wastes time; the model is reasoning over noise and dead ends.
  2. Relying on the chat to 'remember' is fragile; durable state belongs in files, not scrollback.

In Practice

FAQ