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.
npx ccusage@latestwith 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 dailyscopes it to one. blocks --livewas removed in v18.0.0. Useblocks --activeor the statusline command.- It deduplicates on message ID and request ID, which is why its numbers are the correct ones.
Running it
# 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.
| Source | Focused command | Reads from |
|---|---|---|
| Claude Code | ccusage claude daily | ~/.claude/ and ~/.config/claude/projects/ |
| Codex | ccusage codex daily | ${CODEX_HOME:-~/.codex} |
| OpenCode | ccusage opencode daily | ~/.local/share/opencode |
| GitHub Copilot CLI | ccusage copilot daily | ~/.copilot/otel/*.jsonl |
| Gemini CLI | ccusage gemini daily | Its own local logs |
| Amp, Droid, Codebuff | ccusage amp daily and friends | Their own local logs |
| Hermes, pi-agent, Goose | ccusage hermes daily and friends | Their own local logs |
| OpenClaw, Kilo, Kimi, Qwen | ccusage kilo daily and friends | Their own local logs |
The commands
What each report is for.
| Command | Groups by | Use it to |
|---|---|---|
daily (default) | Calendar day | See the trend and spot expensive days |
weekly | Week | Compare against a weekly cap |
monthly | Month | Budget and report |
session | Session | Find the sessions that cost the most |
blocks | 5-hour billing window | Understand quota consumption |
statusline | Live, in your prompt | See spend without running anything |
The flags worth knowing
Global flags apply to every report.
| Flag | Short | Does |
|---|---|---|
--json | -j | Structured output, for scripting |
--breakdown | -b | Split each row by model |
--since / --until | Date range, YYYYMMDD | |
--last N | Most recent N periods | |
--offline | -O | Use the cached pricing snapshot, no network |
--timezone | -z | Timezone for date bucketing |
--no-cost | Hide dollar columns and JSON cost fields | |
--compact | Force the narrow table layout | |
--config FILE | Load defaults, including pricing overrides |
# 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.
# 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.
{
"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.
| Flag | Does |
|---|---|
--visual-burn-rate | Adds an indicator to the burn rate. off, emoji, text, or emoji-text |
--cost-source | Which pricing calculation to display: auto, ccusage, cc, or both |
--context-low-threshold | Colour threshold for context usage, default 50 percent |
--context-medium-threshold | The second threshold, default 80 percent |
--no-offline | Fetch 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.
- Resumes replay history. Resuming a session can write earlier messages again, so the same logical request appears in more than one place.
- Retries duplicate. A retried request can be recorded twice.
- 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
| Limitation | Why | What covers it |
|---|---|---|
| No remaining quota | Plan state is not written to the session files | A status line script, or a desktop gauge |
| One machine only | The files are local | The org Analytics API, or OpenTelemetry |
| Only 30 days of Claude Code history | Transcripts are swept by cleanupPeriodDays | Raise the setting, or a tool that keeps its own copy |
| You have to run it | It is a CLI | The statusline command, or an ambient gauge |
| Prices are list prices | It has no view of your contract | The 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.