← Claude for Real Work

Context is the bill

Lesson 16 of 28 · 12 min · Updated

The context window is the fixed amount of room Claude has to hold your conversation in. Everything competes for it: the system prompt, your CLAUDE.md, the tool definitions, every file it has read, every command’s output, and every message either of you has sent.

Two things follow, and the second one is the one people miss. It costs money, because the whole conversation is re-sent on every turn. And it costs quality, because a session that has read forty files has forty files’ worth of noise between your question and the part of the code that answers it.

Long sessions get expensive and they also get worse.

Look at your own

claude -p "/context"
## Context Usage

**Model:** claude-opus-5[1m]
**Tokens:** 25.0k / 1m (2%)

### Estimated usage by category

| Category                | Tokens | Percentage |
|-------------------------|--------|------------|
| System prompt           | 3.7k   | 0.4%       |
| System tools            | 18.8k  | 1.9%       |
| System tools (deferred) | 14.9k  | 1.5%       |
| Memory files            | 104    | 0.0%       |
| Skills                  | 2.5k   | 0.2%       |
| Messages                | 8      | 0.0%       |
| Free space              | 974.9k | 97.5%      |

Your numbers will be different. The window size depends on which model you are on, and the categories depend on what you have installed. What is worth noticing is that 25,000 tokens were spent before you typed anything, and that the Messages row is where your actual conversation lives.

/context also lists which memory files loaded and what each skill costs. It is the diagnostic for “why is my session behaving oddly”, and almost nobody runs it.

Where it goes

The big consumers, in the order they will surprise you:

File reads. By far the largest. A session that has read src/reports/index.ts twice is carrying it twice. Reading a 2,000-line file to change four lines in it costs you the whole file.

Command output. npm test in stockroom prints about a hundred lines. A test run that fails noisily can be larger than the file you were debugging.

Your own conversation. Every turn carries every previous turn.

Everything installed. Tool definitions, skill descriptions, MCP servers. This is fixed per session, and it is why /context sometimes shows a surprising number before you start.

The two commands

/clear throws the conversation away and starts fresh. Same directory, same CLAUDE.md, nothing else. Use it when you finish a task and start an unrelated one, which is more often than most people do it. There is no cost to clearing and there is a real cost to not clearing: the fifty turns about the pagination bug are still being paid for while you ask about hooks.

/compact replaces the conversation with a summary of itself. The session continues and remembers roughly what happened, in far fewer tokens. It runs automatically as you approach the limit, so you will meet it whether or not you ask for it.

Compact deliberately rather than waiting:

/compact focus on the paginate fix and what is still failing

The automatic pass guesses what mattered. When you say, it keeps that.

There is a third worth knowing: /autocompact 500k sets how full the window gets before the automatic pass fires. Useful if you keep getting compacted in the middle of something.

What survives a compact?

This is the part that catches people out, because “it forgot” is usually one of these:

WhatAfter compaction
System promptUnchanged
Project-root CLAUDE.mdRe-read from disk
Auto memoryRe-read from disk
A nested CLAUDE.md in a subdirectoryGone until a file there is read again
A rule with paths: frontmatterGone until a matching file is read again
Something you only said in the chatSummarised, which is not the same thing

The last row is the one that bites. “Always use stocktake, never count” typed into the conversation survives as a sentence in a summary, if it survives at all. The same line in CLAUDE.md is re-read from disk every time. That is the practical argument for lesson 15’s file: not that it saves typing, but that it is the only instruction that cannot be compacted away.

Habits that help

/clear between tasks. The single highest-value habit in this lesson and the easiest to skip.

Point at files instead of asking it to search. @src/util/paginate.ts reads one file. “Find where paging happens” might read nine.

Ask for the change, not the tour. “Explain the reports module, then fix the off-by-one” reads the whole module. “Fix the off-by-one in paginate” reads one file.

Send big reads to a subagent. A subagent has its own window, so the files it reads stay out of yours and only its answer comes back. Lesson 22.

Let a failed session go. Six turns of a fix not working means the context now contains six wrong approaches, and each one makes the seventh attempt slightly worse. /clear, then start again with what you learned.

Watch out for the version of this that is superstition. You do not need to run /compact every ten minutes, and clearing a session that is at 4% costs you the context and buys you nothing. Run /context. If Free space is comfortable, carry on working.

Your turn

In a stockroom clone, measure the cost of a bad question.

claude -p "/context" < /dev/null | grep -E "Tokens:|Messages|Free space"

Note the number. Then, in one session, ask for the tour before the fix:

Explain every file in src/, then tell me what paginate does.

Run /context again in that same session and compare. Then start a fresh session and ask the narrow version instead:

@src/util/paginate.ts What does this do?

Check: the Messages row after the broad question is several times larger than after the narrow one, and both answers about paginate are equally correct. You paid the difference for nothing. If the two numbers are close, the broad question got lazy and did not read what it said it would, which is its own thing to know.

Recap

Context is money and it is also quality. A crowded session answers worse as well as dearer. /context shows you where it went, /clear throws away a finished conversation, and /compact summarises one you still need, better if you tell it what to keep.

Project-root CLAUDE.md and auto memory are re-read from disk after a compact. Nested memory files, path-scoped rules and anything you only said out loud are not, which is why the instruction that matters belongs in a file.

Narrow questions cost less and answer better. That is the rare case where the cheap thing is also the good thing.

Next: the other dial, which is which model is answering and how hard it is trying.