ccusage: the reference tool for Claude Code token costs

ccusage reads the session files your agent CLIs already write and turns them into a cost report. No setup, no account, no network. It started as a Claude Code tool and now covers fifteen different agent CLIs, which makes it the closest thing this ecosystem has to a common unit of measurement.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

ccusage is an open-source CLI by @ryoppippi that parses the local session logs written by Claude Code, Codex, OpenCode, Gemini CLI, Copilot CLI and ten other agent CLIs, and reports token usage and cost by day, week, month, session, or 5-hour block. Run it with npx, no install required. Version 20.0.19 was the current release as of August 2026.

What you need to know
  • npx ccusage@latest with no arguments gives you daily totals immediately.
  • It works retroactively: the data was on disk before you installed anything.
  • It reads fifteen agent CLIs, not just Claude Code. ccusage codex daily scopes it to one.
  • blocks --live was removed in v18.0.0. Use blocks --active or the statusline command.
  • It deduplicates on message ID and request ID, which is why its numbers are the correct ones.

Running it

No install step. It reads files that already exist.
# daily totals across every detected source, the default
npx ccusage@latest

# other package runners
bunx ccusage
pnpm dlx ccusage
nix run github:ccusage/ccusage -- daily

# other groupings
npx ccusage@latest weekly
npx ccusage@latest monthly
npx ccusage@latest session
npx ccusage@latest blocks

It is not a Claude Code tool any more

This is the change most people have missed. A bare ccusage daily now aggregates every agent CLI it detects on the machine, and each source has a focused command that scopes the report to one.

Supported sources and their focused commands, as of August 2026.

SourceFocused commandReads from
Claude Codeccusage claude daily~/.claude/ and ~/.config/claude/projects/
Codexccusage codex daily${CODEX_HOME:-~/.codex}
OpenCodeccusage opencode daily~/.local/share/opencode
GitHub Copilot CLIccusage copilot daily~/.copilot/otel/*.jsonl
Gemini CLIccusage gemini dailyIts own local logs
Amp, Droid, Codebuffccusage amp daily and friendsTheir own local logs
Hermes, pi-agent, Gooseccusage hermes daily and friendsTheir own local logs
OpenClaw, Kilo, Kimi, Qwenccusage kilo daily and friendsTheir own local logs

The commands

What each report is for.

CommandGroups byUse it to
daily (default)Calendar daySee the trend and spot expensive days
weeklyWeekCompare against a weekly cap
monthlyMonthBudget and report
sessionSessionFind the sessions that cost the most
blocks5-hour billing windowUnderstand quota consumption
statuslineLive, in your promptSee spend without running anything

The flags worth knowing

Global flags apply to every report.

FlagShortDoes
--json-jStructured output, for scripting
--breakdown-bSplit each row by model
--since / --untilDate range, YYYYMMDD
--last NMost recent N periods
--offline-OUse the cached pricing snapshot, no network
--timezone-zTimezone for date bucketing
--no-costHide dollar columns and JSON cost fields
--compactForce the narrow table layout
--config FILELoad defaults, including pricing overrides
The three invocations that answer most questions.
# this month, split by model
npx ccusage@latest monthly --last 1 --breakdown

# Claude Code only, grouped by project
npx ccusage@latest claude daily --instances

# machine-readable, for a dashboard or a cron job
npx ccusage@latest daily --json --since 20260701

The per-command flags worth remembering are --instances and --project on the daily report, --start-of-week on the weekly report, and --id on the session report when you already know which session you are chasing.

Blocks, and the live mode that is gone

A block is one 5-hour billing window. It starts with your first message and lasts exactly five hours, which is the same boundary your plan uses, so the block report is the closest ccusage gets to a quota view.

The current block, with a projection.
# only the block you are in, with time remaining and projected totals
npx ccusage@latest blocks --active

# the last three days of blocks
npx ccusage@latest blocks --recent

# treat your largest previous block as the ceiling
npx ccusage@latest blocks --token-limit max

The statusline command

This is the replacement for live mode and it is better, because it costs no screen space. Claude Code runs a command to render its status line, and ccusage ships one.

~/.claude/settings.json
{
  "statusLine": {
    "type": "command",
    "command": "bunx ccusage statusline",
    "padding": 0
  }
}

You get one line in your prompt with the active model and effort level, session cost, today's total, the current block cost with time remaining, burn rate per hour, and context usage as a percentage. It runs offline against cached pricing by default, which is what keeps it fast enough to render on every message.

Flags specific to the statusline command.

FlagDoes
--visual-burn-rateAdds an indicator to the burn rate. off, emoji, text, or emoji-text
--cost-sourceWhich pricing calculation to display: auto, ccusage, cc, or both
--context-low-thresholdColour threshold for context usage, default 50 percent
--context-medium-thresholdThe second threshold, default 80 percent
--no-offlineFetch current pricing instead of using the cached snapshot

Why its numbers are the right ones

The hard part of this problem is not reading JSONL. It is not double counting.

  1. Resumes replay history. Resuming a session can write earlier messages again, so the same logical request appears in more than one place.
  2. Retries duplicate. A retried request can be recorded twice.
  3. Subagents write their own transcripts. Sidechain work lands in a separate file under the parent session directory.

ccusage builds a deduplication key from the message ID and the request ID, so each logical request counts once regardless of how many times it appears on disk. When two records collide it prefers the non-sidechain entry and the one with the larger token total, which is the version that reflects the completed request. A tool that naively sums every usage object it finds will report a larger number, and that number will be wrong.

Where it stops

LimitationWhyWhat covers it
No remaining quotaPlan state is not written to the session filesA status line script, or a desktop gauge
One machine onlyThe files are localThe org Analytics API, or OpenTelemetry
Only 30 days of Claude Code historyTranscripts are swept by cleanupPeriodDaysRaise the setting, or a tool that keeps its own copy
You have to run itIt is a CLIThe statusline command, or an ambient gauge
Prices are list pricesIt has no view of your contractThe Console usage page, for an authoritative bill

Questions people ask

An open-source CLI by @ryoppippi that reads the local session logs written by agent CLIs and reports token usage and cost by day, week, month, session, or 5-hour block. It is MIT licensed and runs entirely offline.

You do not have to. Run npx ccusage@latest and it executes directly. bunx ccusage, pnpm dlx ccusage, and nix run github:ccusage/ccusage all work too.

Yes. As of August 2026 it reads fifteen sources including Codex, OpenCode, Gemini CLI, GitHub Copilot CLI, Amp, Droid, Goose, and Kimi. Run ccusage codex daily to scope a report to one of them.

The live monitor was removed in v18.0.0. Use blocks --active for the current window with projections, or the ccusage statusline command for a permanent readout in your Claude Code prompt.

It shows tokens priced at list rates. On an API key that is close to your bill but ignores contracted discounts. On Pro or Max no money moved, so read it as a measure of intensity and as a comparison against the API.

No. Plan state is not written to the session files. Its blocks report shows consumption within the current 5-hour window, which is a useful proxy, but remaining headroom has to come from the /usage screen or the status line rate_limits fields.

Deduplication. The same logical request can appear multiple times across files after resumes and retries. ccusage deduplicates on message ID and request ID; tools that do not will overcount.

As far back as the files exist. Claude Code deletes transcripts older than cleanupPeriodDays, 30 days by default, so a fresh machine typically shows one month unless you changed that setting.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. ccusage on GitHub
  2. ccusage documentation
  3. Claude Code: the .claude directory
  4. Claude Code: customize your status line
Try it

The same numbers,
plus the quota.

Continuum uses the dedup logic ccusage established, and adds live quota gauges, retained history, and every other agent you run.

free app · your subscriptions · local-first