usage-cost

star 1

Computes what your Claude Code usage would cost at pay-as-you-go API prices by replaying the exact per-request token usage recorded in local transcripts (~/.claude/projects). Use when comparing subscription vs API billing, or when the user asks "what would my Claude Code usage cost", "how many tokens have I used", "is the Max plan worth it", "estimate my usage under the rate limit", or "subscription vs pay-as-you-go". Do NOT use for live Anthropic Console billing data, claude.ai web/desktop usage, or direct API-key usage logs — it only sees this machine's Claude Code transcripts.

zachmayer By zachmayer schedule Updated 6/8/2026

name: usage-cost description: > Estimates what this machine's Claude Code usage would cost on each plan -- pay-as-you-go API pricing, Pro, Max 5x, and Max 20x -- by replaying the exact per-request token usage in local transcripts (~/.claude/projects) through each plan's rolling 5-hour and 7-day rate limits, then printing a table of flat fee plus estimated overage as a monthly total, ordered by plan size. Use when the user asks "which Claude plan is cheapest for me", "is Max worth it", "am I on the right plan", "what would my Claude Code usage cost", or "subscription vs pay-as-you-go". Do NOT use for live Anthropic Console billing, claude.ai web/desktop/mobile usage, other machines, or direct API-key logs -- it only sees this machine's Claude Code transcripts. allowed-tools: Bash(uv run *)

Claude Code Plan Cost Comparison

Claude Code transcripts record the exact billed usage object from every API response (input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens with 5m/1h TTL split). The script replays those requests as timestamped, API-priced events and runs each plan's rolling rate limits over them:

monthly cost = flat fee + overage (usage beyond the 5h/7d limits, billed at API rates)

It prints a table ordered by flat fee — Max 20x, Max 5x, Pro, pay-as-you-go — with no overage cap modelled (caps only block you; raising them is the norm), so total is the true cost of letting all your usage through.

Usage

uv run --script SKILL_DIR/scripts/usage_cost.py

The script declares its one dependency (Click) inline, so uv run --script installs it automatically — nothing to set up. Options:

  • --days N — only the trailing N days (e.g. --days 7 for this week's pace)
  • --breakdown — also print per-model and per-day cost
  • --projects-dir PATH — scan a different transcript root
  • --pro-5h $ / --pro-7d $ — override the calibrated Pro limits (Max tiers scale 5x/20x)

How the plan limits are calibrated (read before trusting the numbers)

Anthropic publishes plan limits only as vague "prompts per 5 hours," useless for a dollar model. The script instead carries limits expressed as API-$ of usage per rolling window, calibrated empirically (constants PRO_5H, PRO_7D at the top of the script):

  • Pro 5h limit ($20) was solved so the simulation reproduces a real Pro overage bill — the robust anchor, since it integrates many days of bursts. The fit came out ≈$20.6; it's rounded to a round $20 (which also happens to equal the $20/mo Pro price — a coincidence, not a mechanism). Treat the precision as illusory.
  • Pro 7d limit ($875) came from a live /status weekly percentage (softer; the 7-day window rarely binds — for most users overage is driven entirely by 5-hour bursts).
  • Max 5x / 20x scale Pro's limits by 5x / 20x, matching Anthropic's own framing.

These approximate Anthropic's opaque internal limits and assume an Opus-heavy, cache-heavy mix. The absolute overage figures are soft (call it ±50%); the ranking is what to trust. Two independent code reviews (Codex + Opus) pinned the only fragile boundary: Pro never wins, and Max 5× stays cheapest unless the true 5h limit is ~⅓ below this estimate (then Max 20× wins) — and both calibration anchors ($20.6 bill, $33 /status) sit at or above $20, so the estimate is more likely low than high, which only favors Max 5×. For a very different usage mix, recalibrate via --pro-5h / --pro-7d (from your own overage bill or /status).

How to read it

  • Burst shape, not raw total, drives cost. $800 spread thin can fall entirely under a cheap plan; $800 in one 5-hour window blows any plan's session limit. That's the whole point of the rolling simulation — it captures this where a monthly sum can't.
  • Pay-as-you-go is the raw API value of everything; subscriptions are typically a 5–10x discount, so the real question is which subscription.
  • The cheapest plan is flagged. The sweet spot is usually the smallest plan whose limits absorb your bursts with near-zero overage.

Caveats (also printed by the script)

  • This machine's Claude Code only — no claude.ai web/desktop, other machines, or Console billing. Calibration assumes that's the bulk of your usage.
  • Transcripts are pruned after ~30 days, so older history is a floor, not a total.
  • Records predating the cache TTL split are priced at the cheaper 5m rate.

Pricing freshness

Rates are hardcoded in BASE at the top of the script (as of 2026-06: Opus $5/$25, Sonnet $3/$15, Haiku $1/$5, Fable $10/$50 per MTok; cache read 0.1x, write 1.25x/5m & 2x/1h; no >200K long-context premium on Opus 4.7/4.8). Verify current rates — via the claude-api skill or https://platform.claude.com/docs/en/pricing — and update BASE if they've changed.

Install via CLI
npx skills add https://github.com/zachmayer/skills --skill usage-cost
Repository Details
star Stars 1
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator