Skip to main content

Accurate cost tracking and quota monitoring for Claude Code

Project description


ccbar

Vibe coding is no longer just for fun. Know what it costs.

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

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 + cost › proj tokens ♻cache/hit% cost · week cost › proj tokens cost │ month tokens cost › proj cost
Row 2:  7d quota bar + countdown · session cost + $/h + →projection + duration + ctx% + lines · total cost › proj tokens ♻cache cost + path

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

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.2.tar.gz (22.4 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.2-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ccbar-0.1.2.tar.gz
  • Upload date:
  • Size: 22.4 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.2.tar.gz
Algorithm Hash digest
SHA256 0ea7874bc7f9db78a32e3bb0e90910a6cdc1664eaf65059775490d0deb4f1dd2
MD5 536dd16b8ee37c84a5ddc40256f394e2
BLAKE2b-256 1e61975b5c2407bc4339416b5d273be6d4be4d0c44e5d03c75bf55e8cbdbf034

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ccbar-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 602fbe2cce5710d3421f56604a1a8d89ffb2db0cba21d5fd6e97fd8f0257a5e9
MD5 18a9e65666a34b3c7b677cf191104bd0
BLAKE2b-256 23491b84959d0a13fe010fbcf4d60d3c81a457817f48cfb967000be33fa3a7ae

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