RoninForge / claude-code-cost

~1.5k tokens | View as Markdown |

claude-code-cost

v1.0.0

A Claude Code plugin. The /cost slash command shows your Claude Code spend in USD, per project and per git branch, computed locally on your machine.

Zero key. Zero prompts. Zero latency. It reads the JSONL session logs Claude Code already writes locally, and prices each response point-in-time from the open ai-price-index dataset, bundled at build time so there is no runtime network.

Then run /cost. Requires node (>= 18) on your PATH, which Claude Code users almost always have. No binary, no curl, no Homebrew.

What it does

Spend per project and branch

/cost prints your Claude Code spend grouped by project and by the git branch that was checked out when each response ran, for today, the current week, and the current month.

Lives inside Claude Code

Installs through the Claude Code plugin system. No binary to download, no curl pipe, no Homebrew. It needs only node (>= 18) on PATH, which Claude Code already relies on.

Point-in-time pricing

Each response is priced at the rate that was live on its own date, from the open ai-price-index dataset (CC BY 4.0) bundled at build time. A later price change never rewrites your past spend.

Zero network calls

Reads ~/.claude/projects/**/*.jsonl on disk. No API keys. No prompts sent anywhere. No telemetry. The pricing data is embedded, so nothing leaves the machine.

Counts cache tokens

Input, output, cache-read, and cache-write tokens are all priced. Claude Code repeats the same response across several JSONL lines, so the plugin dedups those before counting.

Works on Pro, Max, and API

On API billing the dollars are your real cost. On flat-rate Pro and Max subscriptions, token usage is still tracked and priced as a metric so you can see which work burns the most of your plan.

Install and use

  1. 1 Add the marketplace. In Claude Code, run /plugin marketplace add RoninForge/claude-code-cost.
  2. 2 Install the plugin. Run /plugin install claude-code-cost@roninforge. Requires node (>= 18).
  3. 3 See your spend. Run /cost for the full table.
  4. 4 Filter or export. /cost <filter> narrows to a project or branch, /cost --self forces the built-in reader, and /cost --json prints machine-readable output.
> /cost

PROJECT     BRANCH        TODAY    WEEK     MONTH
myapp       main          $4.85    $28.30   $112.40
myapp       feature/auth  $1.20    $3.20    $3.20
side-proj   main          $0.00    $0.50    $14.10
TOTAL                     $6.05    $32.00   $129.70

How it works

  1. 1 Read. It scans ~/.claude/projects/**/*.jsonl, the session logs Claude Code already writes to disk.
  2. 2 Dedup. Claude Code writes the same response across several JSONL lines. The plugin counts each billable assistant response once and drops the repeated lines.
  3. 3 Attribute. Each response is tagged with its project (the working-directory name) and the git branch recorded on the line.
  4. 4 Price. Each response is priced at its own date from the bundled open ai-price-index dataset (CC BY 4.0), counting input, output, cache-read, and cache-write tokens. Unknown models are surfaced rather than silently dropped.
  5. 5 Roll up. Totals are bucketed into today, the current Monday-based week, and the current calendar month, all in UTC.

What it will not do

No API keys

claude-code-cost never asks for an Anthropic key and cannot log in to your account. It only reads files you already own.

No prompts captured

Only token counts, model, project, branch, and date are read. Prompt and response text are ignored, and nothing leaves the machine.

No proxy, no middle

Not an API proxy. Not a process injector. Claude Code's traffic is completely untouched. Tooling is MIT and the bundled pricing data is CC BY 4.0.

Zero key, zero prompts, zero latency. The trust pledge is load-bearing: claude-code-cost parses what Claude Code already writes to local disk and nothing else.

Optional BudgetClaw integration

Richer view when BudgetClaw is installed

claude-code-cost is fully self-contained. But if BudgetClaw is also installed, /cost uses it automatically for a richer view backed by a persistent database and budget caps. If BudgetClaw is not present, the built-in reader is used. Run /cost --self to force the built-in reader either way.

Roll up to a dashboard

Want spend across providers and machines in one place? Goei at goei.roninforge.org unifies billing into one view. claude-code-cost stays a local, read-only plugin; the dashboard is an opt-in next step, not a requirement.

Frequently asked questions

How does claude-code-cost calculate my Claude Code spend? +

It reads the JSONL session log files Claude Code already writes to ~/.claude/projects/ on your machine, counts the billable assistant responses, and prices each response point-in-time from the bundled open ai-price-index dataset, at the rate that was in effect on that response's own date. Input, output, cache-read, and cache-write tokens are all counted. Claude Code writes the same response across several JSONL lines, so the plugin dedups those repeated lines before pricing. Nothing leaves the machine.

Do I need BudgetClaw to use claude-code-cost? +

No. claude-code-cost is self-contained and ships its own built-in JSONL reader and pricing data. If BudgetClaw happens to be installed, /cost uses it automatically for a richer view backed by BudgetClaw's persistent database. If it is not installed, the built-in reader is used. Run /cost --self to force the built-in reader even when BudgetClaw is present.

Is claude-code-cost a proxy? Does it intercept API calls? +

No. claude-code-cost reads local log files. It never sits between your editor and the Anthropic API, never asks for a key, never sees a prompt or response body, and adds no latency. Zero key, zero prompts, zero latency.

How do I install claude-code-cost? +

Inside Claude Code, run /plugin marketplace add RoninForge/claude-code-cost, then /plugin install claude-code-cost@roninforge. After that, run /cost. It requires node (>= 18) on your PATH, which Claude Code users almost always have. There is no binary to download, no curl pipe, and no Homebrew step.

Does it work on Claude Pro or Max subscriptions, not just API billing? +

Yes. It reads the same local JSONL logs regardless of how you are billed. On API usage the dollar figures are your real cost. On flat-rate Pro and Max subscriptions, token consumption is still tracked and priced as a usage metric, so you can see which projects and branches burn the most of your plan.

What data does claude-code-cost read? +

Only the local JSONL session logs under ~/.claude/projects/. From each line it uses the token counts, model id, working directory, git branch, and timestamp. Prompt and response text are ignored. Nothing is uploaded and nothing leaves your machine.

What happens when it sees a model it does not recognize? +

Unknown models are surfaced in the output rather than silently dropped, so a new Anthropic model never makes your spend look artificially low. The bundled ai-price-index dataset is updated as new models and rates land, and each release embeds a fresh copy.

claude-code-cost is one of several tools from RoninForge. See also BudgetClaw for hard spend caps, and Goei for a cross-provider billing dashboard.