
Run /context Before Your Claude Code Session Hits the Token Wall — Then Choose Between /compact and /clear
Chris Harper
2 min read
Aug 3, 2026 · 20:09 UTC
/context prints a live breakdown of your Claude Code session's token usage — the fastest way to catch a bloating context before each turn's cost compounds to 5× what it was an hour ago.
Claude Code's context window starts at 200k tokens. What's in it matters for both cost and quality: a session starts lean (system prompt + CLAUDE.md ≈ 6k tokens), but each file read adds 1–2k tokens, MCP servers can add 40k+, and conversation history compounds fast. By the time you feel the session slowing down, you're often deep into the expensive zone.
Run /context to see the breakdown:
/context
The output groups usage by category — system prompt, CLAUDE.md rules, loaded files, MCP servers, and conversation history. The MCP server line is frequently the biggest surprise: a server with broad tool schemas can add 30–50k tokens before any work begins.
After you see the breakdown, two commands respond to it:
/compact— replaces conversation history with a structured summary, typically cutting 60–80% of accumulated context. Key decisions, code changes, and file states carry over. Use this for ongoing work where you want to continue the same session./clear— wipes conversation history entirely. Context returns to near-zero. Better for task-switching or when the current thread is irrelevant to what comes next.
The cost math is the reason this matters. At Sonnet 5's current pricing ($3/MTok input), a turn at 150k context costs roughly $0.45; the same turn at 30k after compaction costs $0.06. Over a two-hour session of 100 turns, that's the difference between $45 and $6 in input costs alone.
Practical rule: run /context after heavy file reads (initial project exploration, test suite loads), when you switch sub-tasks, and before any loop that will repeat many turns. If MCP servers dominate the breakdown, consider /clear and reconnecting only the servers you need for the current task.
The cheapest time to compact is earlier than you think — before the session visibly slows. Make /context part of your session hygiene.
Sources: Claude Code Context Management — claudefa.st · Claude Code Context Window — Unblocked · Compaction — Claude Platform Docs