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.jsonfrom then on. - One static HTML file, no external dependencies.
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>
| 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).
- Input / cache read / cache write: the
usageof every API response in the transcripts, deduplicated by message id. - Output:
output_tokensin transcripts is mostly a streaming placeholder, so it is estimated from response content length ÷ 3.5 (within ~2% of/costin testing). - USD: the tokens above ×
pricing.json(Anthropic list prices; edit as needed). Through Bedrock or a company gateway,/costmay 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).
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.