TL;DR

When Claude Code's context fills, it compacts automatically by summarising older conversation. Anything only said in chat can be lost. The project-root CLAUDE.md, auto memory and recent files reload; path-scoped rules and nested CLAUDE.md files are summarised away and return only when Claude touches a matching file again. Compact with a focus before long tasks, clear between tasks, and put durable rules in CLAUDE.md.

When Claude Code's context fills up, it compacts automatically: it summarises older conversation and keeps working. Per the docs, content that existed only in the conversation is summarised with the rest of it, while the project-root CLAUDE.md is re-injected from disk. Put rules that must survive in the project-root CLAUDE.md, run /compact with a focus before a long task, and use /clear between unrelated tasks. Last verified on 14 November 2026 against the context window documentation, with the npm registry listing 2.1.325 as the latest Claude Code version.

How to tell an outage from a local problem

A full context window is not an outage. The error reference files Context limit reached and Prompt is too long under request errors, separate from its usage limits section. Errors such as 529 or 500 are different, and status.claude.com and the Claude Code status hub show whether one is open. If the session is just slow and long, the steps below apply.

Symptom, likely cause and fix

SymptomLikely causeWhat to do
Claude forgets a decision after compactionIt was only in the conversation, which is summarisedWrite it to CLAUDE.md or a file, or compact with a focus
A rule stops applying after compactionIt lives in a paths:-scoped rule or a nested CLAUDE.md, which load into historyMove it to the project-root CLAUDE.md
"Autocompact is thrashing"A file or tool output keeps refilling the windowRead in line ranges, compact with a focus, use a subagent, or /clear
Not enough messages to compact.Per the docs, the conversation is a single exchange with nothing earlier to summarise, so one prompt plus what is sent with every request fills the windowUse /clear and restart from a short brief
Window fills right after /clearStartup content (CLAUDE.md, MCP tools, skills) is too largeRun /context and trim what loads
Usage climbs in a long sessionEach request carries the whole conversationClear between tasks; delegate large reads

What is filling the window?

Run /context. The docs say it shows a live breakdown by category, including system prompt, tools, memory files and messages, with optimisation suggestions. In fullscreen mode the per-item breakdown is collapsed, and /context all expands it. Compare the Messages row with the rest. If messages dominate, the conversation is the problem. If the other rows together are larger, startup content leaves too little room to work. /memory opens the memory files that loaded.

What survives compaction?

The docs give an exact list. These come back after compaction:

  • The system prompt and output style.
  • The project-root CLAUDE.md and unscoped rules, re-injected from disk.
  • Auto memory, re-injected from disk.
  • Skill descriptions, rebuilt from your current skills (Claude Code 2.1.304 or later).
  • Up to five recently read or edited files, most recently modified first. A file over 5,000 tokens returns as a path reference without content.
  • Invoked skill bodies, capped at 5,000 tokens each and 25,000 in total, oldest dropped first.

These are summarised away with everything else: rules with paths: frontmatter and nested CLAUDE.md files, which reload only when Claude touches a matching file again, and anything a hook added to the conversation earlier. Instructions you typed in chat are summarised with the rest of the conversation. That is the whole reason to move durable rules out of the conversation. A CLAUDE.md is also guidance, not enforcement, as your CLAUDE.md is not a control explains.

What can you do before it compacts?

Each of these is documented:

/compact focus on the auth bug fix and the files changed
/rewind
/autocompact 500k
/clear

/compact with instructions tells the summary what to keep. /rewind, then selecting a message, offers Summarize from here or Summarize up to here, which compacts only part of the conversation. /autocompact with a token count sets how full the window gets before the automatic pass runs, so you can compact earlier. /clear starts fresh, and /rename before it, or a name passed to /clear, lets you find the old session through /resume. The docs add that /compact itself reads the whole conversation, so compacting a very large context is a large request.

You can also set standing compaction guidance in CLAUDE.md. The costs page documents this form:

# Compact instructions

When you are using compact, please focus on test output and code changes

How do you re-inject context after compaction?

The hooks guide documents a SessionStart hook with a compact matcher. Claude Code runs it after compaction and adds the command's stdout to the context. Put it in .claude/settings.json:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "compact",
        "hooks": [
          {
            "type": "command",
            "command": "echo 'Reminder: run npm test before committing. Current task: auth refactor.'"
          }
        ]
      }
    ]
  }
}

Swap the echo for a command with dynamic output, such as git log --oneline -5. The shape is adapted from the hooks guide's example, with a different echo text, and was not run in a live session. If it does not appear to fire, the checks in Claude Code hooks not firing apply. For text that should load on every start, CLAUDE.md is the simpler place.

What does "Autocompact is thrashing" mean?

The message starts Autocompact is thrashing: the context refilled to the limit. Per the troubleshooting page, compaction succeeded but a file or tool output refilled the window several times in a row, so Claude Code stops retrying. The documented recovery is to ask Claude to read the oversized file in a line range or one function, to run /compact keep only the plan and the diff, to move the large-file work to a subagent, or to run /clear. If it returns after a clear, check /context as described above.

How do you keep the window small?

Delegate verbose work, such as test runs and log reads, to a subagent so only a summary returns. MCP tool definitions are deferred by default, so only tool names enter context until a tool is used, and /mcp lets you disable servers you do not need. Move workflow-specific instructions from CLAUDE.md into skills, which load only when invoked, and keep CLAUDE.md short. The docs suggest under 200 lines. Models with a 1 million token window exist on some plans, and the docs say compaction works the same way there. One open GitHub report describes auto-compaction firing well below the expected point on a 1M window, on the VS Code extension v2.1.319 (issue 109678, open on 14 November 2026). It is a single user report, not documented behaviour.

For a memory-heavy session, the troubleshooting page says to restart Claude Code and run claude --continue to resume the conversation in a fresh process. Its warning on /heapdump is that the snapshot contains your full conversation and credentials, so it should not be attached to a public issue or shared.

More practical writing for people building with AI tools is on the Lead Source blog.

Fixed? Two optional things

Check Anthropic’s status and get an alert when an incident is resolved: Claude Code status and alerts, an independent resource by Lead Source.

Official source: status.claude.com.

Written by the team at Lead Source, where the day job is lead source tracking: working out which marketing actually brings customers.