Skip to content

Cost Management

Claude Code charges by API token consumption. Here’s how to track, manage, and reduce your costs.


  • Average: ~$13 per developer per active day
  • Monthly: $150–250 per developer
  • 90th percentile: under $30 per active day

These vary widely based on model choice, codebase size, and how many parallel sessions you run.


/usage

Shows:

  • Token usage for current session
  • Dollar estimate (computed locally — check Claude Console for authoritative billing)
  • On Pro/Max/Team/Enterprise: breakdown by skills, subagents, MCP servers
  • Press d for last 24h, w for last 7 days

Configure your status line to show context window usage at all times. See Keyboard Shortcuts & Status Line.

For authoritative billing: https://platform.claude.com/usage

Set workspace spend limits at: https://platform.claude.com/workspaces


Team sizeTPM per userRPM per user
1–5200k–300k5–7
5–20100k–150k2.5–3.5
20–5050k–75k1.25–1.75
50–10025k–35k0.62–0.87
100–50015k–20k0.37–0.47
500+10k–15k0.25–0.35

TPM per user decreases with team size because fewer users use Claude concurrently in larger orgs.


/clear

Start fresh when switching to unrelated work. Stale context wastes tokens on every subsequent message.

Before clearing, rename the session so you can resume later:

/rename auth-module-debugging
/clear
# ... later ...
/resume auth-module-debugging

Custom compaction instructions:

/compact Focus on code samples and API usage

Or in CLAUDE.md:

# Compact instructions
When compacting, preserve test output and code changes.

ModelBest for
HaikuSimple subagent tasks, lookups, fast checks
SonnetMost coding tasks — best cost/quality balance
OpusComplex architectural decisions, multi-step reasoning

Switch mid-session: /model Set default: /config For subagents: add model: haiku in the subagent frontmatter


MCP tool definitions are deferred by default (only names in context until used). But unused servers still add overhead.

/mcp # See configured servers
/context # See what's consuming context space

Prefer CLI tools when available (gh, aws, gcloud, sentry-cli) — they don’t add any context overhead vs MCP servers.


Problem: CLAUDE.md is loaded into context at session start — even when you’re doing unrelated work.

Solution: Move specialized instructions (PR review checklists, deploy steps, migration patterns) into skills — they only load when invoked.

Rule of thumb: Keep CLAUDE.md under 200 lines. Only put always-needed context there.


Instead of Claude reading a 10,000-line log file, a hook can grep for ERROR and pass only matching lines:

settings.json
{
"hooks": {
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{"type": "command", "command": "~/.claude/hooks/filter-test-output.sh"}]
}]
}
}
filter-test-output.sh
#!/bin/bash
input=$(cat)
cmd=$(echo "$input" | jq -r '.tool_input.command')
if [[ "$cmd" =~ ^(npm test|pytest|go test) ]]; then
filtered_cmd="$cmd 2>&1 | grep -A 5 -E '(FAIL|ERROR|error:)' | head -100"
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"allow\",\"updatedInput\":{\"command\":\"$filtered_cmd\"}}}"
else
echo "{}"
fi

6. Delegate Verbose Operations to Subagents

Section titled “6. Delegate Verbose Operations to Subagents”

Running tests, fetching docs, or processing logs generates verbose output. Delegate these to subagents — the verbose output stays in the subagent’s context, and only a summary returns.


  • Vague: “improve this codebase” → broad scanning, many file reads
  • Specific: “add input validation to the login function in auth.ts” → minimal file reads

Press Shift+Tab to enter plan mode. Claude explores first and proposes an approach for your approval — preventing expensive re-work when the initial direction is wrong.


If Claude starts going in the wrong direction:

  • Press Escape to stop immediately
  • Press Escape twice (or /rewind) to restore to a previous checkpoint
  • Redirect before Claude does more work in the wrong direction

Extended thinking improves quality but costs more (thinking tokens billed as output tokens).

For simpler tasks:

/effort low # Reduce thinking effort
/model # Disable thinking in model settings

Or set environment variable: MAX_THINKING_TOKENS=8000

Note: Fable 5 always uses extended thinking — can’t be disabled.


Agent teams use ~7x more tokens than standard sessions (each teammate has its own context window).

Tips:

  • Use Sonnet for teammates (not Opus)
  • Keep teams small
  • Keep spawn prompts focused (CLAUDE.md + MCP load automatically — don’t duplicate in prompts)
  • Shut down teammates when their work is done

Enable agent teams: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1


Even when idle, Claude Code uses a small amount of tokens:

  • Conversation summarization for /resume
  • Some command processing (/usage, etc.)

Typical background cost: under $0.04 per session — minimal.


Claude Code automatically uses prompt caching to reduce costs for repeated content:

  • System prompts
  • CLAUDE.md files
  • Tool definitions
  • Conversation history that hasn’t changed

You don’t need to do anything — it’s automatic. See how prompt caching works.

  • Trick: the four levers — “cache, model mix, delegation, lean CLAUDE.md.”
  • Show: /usage plus a statusline with cache counters.
  • They’ll trip on: blaming the model for cost when the cache prefix is churning (see file 54).

Learning path:40-agent-sdk.md · Index · ➡ 42-large-codebases.md

Written by Fenil Patel