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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ccbar-0.1.3.tar.gz
  • Upload date:
  • Size: 22.6 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.3.tar.gz
Algorithm Hash digest
SHA256 46cb7469b330e8f05cd460ec6332a71d4de97c8992a301492621cb1f3680eb63
MD5 5c5ef76f47d40372be24c046993503f6
BLAKE2b-256 41e401e47387abe5bb8bf44d19ac898dfe6420f785b33713e2545affe36ee3f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ccbar-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 eb3ae6300698b65ac2a17973995925a13da527047828975fe61d72342104dadc
MD5 c0325bee559eb003e3ffb4673d3041d2
BLAKE2b-256 0b1138bfdd51656e38e3c072f8680b5f84493dae25fd11f58c3b7a89e2b00115

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