cost-report
Skill1 starsChanged 12 days agoMITView on GitHub
Report Claude Code token usage, API-equivalent cost and plan-limit usage from a local ledger built from session transcripts: per session, per subagent (with the nested agent tree), per subagent type, model × effort, day, skill, project, cache behaviour, subagent fan-out, recorded 5-hour/weekly limit snapshots, and reconciliation against Claude Code's own cost figure. Use when asked what something cost, how many tokens a session or subagent used, where spend goes, how close the plan limits are, which skills or agents are expensive, or about cache efficiency; or by name (/cost-report). Numbers come only from the scripts; never estimate them.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- telerik/observability-skillstheir own version, first seen Oct 22, 2026
- QuixiAI/Hexistheir own version, first seen Oct 8, 2026
- QuixiAI/agi-memorytheir own version, first seen Oct 8, 2026
- jpoindexter/theft-kittheir own version, first seen May 20, 2026
- Manavarya09/cost-guardiantheir own version, first seen Apr 8, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- QuixiAI/agi-memory★ 623same name
- QuixiAI/Hexis★ 623same name
- Manavarya09/cost-guardian★ 35same name
- jpoindexter/theft-kit★ 1same name
- telerik/observability-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- skills/review-core/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ai-harness-engineeringSkill
- rag-ui-redesignSkill
- review-coreSkill
- tdd-specSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Use one fixed Python 3.12 interpreter, written <python> below, and never a bare python: on Windows it may be a Store stub.
- Distinctive: line 47
Add two or three observations taken from the numbers, for example the top cost driver, the subagent share, or the cache-write cost after …
- Distinctive: line 58
Do not compute, extrapolate or round figures beyond what the JSON contains.
- Very specific: line 95
The hooks: always exit 0 and print nothing.
- Very specific: line 100
If
--level limitsstays empty,: read cost/statusline-last.json.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
cost-report: usage, cost and limits
Args: [level] [window] [--session ID] [--project NAME]. Defaults: session, last 7 days.
Design and decisions: design.md.
Run
Use one fixed Python 3.12 interpreter, written <python> below, and never a bare python: on
Windows it may be a Store stub. From PowerShell:
& "<python>" "$env:CLAUDE_CONFIG_DIR/skills/cost-report/scripts/rollup.py" --level <level> --since <window> --format jsonPick the level from the question.
Question Level Most expensive sessions; main vs subagent split sessionOne session, broken down by agent tree --session <id prefix>Which subagent types cost most agent-typeWhat each model × effort costs model-effortSpend over time dayCost per skill skillCost per repo projectCache efficiency; idle-gap rewrites cacheHow much fan-out costs fanoutHow close the 5-hour/weekly limits are limitsDoes the ledger match Claude Code reconcileWindow:
--since 24h|7d|2w|YYYY-MM-DD|all.- Run the script. It first ingests new transcript lines, then prints JSON.
- Present the result.
- Show a compact table of
rows(and anysections). - Add two or three observations taken from the numbers, for example the top cost driver, the subagent share, or the cache-write cost after idle gaps.
- Show a compact table of
- Always state the cost basis. Figures are API list prices. On a Pro/Max subscription
they are an API-equivalent comparison, not a bill. The plan's real limits are the 5-hour and
weekly percentages in
limits. - Repeat every warning in
totals:incomplete_output(cost is a lower bound);unpriced/unpriced_models;assumed_price_models;anomalies_ledger_wide.
Do not compute, extrapolate or round figures beyond what the JSON contains. If the script fails, report its error output as it is.
Other commands:
$py = "<python>"; $s = "$env:CLAUDE_CONFIG_DIR/skills/cost-report/scripts"
& $py "$s/ingest.py" scan # incremental ingest of every transcript
& $py "$s/ingest.py" scan --full # re-read everything (idempotent)
& $py "$s/rollup.py" --level day --since 2w # table output for a humanThe ledger is $CLAUDE_CONFIG_DIR/cost/ledger.db; override it with $COST_LEDGER_DB. It's local
runtime data, ignored by git, and holds no prompt or response text.
Setup (once per machine)
- Backfill:
& $py "$s/ingest.py" scan. - Retention:
settings.jsonsets"cleanupPeriodDays": 365, so transcripts outlive the default 30 days. Hooks and status line. Merge this into
settings.json, with<python>and<config>as absolute paths (settings.example.json has the same block)."hooks": { "SessionStart": [{ "hooks": [{ "type": "command", "timeout": 60, "command": "<python> <config>/skills/cost-report/scripts/ingest.py hook --scan" }]}], "SessionEnd": [{ "hooks": [{ "type": "command", "timeout": 30, "command": "<python> <config>/skills/cost-report/scripts/ingest.py hook" }]}] }, "statusLine": { "type": "command", "command": "<python> <config>/skills/cost-report/scripts/statusline.py" }- Shell-neutral commands. Absolute paths with no spaces need no quotes and no PowerShell
&, so the same command works whether Claude Code runs it through PowerShell, Git Bash orcmd. Hooks run through PowerShell on this machine; the status line's shell is unconfirmed. - The hooks always exit 0 and print nothing; errors go to
cost/errors.log. - The status line shows
[model] · 5h 34% (Sat 14:00) · wk 61% (Mon 09:00) · session $2.10 API-eq. It records each change in a limit to the ledger, which feeds--level limits. - The paths are machine-specific, like the Node path in
CLAUDE.md.
If
--level limitsstays empty, readcost/statusline-last.json. The status line rewrites it on every refresh, with key names only (no values).- The file is missing: Claude Code never ran the command. Check the
statusLineblock and restart the session. erroris"empty stdin": the command ran but got no input. The status line also shows[cost-report: empty stdin]in that case.rate_limitsisnullbuthas_costis true: Claude Code isn't sending plan limits for this account. Subscription limits then have to be estimated (design.md section 7).
- Shell-neutral commands. Absolute paths with no spaces need no quotes and no PowerShell
Known limits
- Subagent output is under-counted. Subagent transcripts often miss the final output count.
Each subagent's last request is restored from the parent's tool result; the rest stay flagged
as
incomplete. - Background calls are missing. Title generation and similar calls never appear in
transcripts.
reconcileshows them as the unattributed gap, where Claude Code wrote its own figure. - Subscription limits are shared. They are also consumed by claude.ai and other devices, so
usd_per_pctinlimitsis an upper-bound estimate.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

