AnswerQA

How do I recover when Claude auto-compacts and forgets the plan?

Answer

Compaction replaces the conversation with a summary; CLAUDE.md and auto memory are re-injected from disk, but path-scoped rules and per-turn nuance are lost. Use /context to watch budget, /rewind to undo a turn, and /clear to start fresh; reach for `claude --resume` only when the session is still salvageable.

By Kalle Lamminpää Verified May 7, 2026

Auto-compaction is the silent killer of long sessions. Claude Code summarizes the conversation history when it starts to overflow the context window; the summary is short, prose, and lossy.

What survives, what does not

SourceAfter compaction
System prompt and output styleUnchanged (not part of message history)
Project-root CLAUDE.mdRe-injected from disk
Auto memoryRe-injected from disk
Rules with paths: frontmatterLost until a matching file is read again
Skill bodiesRe-injected, but large skills are truncated; oldest invoked skills are dropped past the budget
Per-turn context (which files Claude considered, which approaches it ruled out)Lost; only the summary survives

The asymmetry matters. Anything that lives on disk gets re-injected. Anything that lived only in the conversation (a half-formed plan, a “do not touch X” instruction, a clarifying answer to a question) is reduced to whatever the summarizer kept.

Watch the budget before it bites

/context

Live breakdown by category with optimization suggestions. Run it any time the session feels off; the categories that are usually eating budget are recent file reads, skill bodies, and accumulated tool output. The doc explicitly notes that you can subagent away noisy reads (parallel research) to keep them out of the parent’s context entirely.

/memory

Lists which CLAUDE.md files are currently loaded. Useful when you suspect a rule “stopped working” mid-session: a path-scoped rule unloads when the matching file is no longer recent in context, and reload only when a matching file is touched again.

Decision tree when the session goes wrong

Symptom: Claude is repeating itself or ignoring an instruction it followed earlier. The session probably compacted. /clear and start fresh. The summary cannot recover the nuance you lost. Re-state the instruction in your first prompt of the new session.

Symptom: Claude made an edit you do not want. /rewind (or Esc + Esc). The menu shows three restore options plus a “Summarize from here” action and a cancel:

  • Restore code and conversation: undo both the file changes and the messages that led to them.
  • Restore conversation: rewind the messages but keep the current code.
  • Restore code: undo the file changes but keep the conversation; useful when you want Claude to know what was tried and rejected.

After restoring the conversation (or running summarize), the original prompt from the selected message lands back in the input field so you can edit it. “Restore code” alone leaves your prompt history intact.

Symptom: you closed the terminal mid-task. claude --continue resumes the most recent conversation. claude --resume opens a picker if you want a different session. Both restore the saved transcript; if compaction had already happened, you wake up with the summary, not the original detail.

Symptom: the context is genuinely too full to keep working. /clear and start a fresh session. Better to lose the conversation cleanly than continue with a degraded one. Anything you wanted to preserve should be in CLAUDE.md or a .claude/rules/*.md file before you /clear, not in the conversation.

Footguns

Auto-compaction is silent in normal terminal flow. There is no banner, no warning, no “session was compacted” message during ordinary use. You notice when Claude starts repeating itself or forgets a half-formed agreement. By that point the original conversation is already gone. (You can wire a PreCompact hook to trigger before compaction if you want a programmatic signal, but nothing surfaces by default.) The proactive defense is /context checks at natural break points: after a long debugging session, after a research subagent returns with a 3,000-line file, after Claude has read every test in the suite. If the breakdown shows tool output dominating, consider /clear.

/rewind does not unwind Bash side effects. Checkpointing tracks Edit/Write/MultiEdit. A Bash(rm -rf node_modules) is not in the rewind log; the directory is gone whether you rewind or not. The same for Bash(git push), Bash(npm publish), anything network or destructive. /rewind is local undo for in-session edits; git is the only undo for everything else.

Path-scoped rules disappear after compaction even though their files might still be referenced in the summary. A rule that loaded because Claude opened src/auth/token.ts is gone after compaction; the summary may still mention “we worked on token.ts” but the rule frontmatter does not re-trigger from the summary. Defense: if a rule must persist across compactions, drop the paths: frontmatter or move it into the project-root CLAUDE.md.

Skill bodies get truncated, then evicted, then silently re-injected. Large skills (above the per-skill cap) are truncated when re-injected; older invoked skills are dropped first if the total skill budget is exceeded. So a skill that worked perfectly in turn 5 may quietly half-work in turn 50 because half its body got truncated. If a skill is doing weird partial work after a long session, /clear or shrink the skill body.

claude --resume walks back into a compacted session. Resuming does not undo compaction; you wake up with whatever the conversation looked like when you closed it, summary and all. If the session was already degraded when you exited, resuming drags that degradation forward. For sessions that ended badly, prefer /clear and a new session over --resume.

When NOT to fight compaction

  • The session is already dead. Once you cannot tell whether Claude remembers an instruction, you have lost. /clear is faster than excavating the conversation for what was lost.
  • The work is finished. Compaction near the end of a successful task is harmless; do not preempt it just because /context shows yellow. Save the cycles for the next task.
  • You can express the missing context in two sentences. A small lossy summary you can re-prime in a fresh session is the cheapest recovery. Long sessions earn /clear precisely because the recoverable state is short.
  • You are about to do something destructive. The instinct to “just one more turn before compaction” is exactly when destructive edits sneak through. If /context is over 80%, do not run another bash command; /clear, restart, redo the destructive step deliberately.

Sources

  • Explore the context window
    Authoritative on what survives auto-compaction (CLAUDE.md, auto memory re-injected from disk) vs what is lost (path-scoped rules, per-turn detail). Source for the /context command and the per-skill truncation behavior.
  • Checkpointing
    /rewind (or Esc + Esc) opens a menu with three restore options: restore code, restore conversation, or restore both. Checkpoints persist across sessions; Bash and external file edits are not tracked.
  • CLI reference
    `claude --continue` resumes the most recent conversation; `claude --resume` opens a picker. Useful when you want to keep working in a session that compacted unhelpfully.

Was this helpful?

Read more