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
- Your
CLAUDE.mdfiles (or anAGENTS.md, which can load in its place). - Auto memory: the start of Claude's own notes. See how Claude Code remembers your project.
- The names of your MCP tools and the descriptions of your skills.
- Anything your own setup adds, such as an output style or text passed with
--append-system-prompt.
What gets added as Claude works
- Every file Claude reads. A big file costs a lot, and it stays in context.
- Path-scoped rules, which load alongside the files they match.
- Output from hooks, such as a hook that runs after each edit.
- A subagent works in its own separate window, so its large reads stay out of yours. Only its summary comes back.
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:
- Comes back from diskThe project-root CLAUDE.md and unscoped rules, auto memory, the plan Claude wrote in plan mode, and your skill descriptions (rebuilt from your current skills).
- Still appliesThe system prompt and your output style.
- Reloads when neededRules with
paths:frontmatter and CLAUDE.md files in subdirectories load again on demand, the next time Claude touches a matching file. - Partly re-readClaude Code re-reads up to five of the files Claude read or edited, most recently modified first. A file over 5,000 tokens comes back as a path reference without its content.
- Re-injected with capsSkills you invoked come back, capped per skill and in total. Large ones are cut off at the end and the oldest are dropped first, so put the important instructions near the top of the SKILL.md.
- Keeps runningBackground commands and background subagents continue. Claude is reminded which ones are still running.
- Summarized awayThe conversation itself, including context that hooks added earlier. Rules and nested CLAUDE.md files that had loaded into the conversation are summarized with it, until they load again on demand.
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:
- Compact with a focus.
/compact focus on the auth bug fixkeeps what you choose instead of what the automatic pass guesses matters. - Compact part of it.
/rewind, pick a message, then Summarize from here or Summarize up to here. See undoing what Claude did with /rewind. - Clear between tasks.
/clearwhen you switch to unrelated work. Old conversation crowds out the files you need next and costs tokens on every message. - Delegate large reads to a subagent so the file contents stay in its window.
- Compact earlier. The documentation describes an
/autocompactcommand that sets how full the window gets before the automatic pass. Check the current page for the accepted values.
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
- Start a session and run
/contextbefore typing anything. Note how much is already there. - Ask Claude to read one large file, then run
/contextagain. - Run
/compact focus on what we just readand 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.