Reading the budget and spending it — /context, /compact, /clear, /btw
By the end you can
- Run /context and act on what it reports rather than guessing at usage
- Choose between /clear, /compact and /compact with instructions on purpose
- State what reloads itself after compaction and what is summarised away
- Use /btw for a question that should not join the conversation
- Know that compacting a large window is itself a large request and clearing is free
Lesson 3.1 argued that the window is a budget. This one is the instrument panel and the three levers, and the order matters: read first, then choose.
Read it: /context
The documented description is exact about what you get:
Visualize current context usage as a colored grid. Shows optimization suggestions for context-heavy tools, memory bloat, and capacity warnings. — Commands
It takes an optional [all] argument. It reports the session you are actually
in — which CLAUDE.md files loaded, which auto memory, what each tool listing
costs — rather than the representative figures from the last lesson.
Two documented uses beyond curiosity. First, /context is how you confirm your
CLAUDE.md actually loaded — the best-practices guide recommends it for exactly
that. Second, it is how you find MCP servers you are paying for and not using;
the costs guide points you at /context to see what is consuming space, and at
/mcp to disable servers you are not actively using.
The three levers, and what each one costs
| Lever | What it does | What it costs |
|---|---|---|
/clear [name] | Starts a new conversation with empty context | Nothing |
/compact [instructions] | Replaces history with a summary | A request over the whole history |
/btw <question> | Answers a side question outside the conversation | The answer never enters history |
That cost column is the part people get backwards. Compaction is not a cheap tidy-up:
/compactreads the conversation it summarizes, so compacting a large context is itself a large request. When you want a fresh start instead of continuity,/clearcosts nothing. — Manage costs effectively
So the choice between them is not "which frees more space". It is whether you need continuity at all. If the next task has nothing to do with the last one, compacting is paying a large request to carry forward a summary you are about to ignore. Clear instead.
/compact, and why the bare form wastes the lever
/compact takes optional focus instructions, and the documentation is direct
about what that buys:
The summary keeps what you choose instead of what the automatic pass guesses is important. — Context window
/compact focus on the auth bug fixThe useful habit is to compact before a long new task inside the same workstream, with instructions naming what the next stretch will need — not after you have already noticed things going wrong.
You can also set this once per project rather than per compaction, by putting a
section in your CLAUDE.md:
# Compact instructions
When you are using compact, please focus on test output and code changesWhat survives compaction
Compaction does not simply delete the old conversation; different kinds of content are handled differently (Context window):
| Mechanism | After compaction |
|---|---|
| System prompt and output style | Unchanged; never part of message history |
Project-root CLAUDE.md and unscoped rules | Re-injected from disk |
| Auto memory | Re-injected from disk |
| The plan Claude wrote in plan mode | Re-injected from disk |
Rules with paths: frontmatter | Reloaded as Claude reads files they match |
Nested CLAUDE.md in subdirectories | Reloaded as Claude reads files in that subdirectory |
| Files Claude read or edited | Re-read, up to five, most recently modified first |
| Invoked skill bodies | Re-injected, capped per skill and in total; oldest dropped first |
| Context a hook added earlier | Summarised with the rest of the conversation |
Read the two halves. Anything that lives on disk comes back, because Claude Code can simply read it again. Anything that existed only in the conversation — your explanations, the reasoning, a correction you made, output a hook injected — is summarised, which is to say compressed with loss.
Three consequences worth carrying:
- A constraint you stated in chat is fragile; a constraint in
CLAUDE.mdis not. If it must survive, write it down somewhere on disk. - A rule with
paths:frontmatter is summarised away and only returns when a matching file is read again. The docs say plainly: if a rule must persist across compaction, drop thepaths:frontmatter or move it to the project-rootCLAUDE.md. - Only five files come back, most recently modified first — and a file over 5,000 tokens returns as a path reference rather than its contents.
/btw, the lever nobody uses
Ask a side question about the current session without adding to the conversation. — Commands
The answer never enters conversation history, so you can check a detail without growing context. This is the right tool for "wait, what was that file called?" or "what version are we pinned to?" — questions whose answers you need once and which would otherwise sit in the window for the rest of the session, being re-sent with every subsequent message.
Put the question on the same line. Running /btw bare reopens your most recent
side answer, and Left steps back through earlier ones; if you have not asked
anything yet, it prints a usage line. Before v2.1.212 that usage line was all
the bare form ever did, because /btw required a question.
Choosing, as a decision rather than a habit
| Situation | Reach for |
|---|---|
| Next task is unrelated to this one | /clear |
| Same workstream, long stretch ahead, history is getting heavy | /compact <what the next stretch needs> |
| You need one fact and do not want it in the window | /btw |
| You want the window smaller before the automatic pass decides for you | /compact with instructions |
| You have corrected the same mistake twice | /clear, and a better opening prompt |
That last row is Lesson 3.3 and 3.4, and it is the one that changes how sessions actually feel.
Checkpoint
-
You are 90 minutes into a refactor and about to start a long, related implementation stretch.
/clearor/compact, and why?Show answerAnswer
/compact, with instructions. The choice between the two levers is not "which frees more space" — it is whether you need continuity at all, and here the next stretch is the same workstream, so the last 90 minutes are worth carrying forward.Do not run it bare. Name what the next stretch will need, as in
/compact focus on the auth bug fix, so the summary keeps what you choose instead of what the automatic pass guesses is important. And run it now, before the long task — the useful habit is compacting ahead of a long stretch, not after you have already noticed things going wrong./clearwould be the right lever only if the next task had nothing to do with this one. -
You wrote "never touch the generated files" in chat an hour ago, and the session has since compacted. Is that instruction still reliably in context? Where should it have lived?
Show answerAnswer
No. Anything that existed only in the conversation — your explanations, the reasoning, a correction you made — is summarised, which is to say compressed with loss. Only what lives on disk is re-injected after compaction: the project-root
CLAUDE.md, unscoped rules, auto memory, and the plan Claude wrote in plan mode.It should have lived in the project-root
CLAUDE.md. A constraint stated in chat is fragile; a constraint on disk is not. Watch the near-miss version as well: a rule withpaths:frontmatter is summarised away too and only returns when a matching file is read again, so the docs say to drop thepaths:frontmatter or move the rule to the project-rootCLAUDE.mdif it must survive compaction. -
Which of the three levers costs a request proportional to the size of the conversation, and which costs nothing at all?
Show answerAnswer
/compactcosts the request;/clearcosts nothing./compactreads the conversation it summarizes, so compacting a large context is itself a large request, while/clearsimply starts a new conversation with empty context.That is the pair people get backwards — compaction reads like the cheap tidy-up and clearing like the drastic step, and it is the other way round. The third lever,
/btw, sits outside the comparison: its answer never enters conversation history, so it does not grow the window at all.