What this thread does
Anthropic's 2.1.311 notes fix stale MEMORY.md and CLAUDE.md after automatic compaction when those files were edited earlier in the same session, and 2.1.317 fixes very long conversations losing an earlier summary when compaction shortens its own request; these repairs do not make summarization lossless (checked 2026-11-05).
The problem
A long Claude Code session hits the context limit, compacts, and afterwards the agent no longer knows the exact commands, the list of changed files or the decision you made an hour ago.
Three controls the docs describe
(From the best-practices and costs pages, read 18 October 2026.)
1. Instructions on the command. /compact Focus on the API changes (or "focus on test output and code changes") tells the summary what to preserve. 2. A standing rule in CLAUDE.md. Add a heading such as # Compact instructions with a sentence like "When compacting, always preserve the full list of modified files and any test commands". Auto compaction then follows it too. 3. Partial compaction. Press Esc twice or run /rewind, pick a message and choose Summarize from here (condense that point forward, keep earlier context) or Summarize up to here (condense earlier messages, keep recent ones in full).
When not to compact
- The docs say
/clearbetween unrelated tasks costs nothing and starts clean. Compacting a large context is itself a large request, because it reads the whole conversation it summarizes. - For a question that should not stay in context,
/btwanswers without entering the history. - Durable facts (decisions, commands) belong in CLAUDE.md or a notes file, not only in the conversation. Related thread: session-start-and-handoff-notes-checked-against-git.
Caveats
- Vendor documentation, not tested by WhatWorks; we have no measurement of how well a summary honours the instructions.
- Compaction is lossy by design. If a detail must survive, write it to a file first and tell Claude to re-read it.
Primary source
Primary sources: Claude Code best practices and Manage costs effectively (Anthropic, read 18 October 2026). Checked: /compact <instructions> with the "Focus on the API changes" example; the # Compact instructions section in CLAUDE.md; Esc+Esc or /rewind with Summarize from here (condenses from that point forward, keeps earlier context) and Summarize up to here (condenses earlier messages, keeps recent ones); /clear between unrelated tasks; /btw answers never enter history; compacting a large context is itself a large request. Not verified: that auto compaction always honours the CLAUDE.md section (the docs say it customizes compaction behavior), and how well any summary follows the instructions.
Started from a post by @Anthropic (Claude Code docs), packaged by the editor. Original post