GitHub - Ventuss-OvO/cc-costline: Enhanced statusline for Claude Code — see your 7d/30d spend at a glance

3 min read Original article ↗

中文 | 日本語 | Français | Español

Enhanced statusline for Claude Code — adds cost tracking, usage limits, and leaderboard rank to your terminal.

cc-costline screenshot

14.6k ~ $2.42 / 40% by Opus 4.6 | 5h: 45% / 7d: 8% | 30d: $866 | #2/22 $67.0

Install

npm i -g cc-costline && cc-costline install

Open a new Claude Code session and you'll see the enhanced statusline. Requires Node.js >= 22.

What you get

Segment Example Description
Tokens ~ Cost / Context 14.6k ~ $2.42 / 40% by Opus 4.6 Session token count, cost, context usage, and model
Usage limits 5h: 45% / 7d: 8% Claude 5-hour and 7-day utilization (auto-colored like context). At 100%, shows countdown: 5h:-3:20
Period cost 30d: $866 Rolling cost total (configurable: 7d, 30d, or both)
Leaderboard #2/22 $67.0 ccclub rank (if installed)

Colors

  • Context & usage limits — green (< 60%) → orange (60-79%) → red (≥ 80%)
  • Leaderboard rank — #1 gold, #2 white, #3 orange, others cyan
  • Period cost — yellow

Optional integrations

  • Claude usage limits — reads OAuth credentials from macOS Keychain automatically. Just claude login and it works.
  • ccclub leaderboard — install ccclub (npm i -g ccclub && ccclub init). Rank appears automatically.

Both are zero-config: if not available, the segment is silently omitted.

Commands

cc-costline install              # Set up Claude Code integration
cc-costline uninstall            # Remove from settings
cc-costline refresh              # Manually recalculate cost cache
cc-costline config --period 7d   # Show 7-day cost (default)
cc-costline config --period 30d  # Show 30-day cost
cc-costline config --period both # Show both periods

How it works

  1. install configures ~/.claude/settings.json — sets the statusline command and adds session-end hooks. Your existing settings are preserved.
  2. render is called by Claude Code on every turn. It reads stdin JSON for session data, then refreshes all data sources inline when their cache expires (2-minute TTL):
    • Local cost: scans ~/.claude/projects/**/*.jsonl, applies per-model pricing → ~/.cc-costline/cache.json
    • Usage limits: fetches api.anthropic.com/api/oauth/usage/tmp/sl-claude-usage
    • ccclub rank: fetches ccclub.dev/api/rank/tmp/sl-ccclub-rank
  3. refresh can also be run manually or via session-end hooks to warm the cost cache.
Pricing table

Prices per million tokens (USD):

Model Input Output Cache Write Cache Read
Opus 4.6 $5 $25 $6.25 $0.50
Opus 4.5 $5 $25 $6.25 $0.50
Opus 4.1 $15 $75 $18.75 $1.50
Sonnet 4.5 $3 $15 $3.75 $0.30
Sonnet 4 $3 $15 $3.75 $0.30
Haiku 4.5 $1 $5 $1.25 $0.10
Haiku 3.5 $0.80 $4 $1.00 $0.08

Unknown models fall back by family name, defaulting to Sonnet pricing.

Development

npm test    # Build + run unit tests (node:test, zero dependencies)

Uninstall

cc-costline uninstall
npm uninstall -g cc-costline

Acknowledgments

License

MIT