SSD Nodes Learn Hosting plans →
How to do am Matt ConnorBy Matt Connor

Claude Code Spend Trackers: Which One Fit You?

Claude Code spend trackers no dey count the same thing. Compare local log parsers, built-in usage screens, and OpenTelemetry to know wetin each one fit see.

Wetin Claude Code spend tracker dey actually read

Every Claude Code spend tracker dey read one of three data sources, and na the source dey decide which question e fit answer. Log parser dey read session transcript files wey dey your own disk. Dashboard dey read usage records wey Anthropic dey keep for your account or organisation. Metrics backend dey read OpenTelemetry (OTel) stream wey Claude Code dey emit when you switch am on. All three fit dey correct for the same time and still no agree, because dem dey count different things.

This guide no dey explain tokens again. how Claude Code dey count token usage cover input, output, cache writes and cache reads, and dashboard no go mean much until that part clear. The question here narrow: for each type of tool, wetin e fit see, and wetin e no fit ever see.

Wetin make three Claude Code spend trackers show for one day

Three separate Claude Code spend trackers show for the same day. Dem no be three versions of the same tool, and na that part dey useful. One parse the local session files. One wrap the account usage screens. One be hosted tracing backend wey you run by yourself.

Dem show together because e don hard to know the cost of one agent session. Chat cost roughly wetin you fit see for screen. Agent fit read twenty files, run the test suite, then send the whole conversation again for every turn. So context wey you no type dey drive the bill. For subscription, the session dollar figure wey Claude Code show na estimate wey Anthropic talk say e no relevant for billing. The number wey matter na usage bar wey dey fill faster for some days pass others. Each of the three dey cover different part of this gap.

Shape 1: local log parser dey tell you wetin today cost

Claude Code dey store each conversation as JSON Lines (JSONL) for ~/.claude/projects/<project>/<session-id>.jsonl, where <project> na your working directory path wey replace non-alphanumeric characters with -. Every assistant turn for that file get token counts for its request. Log parser go add dem together and calculate the price.

ccusage na the one wey most people go use. E no need installation:

npx ccusage@latest daily
npx ccusage@latest daily --breakdown
npx ccusage@latest blocks
npx ccusage@latest session --json

daily dey total by date. --breakdown dey split each row by model, and na so you go discover say one Opus afternoon take most of the week. blocks dey group by the five-hour window wey subscription reset dey use. session dey total each conversation, while daily --instances dey group by project so you fit see which repository cost pass. Add --since and --until to set the range, and run npx ccusage@latest daily --help for the date format wey your version expect. As of October 2026, e dey also read other agent CLIs, including Codex and OpenCode. This one matter if you dey compare dem. Default reports dey combine all sources wey e detect; add claude before daily or session to focus on Claude Code.

Model price table dey provide the pricing, and the tool get three cost modes. --mode auto dey use the costUSD value wey Claude Code write inside the file when e dey available, and e dey calculate from token counts when e no dey. --mode calculate dey always calculate from tokens and ignore any recorded cost. --mode display dey show only recorded costs and print $0.00 for rows wey no get any. If total look wrong, run the same report under calculate and then under display. If the difference big, e mean say most entries no get recorded cost, so everything wey you dey read na estimate. If you dey pay contracted rates, pricingOverrides under defaults inside a ccusage.json config file go replace the price for individual models.

The same data fit provide your prompt. ccusage statusline dey print one compact line for Claude Code status bar, and you fit connect am to ~/.claude/settings.json like any other status line command. See how to build Claude Code statusline for the settings block and the fields wey e receive.

Log parser no fit see anything wey no happen for this machine. Another laptop, session for claude.ai, or work wey teammate do: those transcripts dey for those disks. By default, cleanupPeriodDays dey clean up older terminal sessions after 30 days wey nobody use dem, but you fit configure retention: use big value like 3650 to keep years of history. Transcripts for sessions wey start or wey somebody most recently continue inside Desktop or Cowork dey remain pass that period by default, with exceptions like HIPAA configurations.

One more risk dey, and e come from the structure. Anthropic documentation talk say entry format na internal to Claude Code and e fit change between versions. So scripts wey parse these files directly fit break for any release. This rule apply to every tool wey work this way. Na also why hand-written jq one-liner over the JSONL no good as e look: maintained parsers dey follow format changes for you, while your one-liner fit report wrong number with confidence on the day dem rename one field.

Finally, dollar figure need one warning when subscription dey involved. Usage inside your Pro or Max plan limit no dey bill per token, so the number na wetin your tokens for cost at list API rates. E measure how heavy your usage be. E no be your bill. The exception na usage credits: if you turn dem on, usage wey pass plan limit go bill at standard API rates as separate charge, and claude.ai go show that month's spend under Settings > Usage. If the real question na which plan you suppose use, that comparison na separate exercise: see API billing compared with Claude subscription.

Shape 2: built-in usage screens dey tell you which model chop the budget

Claude Code ships im own reporting, but plenty people never open am. Run /usage inside one session. The Session block for top go show tokens by model and dollar figure for the current session. E dey calculate this locally from token counts with standard list rates, unless administrator set one modelPricing table for managed settings. If administrator set am, the Total cost line go say at your organization's configured rates. Either way, na estimate be the figure, and e fit different from your invoice. For Pro or Max, Anthropic talk say the figure no relevant for billing because that usage dey included for the plan. The totals go reset when /clear start one new conversation.

For Pro, Max, Team or seat-based Enterprise plan, the same screen go show how much of your plan limit you don use. Usage-based Enterprise no get included allowance wey fit finish, because dem bill every token with API rates. For these plans, the screen also assign recent usage to skills, subagents, plugins and individual MCP servers as percentage of the total. E go flag behaviours wey account for 10% or more of recent usage, like long context or cache misses. Press d or w to switch between the last 24 hours and the last 7 days. These figures na approximate values wey this machine calculate from local session history, so usage from second device no dey counted. When allowance finish, Claude Code go name the limit and show when e go reset; empty consumption bar no mean say the allowance don finish. The session fit wait and continue after reset, and wetin to do after you hit the limit na separate decision about model, context and plan.

When users pass one developer, the numbers move go the account. API organisation gets Console Cost page, Claude Code dashboard with spend and accepted lines for each member, and Claude Code Analytics API wey returns the same daily per-user metrics with admin key. Teams and Enterprise plans get spend report for admin console with CSV export, and e dey update daily. E covers usage-credit spend for seat-based plans and full usage for usage-based Enterprise. Enterprise adds analytics API. Which one you see depend on how each developer sign in, so mixed organisation go read two reports and add the figures by hand.

To size budget, the published figure for Anthropic cost documentation as of October 2026 na average near $13 per developer per active day and $150 to $250 per developer per month, with 90% of users below $30 per active day. Treat am as published benchmark from enterprise deployments, no be prediction for your team. Run pilot group and measure first before you extrapolate.

Dashboards no fit see anything below the day and the person. Dem go tell you say Opus na the model wey use most of Tuesday. Dem no go tell you which prompt, repository or CI job cause am. Reports also dey lag because organisation reports update daily. So dem better for review, not for catching runaway agent this afternoon. To catch runaway agent, you need limits, not reports. Na that how to keep agent costs bounded on a VPS dey discuss.

Shape 3: your own OpenTelemetry stack go tell you which prompt regress

Claude Code dey emit OpenTelemetry metrics and events once you enable telemetry and configure exporters. Na this only option wey streams per-user token and cost data enter system wey you control almost real time. The metrics include claude_code.cost.usage for USD, claude_code.token.usage for tokens, claude_code.session.count and claude_code.active_time.total.

The token metric na the interesting one because of its attributes. Each data point carry type, wey be input, output, cacheRead or cacheCreation, plus model and query_source, wey be main, subagent or auxiliary. E still carry agent.name, skill.name, mcp_server.name and mcp_tool.name. Names of MCP servers wey you configure yourself and your own custom subagents go arrive as custom unless you set OTEL_LOG_TOOL_DETAILS=1. This one also adds Bash commands and tool input to tool events. This information enough to answer questions wey no dashboard fit answer: how much of the bill come from subagents instead of your own turns, whether one MCP server double your input tokens, and whether cache reads reduce after person edit CLAUDE.md. Cache behaviour na usually where surprise dey hide, and when prompt caching pays for itself explains wetin you dey look at.

Make we correct one thing because e dey come up for almost every discussion about this. Langfuse na good self-hosted tracing backend, and self-hosting Langfuse for agent tracing cover how to run am for VPS. Its OTLP endpoint dey accept traces only. By default, Claude Code exports metrics and log events, not spans. So if you point OTEL_EXPORTER_OTLP_ENDPOINT to Langfuse, the project go remain empty and e no go give you any useful error. Span export dey available, but e still dey beta and e stay off until you set CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 and OTEL_TRACES_EXPORTER. Langfuse own Claude Code integration use another method: a Stop hook, or plugin wey install one, reads the session transcripts after each response and converts dem to traces. So e get the same local-only limits as a log parser. Langfuse na the correct tool for agents wey you build directly with the API, where your own code creates each span with its prompt, model and cost. For spend totals from the Claude Code CLI, metrics store na the better match.

Set up Claude Code spend tracking for your own VPS

Two services dey enough: one collector to receive the metrics, and Prometheus to store dem. Keep both away from public internet, because any person wey find open OTLP port fit write to am. Write /opt/ccmetrics/compose.yaml:

services:
  collector:
    image: otel/opentelemetry-collector-contrib:latest
    command: ["--config=/etc/otel/config.yaml"]
    volumes:
      - ./collector.yaml:/etc/otel/config.yaml:ro
    ports:
      - "10.8.0.1:4318:4318"
    restart: unless-stopped
  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - prom-data:/prometheus
    ports:
      - "127.0.0.1:9090:9090"
    restart: unless-stopped

volumes:
  prom-data:

10.8.0.1 na the server address inside WireGuard tunnel. So, na your machines fit reach the collector, and nobody else. The address wey dey before the port matter here, because published Docker ports no dey pass through ufw filter: see why Docker published ports bypass ufw. To set up the tunnel itself, see a WireGuard VPN for your own VPS.

/opt/ccmetrics/collector.yaml:

receivers:
  otlp:
    protocols:
      http:
        endpoint: 0.0.0.0:4318

processors:
  batch:

exporters:
  prometheus:
    endpoint: 0.0.0.0:8889

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [prometheus]

/opt/ccmetrics/prometheus.yml. Port 8889 no dey publish to the host, because Prometheus dey reach the collector through the Compose network with the service name:

global:
  scrape_interval: 30s

scrape_configs:
  - job_name: claude-code
    static_configs:
      - targets: ["collector:8889"]
cd /opt/ccmetrics
docker compose up -d
docker compose logs collector

Collector log suppose end with Everything is ready. Begin running and processing data.. If log stop because of config error, e mean say YAML no parse, and the container go restart again and again.

Now point Claude Code to am. For every machine wey dey run Claude Code, add this to ~/.claude/settings.json:

{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_METRICS_EXPORTER": "otlp",
    "OTEL_LOGS_EXPORTER": "none",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "http://10.8.0.1:4318",
    "OTEL_METRIC_EXPORT_INTERVAL": "10000"
  }
}

Start session, send one prompt, wait for the export interval (10 seconds here, 60 seconds by default), then ask Prometheus wetin e don learn:

curl -s http://localhost:9090/api/v1/label/__name__/values | grep -o 'claude_code[a-z_]*'

You suppose get several names wey start with claude_code_. The exporter dey change the dots to underscores and add the unit, so the exact strings depend on your collector version. Empty result mean say nothing don arrive. Check say the protocol and port match, because http/protobuf dey use 4318 and grpc dey use 4317; if dem no match, e fit fail quietly. Run claude --debug-file /tmp/claude-debug.log and check that file for [3P telemetry] lines. Na there Claude Code dey report OTel export errors.

If na one machine and you no need server, skip everything above. Set CLAUDE_CODE_ENABLE_TELEMETRY=1 and OTEL_METRICS_EXPORTER=prometheus, and Claude Code go expose scrape endpoint for http://localhost:9464/metrics by itself. When prometheus na the only exporter wey dey listed, Claude Code no go include the USD, tokens and s units for the exported metrics, so the scrape go remain valid Prometheus text format. Metric names no change. But setting wey combine exporters, such as otlp,prometheus, go keep the units.

This setup get one privacy decision. By default, na only counts and metadata dey leave the machine; prompt text and tool output no dey leave. OTEL_LOG_USER_PROMPTS=1 dey add prompt text to exported events and also enable assistant response text, unless OTEL_LOG_ASSISTANT_RESPONSES=0 override am. OTEL_LOG_TOOL_CONTENT=1 dey add selected tool output to trace spans, with exclusions and truncation at the content limit, wey be 60 KB by default. These flags fit expose source code and secrets inside the content wey dem select; dem no automatically export everything for the context. Full conversation bodies need the separate OTEL_LOG_RAW_API_BODIES setting. Turn dem on deliberately, and first read how to keep secrets out of agent context.

Track spending for scripted and CI runs

Na non-interactive runs dey surprise people, because nobody dey watch the screen. claude -p with --output-format json reports the cost of that run for its result payload:

claude -p "summarise the failing tests" --output-format json | jq '.total_cost_usd'

The payload carry total_cost_usd plus breakdown for each model, so CI job fit record the money e spend without any dashboard. Like every local figure, na client-side estimate e be, and run wey continue conversation with --continue or --resume go report the total for the whole conversation, including earlier runs. Append the value to file, or push am as metric go the collector above. This na the cheapest useful way to track spending, and e cost one jq call for each run.

Failure modes and wetin you go see

The report empty. npx ccusage@latest daily no print any row means e no dey read the place wey Claude Code dey write. CLAUDE_CONFIG_DIR dey change that location, and ccusage dey read that variable too, so run both with the same value. If older sessions no dey show, check cleanupPeriodDays: terminal sessions dey get cleaned after 30 days wey dem no use am by default, while Desktop and Cowork transcripts normally dey stay pass that period.

Two machines dey report different totals. Na expected, no be bug. The /usage breakdown and any log parser dey read only local session history, so usage from another device or from claude.ai no dey inside either one.

The local total no match the invoice. Local figures dey calculate from token counts with standard list rates unless you configure contracted rates: a modelPricing table for managed settings for /usage, or pricingOverrides for ccusage. For subscription, usage wey dey inside the plan limit no dey bill per token at all; na only usage credits dey bill. The Console Cost page na the authoritative source for API billing.

Cost rise while you dey do the same work. Check the cache columns first. Long session dey send the complete history again for every turn. E dey use cached rate while the cache still warm, but e go use full input rate once the cache go cold. So one long break fit make the system process the whole conversation again. You go see this as big input number beside small output number, and input versus output token pricing explain why both figures dey move independently.

A day with subagents look impossible. Each subagent dey run e own context window, so token use dey increase based on how many run and how long each one last. For plan, the /usage attribution dey show the subagent share for this machine as percentage. For detail per request, the OTel data dey separate dem through the query_source attribute for claude_code.token.usage. A log parser go show you the total, but e go leave you to guess.

FAQ

ccusage show wetin I dey actually pay for Max plan?

No. Usage wey dey inside subscription plan limit no dey bill per token. So log parser go price your tokens with standard list API rates and show wetin the same work for cost through the API. E good as relative measure of how heavy one day be, and e useful to compare projects or models with each other. For wetin you owe, Console Cost page cover API billing, while plan billing page cover subscription billing. If you turn on usage credits, usage wey pass the limit go bill with standard API rates, and claude.ai go show that spending under Settings > Usage.

Where Claude Code dey store the session files wey these tools dey read?

For ~/.claude/projects/<project>/<session-id>.jsonl, where <project> na the working directory path wey replace non-alphanumeric characters with -. Each line na one JSON object for one message, tool use, or metadata entry. CLAUDE_CONFIG_DIR dey move the whole directory, while cleanupPeriodDays for settings.json dey control retention. For terminal sessions, the default na 30 days of inactivity. Desktop and Cowork transcripts normally dey stay beyond that period. Anthropic document the entry format as internal and e fit change between versions. So use maintained tool to parse am instead of your own script.

I fit send Claude Code telemetry go Langfuse?

No be with the default telemetry. Langfuse OTLP endpoint dey accept traces. But by default, Claude Code dey export metrics and log events instead of spans, so nothing dey receive the data. Span export na beta feature wey you need switch on. Langfuse own Claude Code integration dey use Stop hook wey convert session transcripts to traces instead. For total spending, send Claude Code metrics go OpenTelemetry collector and store dem for Prometheus. Use Langfuse for agents wey you build yourself on the API, where your own code dey emit spans wey carry the prompt, the model, and the cost.

Why my local numbers no match Console usage page?

Because dem dey calculate dem differently. /usage and log parsers dey add token counts from session files for the machine wey you dey use, then price dem with standard list rates unless you configure contracted rates. This happens through modelPricing for managed settings for /usage or pricingOverrides for ccusage. Console dey cover your organisation usage across machines and keys. Use its Cost page for actual API costs, because Claude Code analytics dashboard spending figures na estimates. Mismatch normal. If the difference too large, e usually mean say second device, CI runner, or another team member dey bill to the same account.

How I fit track cost of claude -p run for CI?

Run am with --output-format json and read total_cost_usd from the result, for example with claude -p "..." --output-format json | jq '.total_cost_usd'. The same payload dey include per-model breakdown and session ID. Record that value for each job, and you go get per-pipeline spending without agent, dashboard, or extra service.

Dis article help you?