ccusage
$ ccusage Community Low Riskccusage reads local AI coding CLI session logs (Claude Code, Codex, OpenCode, etc.) and generates daily, weekly, monthly, session, and blocks usage and cost reports. Supports --json, --compact, --no-cost, --instances, and --timezone.
brew install ccusage ccusage is fastest as a read-only CLI (ccusage daily --json) for cost audits and scripts; an optional @ccusage/mcp server is also available.
Agent-Readiness Checklist
Local Probe EvidenceCaptured --help excerpt
USAGE: ccusage [daily] <OPTIONS> ccusage <COMMANDS> COMMANDS: daily Show usage report grouped by date monthly Show usage report grouped by month weekly Show usage report grouped by week session Show usage report grouped by conversation session blocks Show usage report grouped by session billing blocks mcp Start MCP server with usage reporting tools statusline Display compact status line for Claude Code hooks with hybrid time+file caching (Beta) For more info, run any command with the `--help` flag: ccusage daily --help ccusage monthly --help ccusage weekly --help ccusage session --help ccusage blocks --help ccusage mcp --help ccusage statusline --help OPTIONS: -s, --since <since> Filter from date (YYYYMMDD format) -u, --until <until> Filter until date (YYYYMMDD format) -j, --json Output in JSON format (default: false) -m, --mode [mode] Cost calculation mode: auto (use costUSD if exists, otherwise calculate), calculate (always calculate), display (always use costUSD) (default: auto, choices: auto | calculate | display) -d, --debug Show pricing mismatch information for debugging (default: false) --debug-samples [debug-samples] Number of sample discrepancies to show in debug output (default: 5) (default: 5) -o, --order [order] Sort order: desc (newest first) or asc (oldest first) (default: asc, choices: desc | asc) -b, --breakdown Show per-model cost breakdown (default: false) -O, --offline Use cached pricing data for Claude models instead of fetching from API (default: false) --no-offline Negatable of -O, --offline --color Enable colored output (default: auto). FORCE_COLOR=1 has the same effect. --no-color Disable colored output (default: auto). NO_COLOR=1 has the same effect. -z, --timezone <timezone> Timezone for date grouping (e.g., UTC, America/New_York, Asia/Tokyo). Default: system timezone -l, --locale [locale] Locale for date/time formatting (e.g., en-US, ja-JP, de-DE) (default: en-CA) -q, --jq <jq>
FCRS-1.0 6-Dimension Breakdown
Clean non-interactive reporting (daily, weekly, monthly, session) with --json, --no-cost, --instances, and --timezone.
--json,--compact,--no-cost,--instances, and--timezoneacross report subcommands
Strictly read-only analysis of local JSONL log files with zero network mutations or credential storage.
- Read-only local JSONL log parsing (cached LiteLLM pricing optional/offline fallback)
Runs everywhere via npx ccusage@latest, npm install -g ccusage, or brew install ccusage.
- Available on Homebrew, npm, and
npx ccusage@latest
Instant visibility into cache hit rates, per-model token burn, and 5-hour billing blocks.
- Covers input/output/cache-read/cache-create tokens and multi-CLI subcommands
Active MIT-licensed community tool (ccusage/ccusage) with dedicated docs and companion packages.
- Active
ccusage/ccusagerepository under MIT
Clear documentation site (ccusage.com/guide/) detailing JSON schemas, flags, and subcommands.
- Official docs at
ccusage.com/guide/
Security, Auth & Guardrails
Reads local session JSONL logs (e.g., ~/.claude/projects/); requires no API keys or login.
100% free and MIT open-source.
# ccusage Agent Rules - Always pass `--json` when querying usage reports from agents or scripts. - Use `daily`, `weekly`, `monthly`, or `session` (avoid live `blocks --live` watch loops in non-interactive runs).
Agent-Ready Command Recipes
Safe Read-Only Queries
ccusage daily --json --timezone UTC
Parses local JSONL session logs and outputs daily input/output/cache token totals and estimated USD cost in JSON.
ccusage session --instances --no-cost --json
Breaks down session token counts per project instance in JSON while omitting monetary fields.
Strengths for Agents
- + Zero-setup read-only audit of local AI coding CLI token and cache spend.
- + Clean
--jsonoutput acrossdaily,weekly,monthly, andsessionreports. - + Supports
--no-cost,--instances, and--timezonefor exact reporting.
Caveats & Pitfalls
- ! Estimated USD costs rely on upstream LiteLLM pricing data and may differ slightly from final invoice billing.
- !
blocks --livestarts a continuous terminal monitor that blocks unless omitted.