Find where your Claude Code tokens are leaking — with $ impact and fixes.
npx github:yurukusa/cc-token-diet
The npm package is not yet published. Use the GitHub-direct form above for now; an
npx cc-token-dietshort form will be added when published.
Reads your local Claude Code conversation logs (~/.claude/projects/), detects
specific waste patterns, and tells you which sessions cost the most and what to
change. Nothing leaves your machine.
Other tools tell you how much you spent. cc-token-diet tells you where
the waste is and how to stop it:
- Cache write ratio — if you're rewriting the cache too often (>30 %), you're paying 12.5× what a stable context would cost.
- Verbose output — sessions where the model averages >3K output tokens per turn, usually because it's been asked to "explain everything."
- Runaway sessions — long single sessions (>100 assistant turns) that bloat context exponentially. These are where the money quietly disappears.
Each finding comes with a concrete fix and the Token Book chapter that covers it in depth.
📉 cc-token-diet report (last 7 days)
────────────────────────────────────────────────────────
Sessions analysed: 312 Assistant turns: 36973
Input: 457.8K Output: 7.36M
Cache read: 5.21B Cache write: 87.15M
API-equivalent spend: $10007.22 (Opus 4.x pricing)
↳ On Max/Pro you pay the flat subscription; this is context intensity
↳ On Sonnet divide by ~5. The patterns stay the same either way.
Cache hit ratio: 98.4% (higher is better, aim >85%)
🔥 Waste patterns:
❗ 87 runaway session(s) (>100 assistant turns) (≈ $2726.01 wasted)
Fix: Long single sessions bloat context exponentially.
Use /compact or restart for each logical task.
See: Token Book ch3 (context management)
🌡️ Hottest sessions:
$513.26 2026-04-19 projects-cc-loop 955 turns / 157min
$499.34 2026-04-16 -home-namakusa 898 turns / 3898min
$431.08 2026-04-20 projects-cc-loop 1103 turns / 180min
This is real output from the author's own logs. A 7-day window surfaced 87 runaway sessions worth ~$2,700 of context intensity that could have been trimmed by splitting into smaller sessions. Your numbers will differ — but the shape is how you know what to change.
# default — last 7 days
npx github:yurukusa/cc-token-diet
# wider window
npx github:yurukusa/cc-token-diet --days 30
# machine-readable
npx github:yurukusa/cc-token-diet --json > report.jsonRuns 100 % locally. No network calls. No analytics. The tool only reads the
.jsonl logs Claude Code already writes to ~/.claude/projects/. If you want
to verify, the source is one file: cli.mjs.
Cost estimates use public Anthropic Opus 4.x API pricing (input $15/MTok, output $75/MTok, cache read $1.50/MTok, cache create $18.75/MTok). Actual subscription users (Pro/Max) aren't billed per token — treat the number as "what your session would cost on the API" and watch it relative to your plan's headroom.
If you mostly run on Sonnet, divide by ~5. The patterns still surface the same inefficiencies either way.
cc-cost-check— calculates cost per commit/hour/day from aggregate statscc-cost-forecast— projects API-equivalent spend to month-endcc-token-diet— finds specific waste patterns in your sessions and tells you how to fix them
Use them together: forecast your pace, audit your waste, fix the leaks.
The full token-saving playbook (10 chapters, 40+ documented symptoms, real incidents with hook examples):
- Token Book (¥2,500) — https://ko-fi.com/s/fd44ef09a7
- Free first chapter — https://zenn.dev/yurukusa/books/token-savings-guide
cc-token-diet shows you this month's waste. The patterns that cause it keep
changing as Claude Code evolves.
CC Safety Lab Founder (¥500/mo Ko-fi Membership) delivers a monthly
digest: 3–5 curated incidents from GitHub with fixes, 1 new safety hook, 1
measured token-saving technique with actual $ data, and early access to Token
Book updates. Issue #1 ships 2026-05-01. Founder price locked for charter
members.
MIT