What the timeline shows
The session walks through a realistic flow with representative token counts:- Before you type anything: CLAUDE.md, auto memory, MCP tool names, and skill descriptions all load into context. Your own setup may add more here, like an output style or text from
--append-system-prompt. - As Claude works: each file read adds to context, path-scoped rules load automatically alongside matching files, and a PostToolUse hook fires after each edit.
- The follow-up prompt: a subagent handles the research in its own separate context window, so the large file reads stay out of yours. Only the summary and a small metadata trailer come back.
- At the end:
/compactreplaces the conversation with a structured summary. Most startup content reloads automatically; the table below shows what happens to each mechanism.
What survives compaction
When a long session compacts, Claude Code summarizes the conversation history to fit the context window. As of v2.1.198, the summarization request inherits your session’s extended thinking configuration, so it reasons with thinking enabled when your session has it enabled and stays off otherwise. Thinking affects only how the summary is produced; your session settings are unchanged afterward. What happens to each kind of content depends on how it was loaded:
Path-scoped rules and nested CLAUDE.md files load into message history when their trigger file is read, so compaction summarizes them away with everything else. Right after compaction, Claude Code re-reads up to five of the files Claude has read or edited in the session, choosing the ones modified most recently, and reloads the rules and nested CLAUDE.md files that apply to those files. A file over 5,000 tokens comes back as a path reference without its content, shown as
Referenced file instead of Read. Its rules still reload. If a rule must persist across compaction, drop the paths: frontmatter or move it to the project-root CLAUDE.md.
Skill bodies are re-injected after compaction, but large skills are truncated to fit the per-skill cap, and the oldest invoked skills are dropped once the total budget is exceeded. Truncation keeps the start of the file, so put the most important instructions near the top of SKILL.md.
When your context fills up
Claude Code compacts automatically as you approach the limit, so a full context window doesn’t end your session. The automatic pass works the same way as the/compact step in the timeline. See When context fills up for what it preserves.
You can also act before the automatic pass runs:
- Compact with a focus: run
/compactwith instructions, like/compact focus on the auth bug fix, before starting a long new task. The summary keeps what you choose instead of what the automatic pass guesses is important. - Compact part of the conversation: run
/rewind, select a message, and choose Summarize from here or Summarize up to here. See Rewind and summarize for what each option keeps and how to guide the summary. - Compact earlier: run
/autocompactwith a token count, like/autocompact 500k, to set how full the context window gets before the automatic pass runs. See Set the auto-compact window for accepted values and overrides. - Clear between tasks: run
/clearwhen switching to unrelated work. Old conversation crowds out the files you need next and costs tokens on every message. - Delegate large reads: send research to a subagent so the file contents stay in its context window, not yours.
[1m] model variant. Compaction works the same way at the larger limit.
Sonnet 5 runs with the 1M context window and has no [1m] variant to select. See Sonnet 5 context window for its auto-compaction thresholds and the LLM gateway exception.
The point where automatic compaction runs depends on your model and configuration. See Default auto-compact thresholds for the boundaries per model, and Correct the window for a gateway or custom model ID if Claude Code assumes the wrong window for your model ID, such as an LLM gateway alias.
Check your own session
The visualization uses representative numbers. To see your actual context usage at any point, run/context for a live breakdown by category with optimization suggestions, including which CLAUDE.md and auto memory files loaded. Run /memory to open and edit those files.
Related resources
For deeper coverage of the features shown in the timeline, see these pages:- Extend Claude Code: when to use CLAUDE.md vs skills vs rules vs hooks vs MCP
- Store instructions and memories: CLAUDE.md hierarchy and auto memory
- Subagents: delegate research to a separate context window
- Best practices: managing context as your primary constraint
- Prompt caching: which actions invalidate the cached prefix
- Reduce token usage: strategies for keeping context usage low