ClaudeMap

Claude Code Usage Analysis

Empirical study of Claude Code token usage: cache rebuilds, not typing volume, drive the bill — with run-counted measurements of the habits that throw the prompt cache away and a self-audit prompt that scores your own logs

Tutorials & Guidesguidescostbest-practicesanalysis

This repository measures how Claude Code usage is driven by prompt-cache rebuilds: the cache lasts 5 minutes on an API key (also Bedrock, Vertex and Foundry) and 1 hour on a Pro, Max or Ultra subscription within its usage limits, visible on /usage's Prompt cache (main) line. The do/don't table carries its sample counts: /compact before a break measured 2.5x versus about 10x resuming after (3 runs); /clear plus a 3-line note after a break measured about 1x (3 runs, 2 for /compact); keeping one session for small related fixes measured 28% less than /clear between them (1 run, small history, preliminary); long tool output added +15% (750-token log) to +64% (5,000) over the next 6 turns (2 runs each, preliminary); turning off a tool or switching models mid-task measured 22x a normal turn (2 runs, preliminary; the model-switch figure comes from docs, not tested). Desktop's Code tab measured at least 1.80x the CLI in one run. It ships a local analyzer (python3 -m cc_usage_study.analyze ~/.claude/projects ... --summary --sessions --calls) that reads logs without copying prompt text, and a paste-in prompt that scores your habits from summary fields, timestamps and compact_boundary metadata only.

What it does

  • States the cache baseline per billing mode: 5 minutes on an API key (also Bedrock, Vertex and Foundry), 1 hour on a Pro, Max or Ultra subscription within its usage limits; /usage exposes it on the Prompt cache (main) line
  • Every recommendation carries its sample size — /compact before a break 2.5x vs about 10x resumed after (3 runs), one session for small related fixes 28% less (1 run, small history, preliminary), tool/model switch mid-task 22x a normal turn (2 runs, preliminary, model switch from docs)
  • A paste-in audit prompt scores your own habits from summary numbers, timestamps and compact_boundary fields while explicitly instructing Claude not to read, paste or upload the raw text of your chats
  • The analyzer runs locally (python3 -m cc_usage_study.analyze ~/.claude/projects --summary --sessions --calls -o ./local-out/report.json); the repo also ships a /claude-code-usage-check skill
  • A myths section documents where modeling failed: --autocompact 180000 calculated 43% less but tied the default in a live 270,000-token session; one setting sent 63% fewer raw tokens yet used 25.2% more

When to use it

For teams and heavy users who want session hygiene decided by evidence rather than folklore: what to do before a break, whether scheduled claude -p runs should resume or start fresh, and which client to standardize on.

Getting started

mkdir -p ~/.claude/skills
cp -R skills/claude-code-usage-check ~/.claude/skills/

Things to know

Sample sizes are small and the README marks almost every figure: 1-run rows are labeled preliminary, the +76% workday figure for missed idle compaction is modeled rather than tested live, the ~3x estimate for resuming scheduled claude -p runs is not tested live, and measurements were taken on Claude Code 2.1.325 (older versions may behave differently). Fewer raw tokens is not less usage — one setting sent 63% fewer raw tokens and used 25.2% more, because cached tokens cost far less. The self-audit prompt is designed to keep chat text local, but the Claude Code conversation that runs it still contains the summary numbers.

Repository

inevolin/claude-code-usage-analysis

Charted

Related on the map

  • Anthropic's official "Code with Claude" workshop materials — nine hands-on courses on skills, MCP, evals and Claude Managed Agents.

    • official
    • workshops
    • anthropic
    • managed-agents
  • Anthropic's canonical essay on agent design — workflows vs agents, and five composable patterns.

    • official
    • agents
    • engineering
    • patterns
  • HumanLayer's 12 design principles for production-grade LLM agents — the closest thing to a 'best practices' manifesto.

    • agents
    • best-practices
    • production
    • principles
  • Official curated registry of MCP servers — discovery, versioning, and metadata for the ecosystem.

    • official
    • mcp
    • registry
    • discovery