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, which both go into the system prompt the same way. - 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 your instructions depends on how they were 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. They reload the next time Claude reads a matching file. 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 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. Sonnet 5 runs at 1M with no [1m] variant to select; see Sonnet 5 context window for its auto-compaction thresholds and the LLM gateway exception. Compaction works the same way at the larger limit.
Set the auto-compact window
The auto-compact window is how full the context window can get before Claude Code compacts the conversation. You can set it in three places:- For this session and later ones: run
/autocompactwith a value, like/autocompact 500k. Claude Code saves it to your user settings asautoCompactWindowand applies it to the current session; if a higher-priority settings scope such as managed settings sets the key, the command saves your value but the session keeps that scope’s window, and the command says so. Run/autocompact autoto return to the window tuned for your model. - For one launch: pass
--autocompactwhen starting Claude Code. The flag overrides your saved setting for that launch without changing it, andclaude --autocompact autoruns the session at the tuned window even if your saved setting has a value. Unlike/autocompact, the flag isn’t preempted by a higher-priority settings scope such as managed settings. - In scripts and cloud environments: set
CLAUDE_CODE_AUTO_COMPACT_WINDOW. While it’s set, it takes precedence over the command, the flag, and the setting, and/autocompactreports the override instead of changing the window.
- A plain token count, such as
200000 - A
korMsuffix, such as500kor1M - A bare number from 100 to 1000, meaning thousands, so
200sets 200,000
- Cloud sessions compact as the conversation approaches the model’s limit
- Sonnet 4.6 and Opus 4.6 without extended context compact at the 200K boundary, and so do Opus 4.8 and Opus 5 when they run with a 200K context window, such as on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry
- Sonnet 5 compacts at the model’s default threshold
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