Tutorial 13 min read | November 19, 2026

Claude Code /compact dropped your plan. Here's what actually survives, and how to get the work back

After Claude Code compacts a long session, the plan and earlier decisions often go fuzzy or vanish from the summary. Here is what official docs say survives, a file-and-hook recovery you can do for free, and when a local task store helps.

Keep the plan outside the compact summary

If Claude just compacted and the next step went fuzzy, leave your email. We'll send the setup tutorial, and you can tell us you use Claude Code, before any price is shown.

Step 1 of 4

This needs to be a real email — we'll email you in a few minutes.

No spam. Unsubscribe anytime.

You have been in a long Claude Code session. The context meter creeps up, auto-compact fires, or you run /compact yourself. The next reply is confident and slightly wrong. It repeats a mistake you already corrected. It proposes a dependency you already rejected. It talks about "the plan" without following the plan.

This is not a mysterious bug. Compaction is lossy on purpose. The useful question is what still exists after it runs, and how to put the work somewhere compaction cannot eat.

What /compact actually does

Claude Code's context window holds the session: your instructions, files it read, its replies, and some tool output you never see in the terminal. When that window fills, Claude Code summarizes the conversation so the session can continue. Official documentation describes this the same way whether it was automatic or you typed /compact.

A summary is not a transcript. It keeps what the summarizer thinks matters, usually the recent work, and drops or flattens the rest. People who have checked this in their own sessions report a consistent pattern: the latest stretch is mostly still there; older decisions are the ones that disappear. One widely discussed case: after many compactions in a single session, a later summary had kept none of a dozen older decisions, including a product-positioning line, a backend cleanup call, and a bug they had already tracked down. Treat that as a cautionary measurement, not a universal statistic — your summaries will differ — but the shape of the failure is real.

Official docs are blunt about the same class of problem: if an instruction seemed to vanish after /compact, it was probably given only in conversation, lives in a nested CLAUDE.md that has not reloaded yet, or is a path-scoped rule that has not matched a file since. Conversation-only commitments are the first thing to write down.

What official docs say survives

As of the current Claude Code documentation on the context window and memory, this is what is re-injected or reloaded after compaction. Check the docs if your version is older; skill re-injection, for example, needs a recent Claude Code release.

Still there after compactGone or only if the summary kept it
System prompt and output styleAnything you only said in chat
Project-root CLAUDE.md and unscoped rules, re-read from diskNested CLAUDE.md files until they are reloaded on demand
Auto memory, re-injected from diskPath-scoped rules until they match a file again
Skill descriptions, rebuilt from current skills (recent versions)Context a hook added earlier, which is summarized with the chat
The plan Claude wrote in plan mode, re-injected from diskA PLAN.md or notes file nobody told it to re-read
Up to five files Claude already read or edited, most recently modified firstThe rest of the files it "already understood"
Invoked skill bodies, with a token cap; oldest dropped firstOlder decisions after a summary of a summary
SessionStart hooks whose matcher includes compact, plus their outputThe assumption that "it will remember the plan"

Two important nuances. First, plan mode's own plan file is re-injected; a markdown plan you have been using as a working document is not, unless something re-reads it. That is why people report "Claude does not review your active plan after compaction" even when they religiously keep a PLAN.md. Second, root CLAUDE.md comes back; an instruction you only typed into the chat does not, unless you add it to that file.

Do this in the next five minutes

  1. Do not keep arguing with the compacted session about what it "should remember." Write the missing decisions down first, while you still have them.
  2. Create or update three short files in the repo, each with one job:
    • CLAUDE.md — standing rules. Keep it short. How to build, what not to touch, a pointer to the other two files.
    • DECISIONS.md — append-only. Each entry is the date, the decision, why, and what you already ruled out.
    • NOTES.md — current state only. What is done, what is open, the next step. Rewrite it; do not let it grow into a novel.
  3. Tell Claude, in this session: "Re-read CLAUDE.md, DECISIONS.md and NOTES.md before you continue. Then do only the next step in NOTES.md."
  4. Add a SessionStart hook so you are not depending on it remembering to re-read. Compaction fires SessionStart with source compact, and the hook's stdout is added to the compacted context. A typical shape:
{
  "SessionStart": [
    {
      "matcher": "compact",
      "hooks": [
        {
          "type": "command",
          "command": "printf '\n# Repo state after compact\n' && (test -f DECISIONS.md && cat DECISIONS.md) && (test -f NOTES.md && cat NOTES.md)"
        }
      ]
    }
  ]
}

Put that in your Claude Code hooks settings, and confirm the paths match your repo. You can also match startup and clear if you want the same brief on a fresh session. Official docs call out this exact hook source; a number of practitioners have landed on it independently after losing a plan mid-refactor.

Control when and what gets compacted: /context, /rewind, /autocompact

The files and the hook decide what comes back after a compaction. Claude Code also has a few built-in controls for when the summary happens and what it focuses on. All of these are in the official commands, checkpointing and hooks docs.

  • See what is filling the window. /context shows current context usage as a colored grid, with suggestions for context-heavy tools and memory files. Check it before you decide whether to compact, clear or keep going.
  • Compact with a focus. Run something like /compact focus on the auth bug fix before the automatic pass guesses what matters. That helps the current task. It will not reliably keep a decision from ten compactions ago. Those belong in DECISIONS.md.
  • Summarize only part of the session. Run /rewind (or press Esc twice with an empty prompt), pick a message, and choose Summarize from here or Summarize up to here. Highlight the option with the arrow keys and type what the summary should keep into the add context (optional) row. It does not change files on disk, and the original messages stay in the session transcript. It works like a targeted /compact: summarize a noisy debugging stretch and keep the messages where you set the plan word for word.
  • Move the auto-compact point. /autocompact 500k sets how full the context window gets before Claude Code compacts on its own, and /autocompact auto goes back to the default for your model. With no argument it opens a dialog that shows the current setting. It needs Claude Code v2.1.221 or later and accepts 100K tokens or more, capped at the model's context window. Claude Code saves the value to your user settings (from v2.1.288, per model) and applies it to the current session. For one launch only, use claude --autocompact 500k. The CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable overrides both.
  • Tell the summary what to keep, every time. A PreCompact hook runs before each compaction (matcher manual for /compact, auto for automatic compaction). If it exits 0, Claude Code uses its stdout as instructions for the compaction summary, up to 10,000 characters. For example, print "Keep the current step from NOTES.md and every rejected approach from DECISIONS.md". Exiting with code 2 blocks the compaction instead, which is rarely what you want mid-task.

Be clear about what these do. They change when the summary is written and what it focuses on. A later auto-compact point means a later summary, not no summary, and a bigger window holds more noise as well as more plan. The plan still needs to live on disk, which is what the SessionStart hook above re-reads.

Claude Code's built-in task list is a separate question from the plan: see which AI agent task lists survive compaction for how it compares with Codex and Cursor, and a 2-minute test.

A hook is not a task list

The file-and-hook pattern above is useful and free. It also has limits, and they are worth stating plainly.

  • A hook that cats two files will dump those files into context every compact. If the files get long, you are back to crowding the window.
  • Nothing in that setup tracks dependencies between tasks, or which task is actually in progress, unless you maintain that by hand in NOTES.md.
  • The same files are not automatically available if you switch from Claude Code to Cursor, Codex, or another MCP client, unless you keep using them as plain files and remember to point the new tool at them.
  • A stale line in DECISIONS.md is worse than a missing one, because the agent will follow it with confidence. Date the entries and prune what is no longer true.

This is the gap a dedicated task store is for. The six ways a context window forgets is the broader picture; compaction is only one of them. Crashes, /clear, model switches, and coming back tomorrow are the others. If you also work in Cursor, the same idea applies to a new Cursor chat that forgot your earlier requests. If you switch between Claude Code, Cursor and Codex on one repo, see how to add memory to Claude Code, Cursor and Codex.

Where Todo-MCP fits, honestly

Todo-MCP is a local MCP server. Your tasks, dependencies and session context live in a SQLite file on your machine. It is a paid download, and the files stay yours. To see plans, leave your email in the form on this page first; it sends the Claude Code setup tutorial and then shows the options. After a compact, a crash, or a new session, the usual start is context_resume, which returns the current task, elapsed time, stored context keys and a recommendation for what to do next.

What it does not do: it does not hook itself into Claude Code's compact cycle automatically. If nobody calls the tools, the store sits there unused. The reliable setup is:

  1. Install Todo-MCP in Claude Code as a local stdio MCP server (the Claude Code setup guide walks through this).
  2. Start sessions, and resumes after compact, with context_resume.
  3. Optionally add a compact hook or a short CLAUDE.md line that says: after any compaction, call context_resume before continuing.
  4. Keep CLAUDE.md for standing rules. Let the task list hold the plan, and the context keys hold the decisions you would otherwise lose to a summary.

If you already use a compact reminder or a plan-revisor, those can sit beside a task store rather than replace it. We wrote about that pairing in How to use ToDo-MCP with Post-Compact Reminder. Use the reminder to force the re-read; use the task list as the thing that is re-read.

When to start a new session instead

If the conversation has mixed two or three tasks, or you have already compacted many times, a fresh session plus a file (or context_resume) is often cheaper than another summary of a summary. Write NOTES.md or update the current task, run /clear or start a new session, and have the new session read the store before it touches code.

Your plan does not have to live inside the context window. The window will compact again. The work you care about should already be somewhere else.

Keep the plan outside the compact summary

If Claude just compacted and the next step went fuzzy, leave your email. We'll send the setup tutorial, and you can tell us you use Claude Code, before any price is shown.

Step 1 of 4

This needs to be a real email — we'll email you in a few minutes.

No spam. Unsubscribe anytime.

Frequently asked questions

How do I change when Claude Code auto-compacts?
Run /autocompact with a size, such as /autocompact 500k, to set how full the context window gets before Claude Code compacts on its own; /autocompact auto returns to the default for your model. It needs Claude Code v2.1.221 or later, accepts 100K tokens or more and is capped at the model context window. claude --autocompact sets it for one launch, and the CLAUDE_CODE_AUTO_COMPACT_WINDOW variable overrides both. It changes when the summary happens, not what survives it.
Does /compact delete my chat?
No. Compaction replaces the conversation history in the context window with a summary so the session can continue. The summary is lossy: details the summarizer leaves out are gone from what Claude can see next, even if you still remember them.
Why did Claude ignore my plan after compacting?
Compaction does not automatically re-read a plan file you have been updating in the repo. Official Claude Code docs say the plan written in plan mode is re-injected from disk, and the project-root CLAUDE.md is re-injected. A PLAN.md you only mentioned in chat, or that Claude never re-reads, can be reduced to "there was a plan" with the details missing. Tell it to re-read the file, or add a SessionStart hook that runs on the compact source and prints the plan into context.
What actually survives /compact?
According to Claude Code documentation: the system prompt, project-root CLAUDE.md and unscoped rules, auto memory from disk, skill descriptions, a fresh git status if the session started with one, the plan-mode plan from disk, up to five recently modified files Claude already touched, invoked skill bodies up to a token cap, and SessionStart hooks whose matcher includes compact. Conversation-only decisions, corrections, and debugging notes live or die by the summary.
Is this the same as /clear?
No. /compact keeps a summary and some recent context so the same session can continue. /clear drops the conversation. After /clear, only what is on disk (and whatever a SessionStart hook prints) is available. If you were about to switch tasks, writing state to a file and then clearing is often cleaner than compacting a mixed conversation.
Does Todo-MCP run automatically after compaction?
No, and you should not expect it to. Todo-MCP is a local MCP server: your tasks and context sit in a SQLite file on your machine, and the agent reads them back when it calls the tools, typically starting a session with context_resume. You can also add a hook or a skill that tells Claude to call context_resume after compact. The store is what survives; the agent still has to look at it.

Continue Reading

Back to all articles