Skip to main content

Accurate cost tracking and quota monitoring for Claude Code

Project description


ccbar

Real-time cost tracking and quota monitoring for Claude Code.

Zero dependencies. Pure Python stdlib. One pip install and you're done.

PyPI Downloads Python License Dependencies

English 中文


ccbar demo

Why ccbar

You're burning through API credits or a $200/month Max subscription — but Claude Code doesn't tell you how fast, which project, or what it'll cost by end of day. ccbar fills that gap.

It works with both billing models: whether you're on the API (pay-per-token) or a Pro/Max subscription (quota-based), ccbar tracks your spend in real time. No guessing, no surprises at the end of the month.

Install

pip install ccbar
ccbar --install

Restart Claude Code. Two status lines appear at the bottom. That's it.

What you get

Row 1:  5h quota bar + countdown · today tokens + ♻cache + cost › per-project · week · month
Row 2:  7d quota bar + countdown · session cost + $/h + →projection + duration + lines · context% + model · total cost

Terminal too narrow? Trailing columns drop automatically. Content within columns is never truncated.

Lightweight by design

ccbar is a single Python file. No frameworks, no background daemons, no node_modules. It reads JSONL logs that Claude Code already writes and the OAuth API you already have. The entire package installs in under a second.

ccbar typical alternatives
Dependencies 0 10–50+ npm/pip packages
Install time < 1s 30s – 2min
Background process None — runs on each statusline refresh Persistent daemon
Config 1 JSON file or 1 env var YAML + env + dashboard setup

Accurate to the cent

Most tools estimate costs with a flat rate. That's wrong — Opus output is 19x more expensive than Haiku. ccbar gets it right:

  • Per-model pricing — reads the model ID from every message. Opus, Sonnet, Haiku each priced correctly.
  • Streaming dedup — each API call writes 2–7 JSONL entries. ccbar deduplicates by message.id. Every message counted exactly once.
  • Cache separation — cache reads cost 10% of fresh input. ccbar tracks them separately and shows ♻hit rate per project.
  • Cross-session history — session cost resets when you restart. Your bill doesn't. ccbar scans all JSONL — today, this week, this month, per project.

Full-spectrum monitoring

Metric What it tells you
5h / 7d quota bars Green→yellow→red gradient. Know when you'll hit the limit before you hit it.
Burn rate $8.50/h How fast this session is spending.
Projection →$18 Where you'll land by quota reset at the current pace.
Per-project › proj ♻56M/97% $124 Which project is eating your budget. Cache hit rate included.
Lines changed +250/-40 Code output this session — are you getting value for the spend?
Context % How full the context window is. Helps you decide when to compact.
Today / Week / Month Running totals so you always know where the bill stands.

API & Subscription — both covered

API users — ccbar calculates exact costs from per-model token pricing. You see dollars spent per session, per project, per day.

Pro / Max subscribers — ccbar reads your OAuth quota via the Anthropic API. The 5-hour and 7-day progress bars show exactly how much runway you have left, with countdowns to reset.

Either way, you get a single statusline that tells the full story.

Configure

export CCBAR_LAYOUT="5h,today,history|7d,session,total"
# or
ccbar --init-config   # → ~/.config/ccbar.json
Config reference
{
  "rows": [["5h", "today", "history"], ["7d", "session", "total"]],
  "columns": null,
  "colors": {},
  "pricing": {
    "claude-opus-4-6":    { "in": 15,  "out": 75, "cc": 18.75, "cr": 1.5  },
    "claude-sonnet-4-6":  { "in": 3,   "out": 15, "cc": 3.75,  "cr": 0.3  },
    "claude-haiku-4-5":   { "in": 0.8, "out": 4,  "cc": 1,     "cr": 0.08 }
  }
}
Field Description
rows Layout grid — items: 5h 7d today history session model total
columns Override terminal width (null = auto-detect)
pricing $/million tokens per model
colors [R, G, B] overrides

How it works

stdin JSON → detect terminal width → fetch OAuth quota (cached 30s)
           → scan ~/.claude/projects/**/*.jsonl (cached 60s)
           → dedup by message.id → per-model pricing → adaptive layout → stdout

OAuth — macOS: auto-reads Keychain. Linux/CI: export CLAUDE_OAUTH_TOKEN="...". Without it, quota bars show --.

Uninstall

ccbar --uninstall && pip uninstall ccbar

MIT · For developers who treat AI compute as a budget line item.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccbar-0.1.1.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ccbar-0.1.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file ccbar-0.1.1.tar.gz.

File metadata

  • Download URL: ccbar-0.1.1.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for ccbar-0.1.1.tar.gz
Algorithm Hash digest
SHA256 592810632489769a80f4bbfe1a1f3b3b2e20266f0b09ce1f1e921a1e7922bd64
MD5 48d429771afd70ce9481d7b218fe849e
BLAKE2b-256 b9390c21178105b65f37cf4174cf8eab47fee940da4a1ba44f0056c770f68bbb

See more details on using hashes here.

File details

Details for the file ccbar-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ccbar-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for ccbar-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1740a8aae870aacb137b90d8e58acd486235dc185f53db378e4dbca4befa6891
MD5 0126e7fd4f0d68bf27ff02b4a5f6e2a6
BLAKE2b-256 3d4ad43f7b9d56a8cdf65e977f33b6c3233b24c4e58494065c70a527e6ecc5a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page