Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

claude-spend

A Claude Code cost dashboard: tokens and estimated USD for every turn, grouped by turn / commit / session / project / day, so you can see where the money goes.

  • Pure local Python (stdlib only) that parses the transcripts Claude Code already writes. No model calls.
  • Shows history from before you installed it (within the transcript retention period, 30 days by default). History accumulates in ~/.claude-spend/turns.json from then on.
  • One static HTML file, no external dependencies.

Install (plugin)

In Claude Code:

/plugin marketplace add <this-repo-git-url>
/plugin install spend-tracker@spend-tracker

Or from a shell: claude plugin install spend-tracker --marketplace <this-repo-git-url>

Usage

What How Cost
Refresh and open the dashboard Type /spend in Claude Code One short reply (~$0.01–0.05, depending on current context size)
Same, without any model call ! python3 <plugin-path>/collect.py, or run it from a shell 0
Keep data fresh automatically Built in: a hook runs collect.py --quiet at the end of every session 0

collect.py starts a small server on http://localhost:8765, bound to 127.0.0.1 only (it exits after 4 hours), and opens it via $BROWSER. VS Code Remote forwards the port automatically, so it opens in your local browser. On a desktop machine it opens the browser directly.

No plugin needed: git clone the repo and run python3 collect.py.

Options: --no-open (refresh only, print the file path), --quiet (for hooks, no output). Environment variables: CLAUDE_SPEND_PORT, CLAUDE_SPEND_DIR (default ~/.claude-spend), CLAUDE_CONFIG_DIR (default ~/.claude).

How the numbers are computed

  • Input / cache read / cache write: the usage of every API response in the transcripts, deduplicated by message id.
  • Output: output_tokens in transcripts is mostly a streaming placeholder, so it is estimated from response content length ÷ 3.5 (within ~2% of /cost in testing).
  • USD: the tokens above × pricing.json (Anthropic list prices; edit as needed). Through Bedrock or a company gateway, /cost may use different rates.
  • Commit grouping: each turn goes to the first commit in the same repo, by you, made after the turn ended (a heuristic).

Privacy

Everything stays on your machine. turns.json stores the first 120 characters of each prompt. The server binds to 127.0.0.1 only, but other users on the same machine can still reach that port.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages