What is in Claude Code's context window, and what survives /compact

The context window holds everything Claude knows about your session: your instructions, the files it reads, its own replies, and content that never shows in your terminal. When it fills up, Claude Code compacts the conversation into a summary. Knowing what is loaded, and what comes back afterwards, tells you where to put an instruction so it lasts.

What is there before you type

What gets added as Claude works

What survives /compact

When a session compacts, the conversation history is replaced by a summary. What happens to everything else depends on how it was loaded. This is the table from Anthropic's documentation, shortened:

The practical point: an instruction you typed in the chat is not safe, and neither is a path-scoped rule that has not matched a file lately. If something must persist, put it in the project-root CLAUDE.md. The documentation says this directly: drop the paths: frontmatter or move the rule to the root file.

What you can do before it fills up

Claude Code compacts on its own as you near the limit, so a full window does not end your session. You can act first:

More on the cost side in spend less of your Claude Code quota, and on carrying work between sessions in a 40-line handoff note.

See your own numbers

The documentation's timeline uses representative numbers, not yours. Run /context in a session for a live breakdown by category, including which CLAUDE.md and auto memory files loaded. Run /memory to open and edit them.

Try it on something harmless

  1. Start a session and run /context before typing anything. Note how much is already there.
  2. Ask Claude to read one large file, then run /context again.
  3. Run /compact focus on what we just read and compare the numbers.

This follows Anthropic's context window documentation as we read it in October 2026. We are not affiliated with Anthropic. We wrote this from the documentation and have not tested every case. Some details depend on your version and model, and where this page and the documentation disagree, the documentation wins.

See also: Claude Code sessions: resume, name, branch.

The free loop-stop skill gives long tasks a limit and a stop rule. If you want a second pair of eyes on your CLAUDE.md and settings, the Tune-Up Kit is a checklist for exactly that.