Skip to content

TokenDiet

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…

Install

$/plugin marketplace add Fortytude/TokenDiet

Install command taken from the project's README or registry entry. Always review code before running it.

TokenDiet

Your code is overpaying for AI. /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.

📋 What a run looks like

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.

⚡ Install

In Claude Code:

Similar plugs

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro,…

Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…

Explore related