Context management guide
Claude Code context management: /compact, /clear and reading your context meter
What fills the context window, when automatic compaction fires, what survives it, and the habits — CLAUDE.md, MCP pruning, skills, subagents — that keep Claude Code fast and focused.

An illustrated walkthrough of 13 steps - about 5 minutes to read. Every step links back to the exact moment in the source video.
TL;DR
Everything you type, every file Claude reads and every tool result lands in the context window. Run /context to see what is using it. Near the limit, Claude Code compacts automatically — summarize, keep the essentials, drop the rest — but you can run /compact yourself at a moment you choose. Switching to a new task? /clear wipes everything instead. Long-term facts go in CLAUDE.md, MCP tools you don't need get turned off, and work you only need the answer for goes to a subagent.
Source video
This page follows the Claude team's official screen recording and rebuilds its context-management workflow one frame at a time. Every screenshot links to the exact moment it appears.
Screenshots are frames from the official Claude channel video, credited to its creators; the write-up is our own. Steps verified against the video and the Claude Code docs in September 2026.
What the context window is and how it fills up
Context is Claude's working memory — and every prompt, file read and tool result takes a bite out of it.
- 1
Think of it as a finite window
The context window is the amount of space Claude can hold in its memory while it works on your project. There is only a finite amount that fits, which is why optimizing what goes in matters so much.

The official explainer: part of the window is already Taken, the rest is still Available.Watch at 0:32 - 2
Everything Claude does adds to it
Whenever you enter a prompt, Claude reads a file, runs a tool call, and gets a tool call result back — and each of those is added onto the context window. A single review turn, like the security issues listed here plus the file it reads, is already measurable context.

A review in progress: the issue list, the file read and the status line are all in the window now.Watch at 0:22 - 3
Check the meter with /context
Run the /context command for a big picture of your context size. You get a colored grid, the total used — 21k of 200k tokens, 11% here — and a per-category breakdown: system prompt, system tools, custom agents, skills, messages, plus the free space and the reserve held back for the automatic compaction.

21k of 200k tokens (11%) with the AutoCompact buffer set aside at 16.5%.Watch at 1:32
Autocompact and manual /compact
When the window runs out, Claude Code summarizes it. You can trigger the same cleanup yourself with /compact.
- 4
Autocompact fires near the limit
As you approach the limit, the context window is compacted automatically: important details are summarized, unnecessary tool call results are removed, and a lot of space is freed. One caveat from the video — compaction can potentially lose details from earlier in the conversation.

"Compacting conversation…" — the automatic summary pass running on its own.Watch at 0:44 - 5
Compact manually with /compact
You can run the compaction yourself with the /compact command. It compacts everything you have done up to that point — handy when you want to clear up context space but also keep a memory of what you previously worked on. Choosing the moment yourself beats being surprised by autocompact mid-task.

/compact typed in the input box; the summary pass starts immediately.Watch at 1:04 - 6
What compaction keeps
After compacting, the transcript keeps a summary of where things stand: a Current Work section, an Optional Next Step, and a pointer to the full transcript .jsonl file on disk in case you need exact code snippets or error messages from before the compaction.

The post-compaction summary, with the full transcript saved as a .jsonl file.Watch at 0:52 - 7
Continue on the summarized thread
The session continues right after the summary: "Conversation compacted (ctrl+o for history)", a compact block listing what was read, and Claude immediately asking what still needs to be done — the feature keeps its momentum without the dead weight of old tool results.

"What still needs to be done?" — the same feature, a lighter window.Watch at 1:46
When to clear instead
A new feature deserves a blank slate — old context only biases the new work.
- 8
Two commands, two intents
The slash menu states the difference plainly: /compact clears conversation history but keeps a summary in context, while /clear frees up context outright. The video's rule of thumb: still working on the same feature and going over the window? Compact. Finished and starting something new? Clear, so the old conversation can't bias the new work.

The command descriptions spell out the difference: summary kept vs wiped.Watch at 1:24 - 9
/clear starts you from scratch
Run /clear and everything is removed — the session drops back to the welcome screen with no content and no recent activity. Nothing from the previous conversation leaks into whatever you build next.

Right after /clear: no content, no recent activity, a blank window.Watch at 1:54
Habits that keep context small
CLAUDE.md for memory, fewer MCP tools, skills on demand, and subagents for the journeys you don't need to keep.
- 10
Park long-term memory in CLAUDE.md
For things you do want Claude to remember in other sessions, put them in the CLAUDE.md file — project commands, conventions, architecture notes. That way it doesn't have to rediscover them from scratch every session, and the knowledge doesn't depend on the conversation history surviving a compaction.

CLAUDE.md carrying the project's commands and architecture notes across sessions.Watch at 2:02 - 11
Prune MCP servers you don't need
MCP servers load all of their tools into context by default — this audit shows page after page of loaded Slack and Notion tools. If you have MCP servers unrelated to the project, turning them off is one of the cheapest context wins available.

Every loaded MCP tool occupies context whether or not you use it.Watch at 2:28 - 12
Prefer skills over always-on tools
Skills work similarly to MCP servers but don't put the entire thing into context — the SKILL.md file stays on disk until the skill is actually needed. Moving repeatable workflows from always-loaded tools into skills saves window space for the work itself.

SKILL.md vs CLAUDE.md: load on demand instead of always in context.Watch at 2:43 - 13
Send journeys to a subagent
Subagents run with a completely separate context window and return just a summary to your main agent. For tasks where you only need the answer — "where are the authentication endpoints?" — let the subagent do the digging so the exploration never pollutes your main conversation.

"Spawn the code reviewer subagent…" — the review runs in its own window.Watch at 2:52