Chapter 5: Context & Token Mastery
Monitoring Usage
Monitoring Usage
You can't manage what you can't measure. Claude Code gives you built-in tools to monitor exactly how much context and money each session uses.
The /cost command
The simplest way to check your session spend:
This shows you:
- Total session cost in USD
- Session duration
- Lines of code changed
It's a quick snapshot of what the current conversation has cost you so far.
The /context command
Want to know what's consuming your context window? This command breaks it down:
You'll see a breakdown of what's using space in your context window -- how much is taken up by the conversation history, file reads, and system overhead.
Try it now
Let's see these tools in action with your todo app.
- Open Claude Code in your todo-app directory
- Have a short conversation -- ask Claude Code to explain one of your components (e.g., "What does the TodoList component do?")
- Run
/costto see what that conversation cost - Run
/contextto see what's consuming context space - Run
/compactto summarize and trim the conversation - Run
/contextagain -- notice how the context usage dropped
The difference between steps 4 and 6 shows you exactly what /compact does. It keeps the important context (what you're working on, what files exist) while trimming the verbose history (full file contents, lengthy explanations).
Building your intuition
With practice, you'll develop a feel for what's expensive and what's cheap:
| Cheap (low tokens) | Expensive (high tokens) |
|---|---|
| Short, specific questions | "Explain this entire codebase" |
| Targeted file reads | Reading large files (500+ lines) |
| Quick edits | Long multi-step conversations |
| Running focused commands | Verbose build/test output |
Get in the habit of checking /cost at the end of each session. You'll quickly develop intuition for which tasks are expensive (large file reads, long conversations) and which are cheap (quick edits, short questions).
The feedback loop
Monitoring usage creates a virtuous cycle: you check costs, you notice which habits are expensive, you adjust, and your sessions get more efficient over time. Most developers find their per-session cost drops significantly after the first week of active monitoring.