Skip to main content
Core concepts
Explore the context window
An interactive simulation of how Claude Code’s context window fills during a session. See what loads automatically, what each file read costs, and when rules and hooks fire.
Claude Code’s context window holds everything Claude knows about your session: your instructions, the files it reads, its own responses, and content that never appears in your terminal. The timeline below walks through what loads and when. See the written breakdown for the same content as a list.
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
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. What happens to your instructions depends on how they were loaded: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.
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. Run /memory to check which CLAUDE.md and auto memory files loaded at startup.
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
- Reduce token usage: strategies for keeping context usage low
