{"id":30444460,"url":"https://github.com/badlogic/cccost","last_synced_at":"2025-09-15T10:55:14.257Z","repository":{"id":310418914,"uuid":"1039728191","full_name":"badlogic/cccost","owner":"badlogic","description":"Instrument Claude Code to track actual token usage and cost","archived":false,"fork":false,"pushed_at":"2025-08-18T00:43:19.000Z","size":0,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-18T01:31:10.852Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badlogic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-17T21:26:26.000Z","updated_at":"2025-08-18T00:55:42.000Z","dependencies_parsed_at":"2025-08-18T01:31:12.689Z","dependency_job_id":"c477de07-197b-4cee-a215-7d147e8aa99e","html_url":"https://github.com/badlogic/cccost","commit_stats":null,"previous_names":["badlogic/cccost"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/badlogic/cccost","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badlogic%2Fcccost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badlogic%2Fcccost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badlogic%2Fcccost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badlogic%2Fcccost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badlogic","download_url":"https://codeload.github.com/badlogic/cccost/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badlogic%2Fcccost/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275246318,"owners_count":25430805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-23T10:02:17.146Z","updated_at":"2025-09-15T10:55:14.218Z","avatar_url":"https://github.com/badlogic.png","language":"TypeScript","readme":"# cccost - Claude Code Cost Tracker\n\nTrack token usage and costs for your Claude Code sessions in real-time.\n\n## Problem\nClaude 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.\n\n## What Claude Code Cost Tracker does\nClaude 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:\n\n```bash\ncccost --dangerously-skip-permissions\n```\n\ncccost 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.\n\nThe 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.:\n\n```json\n{\n  \"requests\": 7,\n  \"totalCost\": 0.10331005,\n  \"models\": {\n    \"claude-3-5-haiku-20241022\": {\n      \"requests\": 6,\n      \"input_tokens\": 731,\n      \"output_tokens\": 99,\n      \"cache_creation_input_tokens\": 0,\n      \"cache_read_input_tokens\": 0,\n      \"cost\": 0.0009808,\n      \"last\": {\n        \"utcTimestamp\": 1755475841151,\n        \"input_tokens\": 335,\n        \"output_tokens\": 9,\n        \"cache_creation_input_tokens\": 0,\n        \"cache_read_input_tokens\": 0,\n        \"cost\": 0.000304\n      }\n    },\n    \"claude-opus-4-1-20250805\": {\n      \"requests\": 1,\n      \"input_tokens\": 3,\n      \"output_tokens\": 12,\n      \"cache_creation_input_tokens\": 4761,\n      \"cache_read_input_tokens\": 8077,\n      \"cost\": 0.10232925,\n      \"last\": {\n        \"utcTimestamp\": 1755475842778,\n        \"input_tokens\": 3,\n        \"output_tokens\": 12,\n        \"cache_creation_input_tokens\": 4761,\n        \"cache_read_input_tokens\": 8077,\n        \"cost\": 0.10232925\n      }\n    }\n  }\n}\n```\n\nYou can use that to write accurate statusline scripts that display e.g. context usage or cost for the current session. Simply read the \u003csessionid\u003e.usage.json file for the current session to get the statistics.\n\nThe GitHub repository includes an example [statusline.js](./statusline.js).\n\n## Installation\n\n```bash\nnpm install -g @mariozechner/cccost\n```\n\n## Usage\n\nSimply start Claude Code via `cccost` instead of `claude`:\n\n```bash\n# Track a Claude Code session\ncccost --dangerously-skip-permissions --model sonnet\n```\n\n## Options\n- `--ccc-verbose`: cccost will output debug logging during the session\n\n## Development\n\n```bash\n# Clone the repository\ngit clone https://github.com/badlogic/cccost.git\ncd cccost\n\n# Install dependencies\nnpm install\n\n# Debugging, e.g. via VS Code JavaScript Debug Terminal\n# Do this once to disable anti-debug in your Claude Code\n# install, otherwise you won't be able to debug cccost\nnpx @mariozechner/cc-antidebug patch\n\nnpx tsx src/cli.ts\n\n# Build\nnpm run build\n```\n\n## License\n\nMIT\n\n## Author\n\nMario Zechner\n","funding_links":[],"categories":["Usage Tracker"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadlogic%2Fcccost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadlogic%2Fcccost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadlogic%2Fcccost/lists"}