Skip to main content

claude-cost-compare

Daily Claude spend, before/after windows, and model routing health — in your terminal.

PyPI Python CI License: MIT

Turn local ccusage data into three Rich tables: daily cost, split-window comparison, and per-model verdicts.

Not a ccusage fork — an interpretation layer on top. ccusage reports what you spent; this CLI adds before/after windows, mix shifts, and routing health verdicts.

Quick start · Demo · ccusage vs this tool · Install · Usage · How it works


✨ Why this exists

Claude Code usage can spike fast — especially when Opus routing leaks or Sonnet/Haiku tiers stop doing their job. This CLI answers three questions at a glance:

Question Table
What did I spend each day? Daily cost — cost, tokens, model mix
Did things change after a date? Before vs After — avg/day, totals, mix shift
Are models routed correctly? Real Signal — Opus / Sonnet / Haiku verdicts

No cloud upload. Reads your local ccusage JSON and prints a terminal report.


🔀 ccusage vs this tool

ccusage claude-cost-compare
Role Usage analytics — read local logs, report spend Interpretation layer — explain what changed and if routing looks healthy
Scope Many agents, daily/weekly/monthly/session views Claude Code focus: before/after split + model mix verdicts
Output Descriptive tables & totals Daily cost + Before vs After + Real Signal (Opus/Sonnet/Haiku)
Install both? ✅ Required (data source) ✅ Optional companion on top

Use ccusage for “what did I spend?” Use this when “did something break after I changed config on Tuesday?”


🖥 Demo

claude-cost-compare terminal output showing daily cost, before/after comparison, and model health verdicts

Sample fixture output · --range 7 --cutoff 2026-05-08

Same output as plain text
claude-cost-compare --range 7 --cutoff 2026-05-08
CLAUDE DAILY COST  ·  2026-05-06 → 2026-05-26
┌─────────────┬────────┬───────────┬────────┬───────────┬──────┬────────┬──────┐
│ Date        │ Era    │      Cost │ Tokens │ Mix       │ Opus │ Sonnet │ Haiku│
├─────────────┼────────┼───────────┼────────┼───────────┼──────┼────────┼──────┤
│ 2026-05-06  │ Before │     $2.68 │   3.2M │ ████████… │ 100% │     0% │   0% │
│ 2026-05-08  │ Today  │    $80.88 │ 117.9M │ ████████… │  97% │     0% │   3% │
│ 2026-05-09  │ After  │     $9.92 │  12.1M │ ████████… │  45% │    55% │   0% │
└─────────────┴────────┴───────────┴────────┴───────────┴──────┴────────┴──────┘

BEFORE vs AFTER  ·  Split at 2026-05-08
REAL SIGNAL      ·  Post-2026-05-08 · per-model routing verdicts

🚀 Quick start

1. Install ccusage (peer dependency — reads your local usage data):

npm install -g ccusage

2. Install the CLI:

pip install claude-cost-compare
# or
uv tool install claude-cost-compare

3. Run:

claude-cost-compare --range 5

📦 Install

PyPI / uv

pip install claude-cost-compare
uv tool install claude-cost-compare
uvx claude-cost-compare --help          # run without installing

Homebrew

brew tap mazulo/claude-cost-compare https://github.com/mazulo/claude-cost-compare
brew install claude-cost-compare
npm install -g ccusage                  # still required

One-liner (no tap):

brew install https://raw.githubusercontent.com/mazulo/claude-cost-compare/main/Formula/claude-cost-compare.rb

Requirements

  • Python 3.11+ (pip/uv) or Homebrew
  • ccusage on your PATH (v18+; v20 period JSON field supported)

📖 Usage

# Last 5 days vs today (default)
claude-cost-compare --range 5

# 7-day window split at a specific date
claude-cost-compare --range 7 --cutoff 2026-05-13

# Full billing period from a start date
claude-cost-compare --since 2026-05-01 --cutoff 2026-05-13

# Daily summary only — skip comparison tables
claude-cost-compare --summary --since 2026-05-01

# Plain output (also respects NO_COLOR)
claude-cost-compare --plain --range 5

Flags

Flag Short Description
--range -r Days before cutoff for the "before" window (default: 5)
--cutoff -c Before/after split date YYYY-MM-DD (default: today)
--since -s Explicit start date — overrides --range
--summary Daily cost table only
--plain Disable color

🧠 How it works

flowchart LR
  A[ccusage JSON] --> B[Parser]
  B --> C[Window stats]
  C --> D[Before / After deltas]
  C --> E[Model verdicts]
  D --> F[Rich terminal report]
  E --> F
  1. Fetch — shells out to ccusage daily for JSON (NVM-aware discovery; supports date and v20 period rows).
  2. Parse — normalizes dates, costs, and per-model breakdowns.
  3. Analyze — splits records at --cutoff, computes averages and mix shifts.
  4. Verdict — flags Opus routing leaks, low Sonnet share, Haiku usage patterns.
  5. Render — Rich tables with era labels, mix bars, and color-coded costs.

🛠 Development

git clone https://github.com/mazulo/claude-cost-compare.git
cd claude-cost-compare
uv sync --dev
uv run pytest
uv run claude-cost-compare --range 5

Regenerate the README demo SVG after UI changes:

uv run python scripts/export_demo.py

🚢 Releasing

Bump version in pyproject.toml and src/claude_cost_compare/__init__.py, push to main, then run the Publish workflow from GitHub Actions. It will:

  1. Run tests and publish to PyPI
  2. Update the Homebrew formula checksum
  3. Create a git tag and GitHub Release
  4. Refresh Homebrew Python resources on macOS

Details: docs/RELEASING.md


📄 License

MIT — see LICENSE.


Built for Claude Code power users who want spend visibility without leaving the terminal.

⭐ Star on GitHub if this saves you from an Opus routing surprise.

Metadata

Release files for claude-cost-compare 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-cost-compare 0.1.3
File Size Uploaded Provenance Actions
claude_cost_compare-0.1.3.tar.gz 642.1 kB With provenance Details for claude_cost_compare-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for claude-cost-compare 0.1.3
File Interpreter ABI Platform Actions
claude_cost_compare-0.1.3-py3-none-any.whl Python 3 none any Details for claude_cost_compare-0.1.3-py3-none-any.whl

Total release size: 660.0 kB

Release files / claude_cost_compare-0.1.3.tar.gz

Download URL claude_cost_compare-0.1.3.tar.gz
Size 642.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4e4a3b0722eda66ed388b181ab7e2c352719634e17bd1e6776f88afba0703c30
BLAKE2b-256 checksum
How to use checksums
bbddc40007f66f6bc48212396eba0ec8629fc314b965de22657c6eddedb85604
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 26, 2026.

Transparency log

Release files / claude_cost_compare-0.1.3-py3-none-any.whl

Download URL claude_cost_compare-0.1.3-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ef1aed2a732d7f213a412b7e49dd36441bddc16f96de8a75f6708fe3271f6b5
BLAKE2b-256 checksum
How to use checksums
c513516846f58d7123427c3f5574598ecfc32645aa39adcacb2b9df7c3873f57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 26, 2026.

Transparency log

Security for claude-cost-compare 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for claude_cost_compare-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page