keepcalculator

06 Numbers and Powers

Claude Code Token Drains: Hidden Usage Found

Card No. 06·10072 · Updated · Standard formula, shown below

Average tokens per session 10,000 tokens/session
Context utilization
5.0 %
Result
Total tokens used
100000 tokens
You entered
Active sessions
10 sessions
You entered
You enter
Total tokens used, Active sessions, Context window size
You get
Average tokens per session, Context utilization
Rounding
0 dp · 1 dp

If you checked your Claude Code usage and found four hidden token drains you never knew about, the short answer is yes: Claude Code can consume tokens through background processes, automatic tool calls, context accumulation, and system-level operations that are easy to miss in the usage dashboard. These drains are not malicious—they are byproducts of how the tool works—but understanding them can help you control costs and avoid surprises.

Formula

The calculator above works out two things: the average token usage per session and what percentage of the context window that represents. The formulas are:

  • Average tokens per session = Total tokens used ÷ Active sessions
  • Context utilization = (Average tokens per session ÷ Context window size) × 100

Variables: Total tokens used (t) is the number of tokens billed in a given period, Active sessions (a) is how many separate Claude Code sessions you ran, and Context window size (c) is the maximum tokens the model can hold in memory (for example, 200,000 for Claude 3.5 Sonnet).

Worked Example

Using the defaults: you used 100,000 tokens across 10 sessions, and your context window is 200,000 tokens.

  1. Average tokens per session = 100,000 ÷ 10 = 10,000 tokens/session
  2. Context utilization = (10,000 ÷ 200,000) × 100 = 5.0%

So each session uses about 10,000 tokens, which is only 5% of the available context window. That seems low, but hidden drains can push it higher.

What Counts as a Token Drain?

Token drains are any operations that consume tokens without you explicitly asking for a long response. In Claude Code, these include:

  • Tool calls: Every time Claude reads a file, edits code, or runs a command, it sends a tool call and receives the output—both count as tokens.
  • Context accumulation: As a session goes on, the entire conversation history is resent to the model with each new request. Longer sessions mean more tokens per call.
  • Automatic file reads: Claude Code often reads files to understand the project structure, even if you didn’t ask it to. Each read is a token cost.
  • System prompts and tool definitions: Every request includes a system prompt and descriptions of available tools, which are tokens you don’t see in the response.

Why the Usage Dashboard Hides These

The Anthropic usage dashboard shows total tokens billed, but it doesn’t break down how many tokens went to tool calls versus the model’s response. That’s because the API reports input and output tokens per request, but Claude Code aggregates them across many requests. You might see a large total and assume it’s from long responses, when in reality a lot of it came from hidden tool calls and context resends.

Common Misconception: It’s Only the Response

Many users think token usage equals the length of the final answer. That’s false. In a typical Claude Code session, the model’s response text is often a small fraction of total tokens. For example, a simple file edit might produce a 100-token response, but the tool call to read the file, the file contents, and the updated context can add 2,000 tokens. Over dozens of tool calls, that adds up.

How to Reduce Hidden Drains

You can’t eliminate these drains, but you can reduce them:

  • Start new sessions for new tasks—a fresh context window avoids resending old conversation.
  • Use the /clear command to reset context mid-session when the task changes.
  • Avoid asking for large file reads—instead, ask Claude to search for specific patterns.
  • Limit the number of tools by disabling ones you don’t need (e.g., if you don’t use the browser tool, turn it off).
  • Use the “compact” feature to summarize the conversation and free up context tokens.

What the Numbers Really Mean

When you see a high token count, it doesn’t necessarily mean you asked for too much. It could mean you ran many sessions, used a lot of tool calls, or left a session running while it processed background tasks. The calculator above helps you see the average per session, which is a more useful metric than the raw total. If your average is high, focus on session length and tool usage.

Frequently Asked Questions

Why does my token usage spike even when I’m not typing?

Claude Code may be running background tasks like indexing files or auto-completing code. These operations send tool calls that consume tokens. Also, if you have a long-running session, the context is resent with each request, so even a small prompt costs more tokens than it would in a fresh session.

Can I see a per-tool breakdown of token usage?

Not directly in the standard dashboard. The API response includes per-request input and output tokens, but Claude Code doesn’t expose a per-tool log. You can enable debug logging to see individual requests, but that’s a developer-level feature.

Does the context window size affect cost?

Yes, indirectly. A larger context window means more tokens can be stored, but it also means more tokens are resent with each request. If you rarely use the full window, you’re paying to resend unused context. Starting fresh sessions helps avoid this.

Is there a way to set a token budget in Claude Code?

Claude Code doesn’t have a built-in budget limiter, but you can monitor usage via the Anthropic console and set up alerts. Some users use environment variables to restrict the max tokens per response, but that doesn’t cap total session usage.

Are hidden drains caused by a bug?

No, they’re by design. The tool needs to read files and send context to function correctly. However, if you notice an unusually large spike, check for a runaway loop—a task that keeps calling tools repeatedly. You can stop it with Ctrl+C.

Related

Formula used
in t | Total tokens used | tokens | 100000 | 0
in a | Active sessions | sessions | 10 | 1
in c | Context window size | tokens | 200000 | 1
out avg | Average tokens per session | tokens/session | t / a | 0
out pct | Context utilization | % | (t / a) / c * 100 | 1

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →