Cccost
Description
Track token usage and costs for your Claude Code sessions in real-time.
Installation
claude install-skill https://github.com/badlogic/cccost README
cccost - Claude Code Cost Tracker
Track token usage and costs for your Claude Code sessions in real-time.
Problem
Claude Code does not show cost for users of the Pro and Max plan when using the `/cost` command. API users enjoy that privilege. Except that [`/cost` has a bug (CC 1.0.83)](https://x.com/badlogicgames/status/1957221028603535617). And if you wrote a fancy [statusline](https://docs.anthropic.com/en/docs/claude-code/statusline) script and think you can just parse the session transcript to get token usage and cost, think again. The transcript does not contain all requests Claude Code issues to the Anthropic servers.
What Claude Code Cost Tracker does
Claude Code cost track is a minimally invasive tool. Instead of running Claude Code directly, run your session via cccost. All arguments you pass will be forwarded to Claude Code verbatim:
cccost --dangerously-skip-permissions
cccost spawns Claude Code and injects [this code](./src/interceptor.ts). It hooks the NodeJS `fetch()` function and intercepts all API requests to Anthropic's servers. It then writes a file ~/.claude/projects/mangled-current-working-dir/sessionid.usage.json and keeps updating it with every new request. As opoosed to Claude Code's `/cost` slash command, this also accurately tracks cost and token usage when resuming sessions.
The file contains total input/output/cache read/cache write statistics per model, the usage stats for the last request made with each model, and the total cost. E.g.:
{
"requests": 7,
"totalCost": 0.10331005,
"models": {
"claude-3-5-haiku-20241022": {
"requests": 6,
"input_tokens": 731,
"output_tokens": 99,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cost": 0.0009808,
"last": {
"utcTimestamp": 1755475841151,
"input_tokens": 335,
"output_tokens": 9,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
...
Related Skills
next.js
| The React Framework | 138360 | 1503 | 1 |
Development community sharing-skills
skill for guidance.
Development community root-cause-tracing
Use when errors occur deep in execution and you need to trace back to find the original trigger.
Development community Template Skill
Minimal skeleton for a new skill project structure.
Development community Third-party Notices
THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THIS PRODUCT. ---
Development official Claude API
When code imports anthropic/@anthropic-ai/sdk/claude_agent_sdk, or user asks to use Claude APIBuild apps with the Claude API or Anthropic SDK
Development official Related Agents
Openai Codex CLI
(55.8k ⭐) - Lightweight coding agent that runs in your terminal.
Contributing to nanobot
Thank you for being here. nanobot is built with a simple belief: good tools should feel calm, clear, and humane. We care deeply about useful features, but we also believe in achieving more with less:
Key exports from each phase
for summary in .planning/phases/*/*-SUMMARY.md; do echo "=== $summary ===" grep -A 10 "Key Files\|Exports\|Provides" "$summary" 2>/dev/null done