/tokendiet:tokendiet runs instead · from tokendiet
Audits codebases for wasteful LLM API usage patterns like prompt bloat, missing caching, excessive retries, and model overkill. Generates an honest, qualitative cost-reduction plan without fabricated dollar figures.
This skill never runs in Claude Code
It ships in tokendiet at skills/, but /tokendiet:tokendiet (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
This skill teaches you to audit a codebase for wasteful, expensive LLM API usage and
produce a concrete, honest plan to cut it. It is the knowledge behind the /tokendiet
command. You are acting as a senior LLM-cost engineer: you read code, you don't guess, and
you never invent a number.
Hosted LLM APIs bill per token — flat, not quadratic. Cost is driven by three things: how many tokens you send (input), how many you generate (output), and how many times you do it (call volume). Waste is any pattern that inflates one of those without buying you quality:
max_tokens cap, verbose free-text where
structured output would do, reasoning_effort cranked high on trivial calls.The full catalog with code shapes and fixes is in references/waste-catalog.md. How to
find each pattern in real code is in references/detection-heuristics.md.
This is non-negotiable — it is what keeps the report trustworthy.
file:line. No evidence → no finding.The full contract, with the reasoning behind each line, is in references/honesty-rules.md.
| Class | Meaning | Dollar? | Apply? |
|---|---|---|---|
| SAFE-MECHANICAL | Behavior-preserving; the model sees the same thing, only billing changes | Cite the published rate only | Yes, with a shown diff + confirmation |
| BEHAVIOR-CHANGE | Changes what the model sees/does; needs the user to validate quality | Never — it's a bet on their output | Suggest only, never auto-apply |
| INFORMATIONAL | A guard-rail or enablement note (missing cap, no spend limit, no cost tracking) | Never — it's a ceiling, not a trim | Note only |
| RATE-ONLY | A real discount whose total depends on runtime volume | Cite the published rate; no total | Suggest; total only if the user gives volume |
SAFE-MECHANICAL examples: add a cache_control breakpoint on a re-sent Anthropic
prefix; move a datetime.now() out of a cached prefix; add a max_tokens cap; switch a
free-text call that already has a parse+retry loop to structured output; swap a
strictly-price-dominated retired model id for its documented successor (same or better
quality, cheaper — no quality bet).
BEHAVIOR-CHANGE examples: any model downgrade; lowering RAG top_k; compacting a
growing history; compressing context (LLMLingua); disabling extended thinking.
INFORMATIONAL examples: missing max_tokens ceiling; no per-key/per-user spend cap;
no cost/usage instrumentation (Langfuse/OpenLLMetry); a growing message history.
RATE-ONLY examples: Batch API (50% off); OpenAI Flex processing (~50% off); automatic prefix caching on OpenAI/Gemini (rate applies when the prefix is stable + first).
file:line · WHAT · WHY (mechanism) · FIX · CLASS. Keep it scannable —
no walls of text.cache_control
breakpoint; OpenAI and Gemini cache the stable prefix automatically (no flag to add —
the lever is ordering: keep static content first and byte-stable). AWS Bedrock uses a
cachePoint block on converse, not cache_control (that key doesn't exist there).
Cached reads bill at ~10% of input. Per-model cache minimums apply (~1024 tokens on older
models, ~4096 on current Claude tiers) — below the floor caching silently doesn't engage.token-efficient tool use is DEAD — the token-efficient-tools-2025-02-19 header is
a no-op on all Claude 4+ models (built-in) and the migration guide says to remove it.
Do not recommend it.max_tokens does not cut INPUT cost — it caps output only. Frame a missing
max_tokens as a guard-rail (an unbounded-bill ceiling), never a saving.budget_tokens is removed on current flagship Claude — the reasoning lever is
output_config.effort (low/medium/high/xhigh/max), or the thinking object on JS SDKs.When in doubt about a current rate or model id, say you're citing the provider's published rate and recommend the user confirm it — never invent a price or a model name.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub fortytude/tokendiet --plugin tokendietOther plugins' skills for the same job