From token-audit
Audits Claude Code token usage by analyzing JSONL transcripts, config inventory, and ccu sage baseline to identify high-impact leaks with estimated weekly savings.
How this skill is triggered — by the user, by Claude, or both
Slash command
/token-audit:token-auditThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Find where Claude Code tokens are leaking — and what to fix first.
references/additional-optimizations.mdreferences/hook-design.mdreferences/leak-taxonomy.mdreferences/thariq-heuristics.mdscripts/audit.pyscripts/bottlenecks.pyscripts/config_inspector.pyscripts/cost_model.pyscripts/detectors/__init__.pyscripts/detectors/bash_antipatterns.pyscripts/detectors/cache.pyscripts/detectors/claude_md_bloat.pyscripts/detectors/context.pyscripts/detectors/file_reads.pyscripts/detectors/hook_bloat.pyscripts/detectors/model_selection.pyscripts/detectors/recurring_scripts.pyscripts/detectors/skill_descriptions.pyscripts/detectors/tool_schema.pyscripts/ensure_ccusage.pyFind where Claude Code tokens are leaking — and what to fix first.
Runs a local-only audit with three inputs:
~/.claude/projects/**/*.jsonl (Claude Code CLI)~/Library/Application Support/Claude/local-agent-mode-sessions/**/.claude/projects/**/*.jsonl (Claude desktop "cowork" / local-agent-mode sessions)~/.claude/settings.json, plugins, skills, MCP serversThen produces a ranked report of leaks with ballpark weekly $ savings for each.
python SKILL_DIR/scripts/audit.py --days 7
Outputs JSON to stdout. You (Claude) then synthesize a narrative report in the user's language — default English, switch to match the user's current conversation language.
/compact, /rewind, MCP, CLAUDE.md) stay untranslatedreferences/additional-optimizations.md for seeds (language efficiency, off-peak shifting, runaway cron check, local-model offloading, cache-TTL strategy, desktop-client blindness, skill pruning) and the brainstorming pattern. Curate 1-3 that actually apply to THIS user — don't list them all. If nothing fits, skip the section entirely.| Detector | What it catches | Source |
|---|---|---|
tool_schema | Full MCP tool schemas loaded every turn (~20k tok) — only fires if ENABLE_TOOL_SEARCH is OFF | Samarth Gupta audit |
hook_bloat | Session-start / PreCompact hooks re-injecting large output into every session | Novel |
claude_md_bloat | CLAUDE.md > 2k tokens, paid on every turn | Anthropic cost doc (200-line target) |
model_selection | Opus used on short/simple turns where Sonnet would suffice | Novel |
context | Turns past 400k-token context (context rot zone) | Thariq Shihipar, Anthropic |
skill_descriptions | Total skill-description budget per turn (flags fat individual skills + bloated totals) | Novel |
bash_antipatterns | cat/head/tail/find/grep via Bash instead of native Read/Glob/Grep | Samarth Gupta audit |
cache | Sessions with <50% cache hit ratio (churn-driven cache misses) | Novel |
file_reads | Same file Read 3+ times in one session (rewind candidate) | Thariq Shihipar, Anthropic |
npx — no install needed)~/.claude/projects/, ~/.claude/settings.json, and (if you use the Claude desktop app's cowork mode) ~/Library/Application Support/Claude/local-agent-mode-sessions/ (already yours)If ccusage is unavailable, the audit proceeds without baseline $ totals — detectors still work from JSONLs alone.
Most users are on a flat-rate subscription (Pro $20 / Max 5x $100 / Max 20x $200). Reporting "saves $2,200/week" when they pay $200 flat is misleading — they won't "save" that from their pocket. What they actually gain:
Narration rules when writing the report:
Detectors compute all of:
est_weekly_tokens — honest, plan-neutral primary metricest_weekly_cost_usd — at API list pricingest_weekly_savings_usd — what the fix would eliminate (at list pricing)Plan limits are published in scripts/cost_model.py (Pro/Max5x/Max20x ranges). Use plan_savings_summary(amount, plan) helper to generate the "≈ X% of subscription-week" phrasing.
Why we still compute dollars internally: for ranking. Dollar impact is the cleanest way to prioritize leaks across heterogeneous categories.
audit.py --days 7"Want me to apply any of these? I can: (a) add the Sonnet default to
<project>/.claude/settings.json, (b) trim the oversized CLAUDE.md, (c) enableENABLE_TOOL_SEARCH. Pick any."
references/hook-design.md for principles and patterns. Critical rules:
claude-code-guide agent or https://code.claude.com/en/docs/claude-code/hooks for the current hook API before writing any hook code — the spec changes, don't rely on memoryreferences/hook-design.md; surface this in step 5 of the invocation pattern)AGENTS.md, reasoning_effort), Aider (.aider.conf.yml, map-tokens), Cursor (Auto vs API pool routing).claudeignore absence, plan-mode underuse, stale-session resume, pasted-blob vs @file mentionsBaked into the analysis:
npx ccusage@latest fetch.Creates bite-sized, testable implementation plans from specs or requirements, with file structure and task decomposition. Activates before coding multi-step tasks.
npx claudepluginhub bayramannakov/token-audit-skill --plugin token-audit