How to Track and Reduce Claude Code Token Usage

Published 9 min read

Run /usage to see your session's token usage and estimated cost, then lower it by clearing context between tasks, choosing a smaller model where the task allows, keeping CLAUDE.md short and limiting what subagents run on. Token cost scales with context size: the more context Claude processes, the more tokens you use.

This guide covers how to measure usage (built-in and local tools), why usage climbs, and a checklist of changes ordered by impact. It is part of the Claude Code monitoring hub. For seeing agents live, read how to monitor Claude Code agents.

Step 1: Measure before you change anything

Run /usage

At the Claude Code prompt, run /usage and look under Session. A typical block shows:

Estimated cost:        $0.55
Total duration (API):  6m 20s
Total duration (wall): 6h 33m 10s
Usage by model:
   claude-sonnet-4-6:  1.2k input, 5.3k output, 940.0k cache read, 50.0k cache write ($0.55)

Three facts to know:

  • The dollar figure is computed locally from token counts at list price, so it is an estimate, not an invoice.
  • Totals reset when /clear starts a new session.
  • On Pro, Max, Ultra, Team and Enterprise plans, usage is included in the subscription, so the session cost is not what you are billed. These plans also see a plan usage breakdown.

Read the plan usage breakdown

On subscription plans, /usage attributes recent usage to skills, subagents, plugins and individual MCP servers as percentages. Press d or w to switch between the last 24 hours and the last 7 days. It also lists recommendations, one per row, for behaviors behind 10% or more of your recent usage. A row such as Trim ~/code/api/CLAUDE.md ยท 49k tokens per request tells you the share of usage the change applies to, not how much it saves.

The figures are approximate and computed from local session history on this machine. Usage from other devices or claude.ai is not included.

Watch it continuously with the status line

The status line script receives JSON on stdin with cost.total_cost_usd, context_window.used_percentage and rate_limits.five_hour.used_percentage, among other fields. Type /statusline plus a description to generate one:

/statusline show model, context percentage and session cost

Claude Code saves the script in ~/.claude/ and adds a statusLine entry to your settings.

Find what fills the context

Run /context to see what is consuming space, and /mcp to see configured MCP servers. For a report on how you work rather than raw tokens, run /insights, which writes an HTML report to ~/.claude/usage-data/report.html. Note that /insights itself uses tokens.

Track agents and tokens per task with a local tool

The built-in views give totals. To see tokens per subagent task as it runs, a local dashboard can read the session transcripts. Agent Office shows task tokens in the hover popup and the Activity view, session tokens on each mission card, and all-time tokens per agent in the Directory. It counts input, cache creation, cache read and output tokens per assistant message and skips duplicates.

Limits to keep in mind:

  • Agent Office shows token counts only, never dollars.
  • Per-session and per-task figures start when the service starts. Per-agent totals are all-time on this PC and include a one-time background scan of older subagent logs.
  • Main-session tokens count in session totals but are not credited to an agent.
  • The counts are approximate and carry no accuracy guarantee. Compare them with /usage when exact numbers matter.

Install steps are in the setup guide, and you can open the Office once the service runs.

Step 2: Understand why usage climbs

A session open for hours can use far more of your plan than your activity suggests. The official costs page lists these causes:

  • Long context. Claude Code sends the full conversation with every request. Prompt caching re-reads that history at the cached token rate, but a one-line question still draws usage for the whole conversation.
  • Cache misses. Your first message after a break longer than the cache lifetime reprocesses your full context.
  • Scheduled tasks. A session-scoped scheduled task fires on its interval even while the session is idle, sending the full context each time.
  • Subagents and workflows. Every subagent sends its own requests on top of the main conversation's.
  • Agent teammates. Each active teammate keeps consuming tokens until it exits.
  • Compaction. /compact reads the conversation it summarizes, so compacting a large context is itself a large request.

Extended thinking also adds output tokens. Thinking tokens are billed as output, and the default budget can be tens of thousands of tokens per request depending on the model.

Step 3: Reduce usage, in order of impact

1. Clear between unrelated tasks

Run /clear when you switch to unrelated work. Stale context wastes tokens on every later message. Use /rename first so you can find the session later, then /resume to return to it. Clearing costs nothing.

2. Compact with instructions

Run /compact Focus on code samples and API usage to tell Claude what to keep. You can also add a section to your project CLAUDE.md:

# Compact instructions

When you are using compact, please focus on test output and code changes

3. Choose the right model

Sonnet handles most coding tasks and costs less than Opus. Reserve Opus for complex architectural decisions or multi-step reasoning. Use /model to switch mid-session, or set a default in /config. A switch to Opus also applies to subagents that inherit your session's model.

4. Set a cheaper model on simple subagents

The model field in a subagent file accepts the aliases sonnet, opus, haiku and fable, a full model ID, or inherit. If you omit it, the subagent uses the main conversation's model. Claude Code resolves the model in this order:

  1. The per-invocation model parameter Claude passes when it starts the subagent (an alias only).
  2. The model field in the subagent's definition.
  3. The CLAUDE_CODE_SUBAGENT_MODEL environment variable.
  4. The main conversation's model.

Example file ~/.claude/agents/log-scanner.md:

---
name: log-scanner
description: Scans test and build logs and reports only the failing lines. Use after running tests.
model: haiku
---

Read the log you are given. Return only failing test names and the first error line for each.

To force one model onto every subagent (Claude Code v2.1.257 or later), set both variables in settings.json:

{
  "env": {
    "CLAUDE_CODE_SUBAGENT_MODEL": "haiku",
    "CLAUDE_CODE_SUBAGENT_MODEL_FORCE": "1"
  }
}

While the force variable is on, Claude Code ignores each definition's model field. Test that your subagents still do the job well on the smaller model before you force it.

5. Delegate noisy work to subagents

Running tests, fetching documentation and processing logs can fill your context. A subagent keeps that output in its own context window and returns only a summary. The subagent's requests still draw on your usage, so pair this with a smaller model.

6. Keep CLAUDE.md short and move workflows into skills

CLAUDE.md loads at the start of every session. Detailed instructions for specific workflows, such as PR reviews or migrations, cost tokens even when you do unrelated work. Skills load on demand, so move specialized instructions there. The costs page suggests keeping CLAUDE.md under 200 lines.

7. Disable unused MCP servers

MCP tool definitions are deferred by default, so only names and server instructions enter context until a tool is used. Still, run /mcp and disable servers you are not using. CLI tools such as gh, aws and gcloud add no per-tool listing.

8. Lower effort for simple tasks

Use /effort or /model to lower the effort level, or disable thinking in /config on models that allow it. Some current models always use extended thinking. On models with a fixed thinking budget you can set MAX_THINKING_TOKENS, for example MAX_THINKING_TOKENS=8000.

9. Trim tool output with a hook

A PreToolUse hook can rewrite a command before it runs. The costs page shows a hook that pipes test runner output through tail -n 100, so Claude reads the last 100 lines instead of thousands. Verify it with /hooks.

10. Write specific prompts and use plan mode

"Add input validation to the login function in auth.ts" costs less than "improve this codebase". Press Shift+Tab to cycle to plan mode for complex work, press Escape to stop a wrong direction early, and use /rewind to return to a checkpoint.

Step 4: Control multi-agent cost

  • Agent teams are disabled by default (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 enables them). Each teammate has its own context window, so tokens scale with team size and runtime. The costs page states agent teams use approximately 7x more tokens than standard sessions when teammates run in plan mode. Use Sonnet for teammates, keep teams small and shut teammates down when done.
  • Several parallel sessions each carry their own context. Check which ones are still running before you start another.
  • Loops and scheduled tasks keep spending while you are away. /usage lists the heaviest ones.

Spending limits

Your setupWhere to see spendHow to cap it
Pro, Max or Ultra/usage, Settings > Usage on claude.aiMonthly spend limit for usage credits
Team or EnterpriseSpend report in org analyticsAdmin spend limits per organization, group or member
Claude Console (API)Console Cost pageWorkspace spend limits
Bedrock, Google Cloud or FoundryYour cloud billing consoleYour cloud's budget controls

For the session itself, the CLI flag --max-budget-usd counts the session cost figure.

Checklist

  1. Run /usage and note the biggest line.
  2. /clear between unrelated tasks.
  3. Default to Sonnet; use Opus on purpose.
  4. Add model: haiku to simple subagents.
  5. Keep CLAUDE.md under about 200 lines.
  6. Disable unused MCP servers.
  7. Stop idle loops and finished teammates.
  8. Review per-agent token use weekly in a tool such as Agent Office.

Frequently asked questions

How do I see token usage in Claude Code?

Run /usage and read the Session heading for tokens by model and an estimated cost. Add a status line to see context and cost continuously, or run /context to see what fills your context window.

Is /usage accurate?

It is an estimate. Claude Code computes the dollar figure locally from token counts at list price, and the plan breakdown is computed from local history on this machine, so other devices and claude.ai are not included. For billing, use your account or Console reports.

Why do subagents use more tokens?

Each subagent starts with its own fresh context window and sends its own requests on top of the main conversation's, so they draw on your usage even though only a summary returns. They help keep your main context small, but they are not free.

Does a Max plan show cost?

Pro, Max and Ultra subscribers have usage included, so the session cost figure is not relevant for billing. They see plan usage bars, activity stats and an attribution breakdown instead.

How do I lower Claude Code usage?

Run /clear between unrelated tasks, pick Sonnet instead of Opus when the task allows, set model: haiku on simple subagents, keep CLAUDE.md short, disable unused MCP servers and write specific prompts.

Can I set a spending limit?

On Pro, Max and Ultra you can set a monthly spend limit for usage credits. Team and Enterprise admins set limits in admin settings, and API organizations set workspace spend limits in the Console. The --max-budget-usd CLI flag also counts the session figure.

Does Agent Office show cost in dollars?

No. Agent Office shows token counts per task, per session and per agent, never a price. Use /usage for the dollar estimate.

Sources

  • Manage costs effectively (/usage, reducing token usage, agent teams, limits): https://code.claude.com/docs/en/costs
  • Sub-agents (model field, CLAUDE_CODE_SUBAGENT_MODEL): https://code.claude.com/docs/en/sub-agents
  • Status line (JSON fields, /statusline): https://code.claude.com/docs/en/statusline
  • Monitoring usage with OpenTelemetry: https://code.claude.com/docs/en/monitoring-usage
  • Agent Office facts: Agent Office README and source code, verified 2026-11-30

Claude and Claude Code are trademarks of Anthropic. Claud Agency is an independent tool by ECOMHUTSY and is not affiliated with Anthropic.

Frequently asked questions

How do I see token usage in Claude Code?

Run /usage and read the Session heading for tokens by model and an estimated cost. Add a status line to see context and cost continuously, or run /context to see what fills your context window.

Is /usage accurate?

It is an estimate. Claude Code computes the dollar figure locally from token counts at list price, and the plan breakdown is computed from local history on this machine, so other devices and claude.ai are not included. For billing, use your account or Console reports.

Why do subagents use more tokens?

Each subagent starts with its own fresh context window and sends its own requests on top of the main conversation's, so they draw on your usage even though only a summary returns. They help keep your main context small, but they are not free.

Does a Max plan show cost?

Pro, Max and Ultra subscribers have usage included, so the session cost figure is not relevant for billing. They see plan usage bars, activity stats and an attribution breakdown instead.

How do I lower Claude Code usage?

Run /clear between unrelated tasks, pick Sonnet instead of Opus when the task allows, set model: haiku on simple subagents, keep CLAUDE.md short, disable unused MCP servers, and write specific prompts.

Can I set a spending limit?

On Pro, Max and Ultra you can set a monthly spend limit for usage credits. Team and Enterprise admins set limits in admin settings, and API organizations set workspace spend limits in the Console. The --max-budget-usd CLI flag also counts the session figure.

Does Agent Office show cost in dollars?

No. Agent Office shows token counts per task, per session and per agent, never a price. Use /usage for the dollar estimate.