Audits LLM token usage and costs across code and prompts. Runs when invoked via the tokendiet command or skill.
> /plugin marketplace add Fortytude/TokenDiet> /plugin install tokendiet@tokendiet
FAQ
tokendiet is a Claude Code plugin with 1 hand-picked skill for development work, indexed on Flowy. Install it with the command on its page. It includes tokendiet. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.
Repo: Fortytude/TokenDiet
/tokendiet finds where โ free, in your editor, in about a minute.A Claude Code plugin that audits your own repo for wasteful LLM API spend โ missing prompt caching, uncapped retries, prompt bloat, no batching, overpowered models โ and hands you a concrete, honest fix plan. Runs on your agent, your tokens, your repo. Nothing leaves your machine.
Hosted LLM APIs bill per token. Most codebases quietly re-send the same system prompt uncached on every call, run offline batch jobs on the real-time API, never cap a retry loop, and pretty-print JSON into the prompt. None of it shows up in a code review โ it shows up on the invoice.
/tokendiet reads your code the way a senior LLM-cost engineer would, finds those patterns at the exact file:line, explains the mechanism, and gives you the fix. It offers to apply the safe, behavior-preserving ones for you.
And it never invents a dollar figure. More on why that matters below โ it's the whole point.
You type /tokendiet. Your agent walks your repo and prints something like this (illustrative โ your findings and paths will differ):
## TokenDiet audit โ whole repo
Reviewed 14 LLM call-sites across 6 files. Found 4 findings.
### Safe mechanical wins (behavior-preserving โ ship these)
1. Missing prompt caching โ src/agent/planner.py:57
WHAT: a ~2,100-token system prompt + tool schema is re-sent uncached on every
Anthropic call.
WHY: cached reads bill at ~10% of the input rate (Anthropic published) โ right
now you pay full input price for the same bytes on every request.
FIX: add cache_control:{type:"ephemeral"} on the last stable system block.
CLASS: SAFE-MECHANICAL
2. Timestamp busting the cache โ src/agent/planner.py:44
WHAT: `Current time: {datetime.now()}` sits at the FRONT of the system prompt.
WHY: caching is a prefix match; a value that changes every call invalidates
everything after it, so the hit rate is ~0 even once caching is on.
FIX: move the timestamp to the end of the prompt, after the static prefix.
CLASS: SAFE-MECHANICAL (this IS the cache win for this prefix โ counted once)
### Suggestions to validate (behavior-change โ your call)
3. Overpowered model for a classify task โ src/route/intent.py:88
WHAT: `classify_intent()` calls a flagship model to pick one of 5 labels.
WHY: a small model is roughly ~5ร cheaper on input and may handle a labeling
task fine โ but a swap changes output quality.
FIX: try a cheaper same-family model and validate the labels on your own data.
CLASS: BEHAVIOR-CHANGE (a downgrade is a suggestion, never a promised saving)
### Guard-rails & notes (informational)
4. No max_tokens cap in the agent loop โ src/agent/loop.py:15
WHAT: the completion call has no max_tokens / max output ceiling.
WHY: a runaway loop or a degenerate response can emit the full output window โ
an unbounded bill. (A ceiling, not a saving โ no dollar figure.)
FIX: add an explicit max_tokens sized to what the response needs.
CLASS: INFORMATIONAL
Want me to apply the 2 safe mechanical wins? I'll show the diff first.
โ Audited by /tokendiet ยท TokenDiet by Fortytude (fortytude.dev). Free & open source.
That's the whole product. No signup, no dashboard, no dollar amount pulled out of thin air.
In Claude Code:
/plugin marketplace add Fortytude/TokenDiet
/plugin install tokendiet@tokendiet
Then run it:
/tokendiet
That's it. marketplace add points Claude Code at this repo; install pulls the tokendiet plugin from it. No API keys of ours, no account, no config.
Prefer the terminal? The same works non-interactively once the marketplace is added:
claude plugin marketplace add Fortytude/TokenDiet
claude plugin install tokendiet@tokendiet
The same audit ships for three more editors โ same knowledge, native packaging. Each folder under editors/ has its own README:
| Editor | Get it | Run it |
|---|---|---|
| Cursor | copy editors/cursor/.cursor/ into your repo | /tokendiet in Agent chat |
| GitHub Copilot | copy editors/copilot/.github/ into your repo | /tokendiet in Copilot Chat |
| Codex | copy editors/codex/.agents/ + AGENTS.md into your repo | $tokendiet, or just ask "audit my LLM cost" |
/tokendiet takes an optional scope. Give it as much or as little as you want:
/tokendiet # audit the whole repo
/tokendiet src/ai/ # audit a single path or module
/tokendiet the auth flow # audit an area, described in words
/tokendiet my last PR # git-diff the last PR/commit, audit only changed call-sites
Scoping to my last PR is the fast one to wire into your habit โ audit the AI code you just wrote before you merge it.
The plugin ships a catalog of ~20 LLM-cost waste patterns. It matches each call-site against them โ in Python and TS/JS โ across OpenAI, Anthropic, the Vercel AI SDK, LangChain / LlamaIndex, AWS Bedrock, Google Gemini, and raw HTTP calls. It follows home-grown wrappers to the real provider call, because that's where the waste usually hides.
Findings are grouped by how safe the fix is:
The model sees the exact same thing; only billing changes.
json.dumps sitting before the static content, dropping the hit rate to ~0.json.loads + retry-on-failure, where a structured-output contract would kill the loop.max_tokens cap โ added as a real fix (a bill ceiling), never sold as a saving.These change what the model sees or does. The plugin suggests them and tells you to validate on your own outputs. It never auto-applies them.
top_k / chunk size cranked high, stuffing low-relevance chunks into every prompt.json.dumps(x, indent=2) / JSON.stringify(x, null, 2) shipping whitespace as tokens.reasoning_effort:"high" on a fire-and-forget utility call.Risk ceilings and enablers, not trims. Reported as leads, never with a dollar figure.
messages list replayed in full every agent turn (O(nยฒ) accumulation).It also knows the dead levers not to recommend โ the token-efficient-tools header (a no-op on Claude 4+), lowering max_tokens to cut input cost (it can't), temperature/top_p "tuning" for cost (no billing effect), and adding cache_control on OpenAI/Gemini (their caching is automatic โ the lever is ordering). Bad advice is worse than no advice.
There's no TokenDiet server. There's no TokenDiet account. There's no TokenDiet API key.
The plugin is a slash command plus a skill โ a body of LLM-cost knowledge (the waste catalog, per-provider detection heuristics, and a strict honesty contract). When you run /tokendiet, your own Claude Code agent loads that knowledge and audits your code with your tokens on your machine.
That means the privacy story is simple and real: your code never leaves your laptop. We can't see your repo, log it, store it, or train on it, because it never reaches us. The plugin is just files you can read in this repo.
This is the part that makes the report worth screenshotting.
TokenDiet never invents a dollar figure. It can't see your traffic โ your call volume, your cache hit rate, your easy/hard query mix are all runtime facts that live on your machine, not in your code. So any "$X/month saved" number would be fabricated, and a fabricated number poisons the whole report the moment someone divides it back out.
Instead:
file:line. No evidence, no finding.If you do explicitly ask "how much will this save me?", it asks for your monthly bill or call volume first and contextualizes against that โ clearly, as an estimate that depends on your traffic. It just never volunteers a number it can't stand behind.
That discipline is the reason the report is trustworthy. The honesty is the product.
TokenDiet is built by Fortytude โ we build tools for people shipping with AI. This plugin is free, open source, and stays that way. If it saves you money, a โญ on the repo is the only thanks we ask.
TokenDiet is MIT-licensed and built to be extended. The knowledge lives in flat, readable files โ adding a new waste pattern is a documentation change, not a code change.
tokendiet/
โโโ commands/
โ โโโ tokendiet.md # the /tokendiet slash command + workflow
โโโ skills/tokendiet/
โ โโโ SKILL.md # the methodology and fix taxonomy
โ โโโ references/
โ โโโ waste-catalog.md # the ~20 waste patterns โ add one here
โ โโโ detection-heuristics.md # how to find call-sites, per provider
โ โโโ honesty-rules.md # the honesty contract
โโโ editors/
โ โโโ cursor/ # Cursor packaging (.cursor/commands + rule)
โ โโโ copilot/ # GitHub Copilot packaging (.github/prompts)
โ โโโ codex/ # Codex packaging (.agents/skills + AGENTS.md)
โโโ .claude-plugin/
โโโ plugin.json # plugin manifest
โโโ marketplace.json # marketplace entry
Good first contributions:
waste-catalog.md with the code shape (Python and TS/JS), the mechanism, the fix, and the honesty class. Match the format of the existing entries.detection-heuristics.md, especially for wrappers or a framework we don't cover well yet.commands/.Two hard rules for any contribution: every finding must cite a real file:line, and nothing may fabricate a dollar figure. A PR that adds a "$X saved" claim will be declined โ that line is the point of the project. Open an issue to discuss anything larger.
MIT ยฉ Fortytude. Use it, fork it, ship it.
Built by Fortytude ยท Report an issue
If /tokendiet found something worth fixing in your repo, drop a โญ โ it helps other devs find it.
.claude-plugin/
marketplace.json
plugin.json
.github/
ISSUE_TEMPLATE/
bug_report.yml
config.yml
new_waste_pattern.yml
PULL_REQUEST_TEMPLATE.md
workflows/
validate.yml
.gitignore
commands/
tokendiet.md
CONTRIBUTING.md
editors/
codex/
.agents/
skills/
tokendiet/
references/
detection-heuristics.md
honesty-rules.md
waste-catalog.md
SKILL.md
AGENTS.md
README.md
copilot/
.github/
copilot-instructions.md
prompts/
tokendiet.prompt.md
README.md
cursor/
.cursor/
commands/
tokendiet.md
rules/
tokendiet.mdc
README.md
LICENSE
README.md
SECURITY.md
skills/
tokendiet/
references/
detection-heuristics.md
honesty-rules.md
waste-catalog.md
SKILL.mdยฉ 2026 Flowy ยท Free and open source
Built for Claude Code ยท Not affiliated with Anthropic