Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Track and report Claude Code token usage, spending, and budgets from a local cost-tracking database. Use when the user asks about costs, spending, usage, tokens, budgets, or cost breakdowns by project, tool, session, or date.
.claude/skills/cost-tracking/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 87% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 27% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 0% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 5% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 23% | 0% |
Use this skill to analyze Claude Code cost and usage history from the metrics log that ECC's stop:cost-tracker hook writes.
The tracker appends one JSON object per session-stop to ~/.claude/metrics/costs.jsonl. Each row is a cumulative snapshot for that session, so to total spend you take the latest row per session_id and sum across sessions — summing every row multiply-counts.
Row schema:
| Field | Meaning | | --- | --- | | timestamp | ISO timestamp of the snapshot | | session_id | Claude Code session identifier | | transcript_path | Path to the session transcript | | model | Model used | | input_tokens / output_tokens | Token counts | | cache_write_tokens / cache_read_tokens | Prompt-cache token counts | | estimated_cost_usd | Precomputed cumulative cost in USD for the session |
Prefer estimated_cost_usd over hand-calculating pricing — model and cache prices change, and the tracker is the source of truth.
"what is my token usage?"
First verify the log exists (use node, not sqlite3 — the tracker writes JSONL, and node is cross-platform):
bashnode -e 'const fs=require("fs"),os=require("os"),p=require("path");const f=p.join(os.homedir(),".claude","metrics","costs.jsonl");console.log(fs.existsSync(f)?"cost log found":"cost log not found: "+f)'
If the log is missing, do not fabricate usage data. Tell the user that cost tracking populates after the first session ends with the stop:cost-tracker hook enabled.
bashnode -e ' const fs=require("fs"),os=require("os"),path=require("path"); const f=path.join(os.homedir(),".claude","metrics","costs.jsonl"); if(!fs.existsSync(f)){console.log("cost log not found: "+f);process.exit(0);} const rows=fs.readFileSync(f,"utf8").split(/\r?\n/).filter(Boolean).map(l=>{try{return JSON.parse(l)}catch{return null}}).filter(Boolean); const bySession=new Map(); for(const r of rows){const k=r.session_id||r.transcript_path||r.timestamp;const p=bySession.get(k);if(!p||String(r.timestamp)>String(p.timestamp))bySession.set(k,r);} const latest=[...bySession.values()]; const cost=r=>Number(r.estimated_cost_usd)||0, day=r=>String(r.timestamp||"").slice(0,10), sum=a=>a.reduce((s,r)=>s+cost(r),0), f4=n=>"$"+n.toFixed(4); const today=new Date().toISOString().slice(0,10), yest=new Date(Date.now()-864e5).toISOString().slice(0,10); console.log("today: "+f4(sum(latest.filter(r=>day(r)===today)))+" | yesterday: "+f4(sum(latest.filter(r=>day(r)===yest)))+" | total: "+f4(sum(latest))+" ("+latest.length+" sessions)"); const m=new Map();for(const r of latest){const k=r.model||"(unknown)";m.set(k,(m.get(k)||0)+cost(r));} console.log("by model:");[...m.entries()].sort((a,b)=>b[1]-a[1]).forEach(([k,v])=>console.log(" "+f4(v)+" "+k)); '
For a session drilldown or CSV export, iterate the same latest set (or the raw rows for CSV) and print the fields you need.
When presenting cost data, include today's spend vs yesterday, total across all sessions, a by-model breakdown, and session count. Format sub-dollar amounts with four decimals, larger amounts with two.
row per session_id first.
estimated_cost_usd is present./cost-report - Command-form report over the same metrics log.cost-aware-llm-pipeline - Model-routing and budget-design patterns.token-budget-advisor - Context and token-budget planning.strategic-compact - Context compaction to reduce repeated token spend.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 4,252 | 13,528 | +218% | 1 | 1 | 0% | 738 | 2,125 | +188% | 0 | 0 | — |
case-02 | fail→fail | 2,941 | 16,606 | +465% | 1 | 1 | 0% | 526 | 2,011 | +282% | 0 | 0 | — |
case-03 | fail→fail | 3,584 | 32,733 | +813% | 1 | 1 | 0% | 622 | 2,131 | +243% | 0 | 0 | — |
case-04 | fail→pass | 4,781 | 2,661 | -44% | 1 | 1 | 0% | 898 | 1,677 | +87% | 0 | 0 | — |
case-05 | fail→pass | 7,829 | 3,051 | -61% | 1 | 1 | 0% | 1,360 | 1,722 | +27% | 0 | 0 | — |
case-06 | pass→pass | 9,413 | 4,604 | -51% | 1 | 1 | 0% | 1,661 | 2,078 | +25% | 0 | 0 | — |
case-07 | fail→pass | 9,171 | 2,871 | -69% | 1 | 1 | 0% | 1,728 | 1,736 | +0% | 0 | 0 | — |
case-12 | pass→fail | 8,206 | 2,423 | -70% | 1 | 1 | 0% | 1,442 | 1,705 | +18% | 0 | 0 | — |
case-08 | pass→pass | 9,811 | 2,197 | -78% | 1 | 1 | 0% | 1,710 | 1,690 | -1% | 0 | 0 | — |
case-09 | pass→pass | 7,362 | 2,334 | -68% | 1 | 1 | 0% | 1,171 | 1,637 | +40% | 0 | 0 | — |
case-10 | fail→pass | 12,901 | 6,768 | -48% | 1 | 1 | 0% | 2,419 | 2,546 | +5% | 0 | 0 | — |
case-11 | fail→pass | 9,278 | 4,510 | -51% | 1 | 1 | 0% | 1,770 | 2,170 | +23% | 0 | 0 | — |
case-13 | pass→pass | 9,667 | 3,859 | -60% | 1 | 1 | 0% | 1,653 | 1,812 | +10% | 0 | 0 | — |
case-14 | fail→pass | 7,740 | 2,229 | -71% | 1 | 1 | 0% | 1,411 | 1,563 | +11% | 0 | 0 | — |
case-15 | fail→fail | 10,213 | 2,433 | -76% | 1 | 1 | 0% | 1,718 | 1,665 | -3% | 0 | 0 | — |
case-16 | pass→pass | 7,901 | 1,687 | -79% | 1 | 1 | 0% | 1,267 | 1,520 | +20% | 0 | 0 | — |
case-21 | pass→pass | 6,164 | 2,129 | -65% | 1 | 1 | 0% | 1,075 | 1,589 | +48% | 0 | 0 | — |
case-17 | pass→pass | 4,663 | 3,042 | -35% | 1 | 1 | 0% | 883 | 1,840 | +108% | 0 | 0 | — |
case-18 | fail→pass | 10,612 | 6,287 | -41% | 1 | 1 | 0% | 1,969 | 2,312 | +17% | 0 | 0 | — |
case-19 | pass→pass | 11,303 | 5,890 | -48% | 1 | 1 | 0% | 1,940 | 2,193 | +13% | 0 | 0 | — |
case-20 | pass→pass | 9,522 | 4,178 | -56% | 1 | 1 | 0% | 1,602 | 1,926 | +20% | 0 | 0 | — |
case-22 | fail→pass | 7,497 | 4,791 | -36% | 1 | 1 | 0% | 1,419 | 2,177 | +53% | 0 | 0 | — |
case-23 | pass→pass | 8,534 | 6,903 | -19% | 1 | 1 | 0% | 1,378 | 2,388 | +73% | 0 | 0 | — |
case-24 | pass→pass | 13,535 | 9,951 | -26% | 1 | 1 | 0% | 2,715 | 3,208 | +18% | 0 | 0 | — |
case-25 | pass→pass | 14,548 | 10,592 | -27% | 1 | 1 | 0% | 2,943 | 3,440 | +17% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted, and 22 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +28 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 7/27/2026 | +41% |
Other measured skills in the registry, with their headline benchmark lift.