CC
0 XP
0

Chapter 5: Context & Token Mastery

Monitoring Usage

build3 min

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:

Terminal
$/cost

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:

Terminal
$/context

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.

  1. Open Claude Code in your todo-app directory
  2. Have a short conversation -- ask Claude Code to explain one of your components (e.g., "What does the TodoList component do?")
  3. Run /cost to see what that conversation cost
  4. Run /context to see what's consuming context space
  5. Run /compact to summarize and trim the conversation
  6. Run /context again -- notice how the context usage dropped
💡Info

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 readsReading large files (500+ lines)
Quick editsLong multi-step conversations
Running focused commandsVerbose build/test output
Tip

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.