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.

Claude Code /context dashboard showing 21k of 200k tokens used (11 percent) with the colored usage grid, the estimated usage breakdown by category including Skills and Messages, Free space and the 33k token AutoCompact buffer
The /context dashboard in Claude Code: a colored grid, a per-category token breakdown, and the reserve set aside for automatic compaction.

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. 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.

    Claude Code explainer graphic showing a context window grid with a few database icons marked Taken in red and the rest Available, illustrating that the context window is a finite amount of working memory
    The official explainer: part of the window is already Taken, the rest is still Available.Watch at 0:32
  2. 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.

    Claude Code session listing security review issues while Reading 1 file src/routes/auth.ts and showing a Sublimating status line, the moment file reads and tool call results are being added onto the context window
    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. 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.

    Claude Code /context dashboard reporting 21k of 200k tokens used (11%) with an estimated usage breakdown by System prompt, System tools, Custom agents, Skills, Messages, Free space and a 33k token AutoCompact buffer
    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.

  1. 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.

    Claude Code showing the Compacting conversation status above an empty input box while accept edits mode is on, the moment automatic compaction summarizes important details and clears older tool results near the context limit
    "Compacting conversation…" — the automatic summary pass running on its own.Watch at 0:44
  2. 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.

    Typing the /compact slash command into the Claude Code input box beneath the Custom agents and Skills token usage list to manually compact everything done so far in the session
    /compact typed in the input box; the summary pass starts immediately.Watch at 1:04
  3. 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.

    Claude Code compacted conversation transcript showing Current Work and Optional Next Step sections plus the full transcript .jsonl path to read exact code snippets and error messages from before compaction
    The post-compaction summary, with the full transcript saved as a .jsonl file.Watch at 0:52
  4. 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.

    Claude Code after compaction showing Conversation compacted (ctrl+o for history), a /compact summary listing the files that were read, and a What still needs to be done? prompt to continue the feature
    "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.

  1. 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.

    Claude Code slash command menu opened by typing a forward slash, showing the descriptions for /context, /resume, /clear and /compact including Clear conversation history but keep a summary in context
    The command descriptions spell out the difference: summary kept vs wiped.Watch at 1:24
  2. 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.

    Claude Code v2.1.72 welcome screen immediately after running /clear, showing (no content) under the command and No recent activity in the session panel, a context window starting from scratch
    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.

  1. 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 project memory file opened in Claude Code listing Backend and Frontend npm commands plus Architecture headings, the file where facts worth remembering across sessions live so Claude does not rediscover them
    CLAUDE.md carrying the project's commands and architecture notes across sessions.Watch at 2:02
  2. 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.

    Claude Code /context output listing dozens of loaded Slack and Notion MCP tools with a code-reviewer custom agent below, showing how MCP servers load all of their tools into context by default
    Every loaded MCP tool occupies context whether or not you use it.Watch at 2:28
  3. 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.

    Claude Code explainer diagram contrasting a SKILL.md file with CLAUDE.md, the pattern where skills stay on disk and are loaded on demand instead of putting everything into the context window
    SKILL.md vs CLAUDE.md: load on demand instead of always in context.Watch at 2:43
  4. 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.

    Claude Code spawning the code-reviewer subagent with the prompt Spawn the code reviewer subagent to review the code we last created while a Bash git diff HEAD~1 HEAD runs in its separate context window
    "Spawn the code reviewer subagent…" — the review runs in its own window.Watch at 2:52

Frequently asked questions