tokendiet

tokendiet is a cursor rule for Cursor from DukeDeSouth/tokendiet-mcp. It costs 609 tokens per session, scanned A, original, MIT.

A rule for using TokenDiet, a tool that compresses large logs, web pages, files, and search results before they reach the agent.

In plain words
What is it for?
Use it for long command output, web pages, files over about 3,000 tokens, repository-wide searches, and batches of multiple files.
Why use it?
It reduces unnecessary context when working with large inputs while avoiding extra processing for small reads.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it for long command output, web pages, files over about 3,000 tokens, repository-wide searches, and batches of multiple files.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/dukedesouth/tokendiet-mcp/tokendiet
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/DukeDeSouth/tokendiet-mcp

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tokendiet

README.md
[![agentmods](https://agentmods.dev/badge/rules/dukedesouth/tokendiet-mcp/tokendiet/github.svg)](https://agentmods.dev/rules/dukedesouth/tokendiet-mcp/tokendiet)
Your own site
<a href="https://agentmods.dev/rules/dukedesouth/tokendiet-mcp/tokendiet"><img src="https://agentmods.dev/badge/rules/dukedesouth/tokendiet-mcp/tokendiet/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tokendiet

Your own site · 80×15
<a href="https://agentmods.dev/rules/dukedesouth/tokendiet-mcp/tokendiet"><img src="https://agentmods.dev/badge/rules/dukedesouth/tokendiet-mcp/tokendiet.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 609 This file is loaded in full into every session.
When invoked 609 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00609 $0.00609
Opus 5 $0.00304 $0.00304
Sonnet 5 $0.00122 $0.00122
Haiku 4.5 $0.00061 $0.00061

Measured 11d ago against content hash e68eb6b16730, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

tokendiet scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

templates/tokendiet.mdc · 43 lines

How it starts

The opening of the file, as written. The whole thing — 43 lines — stays where its author put it; the contents beside it link to each section on GitHub.

TokenDiet (turn-neutral compression)

Use TokenDiet when it replaces a heavy payload in one round-trip. Each extra MCP call costs ~8K input-equivalent tokens in cached agent loops — only use when savings exceed that.

When to use TokenDiet

Situation Tool Notes
Test/build logs, long command output run 1:1 Bash replacement; 68–99% saved
Web pages (http/https) fetch 1:1 fetch replacement; large HTML compresses strongly
Single file > ~3000 tokens (code) read with mode=auto Server returns outline+ when net-positive
Multiple files in one task read with targets[] (up to 16) 1 MCP turn — never 12 sequential reads
Single file < ~3000 tokens Built-in Read or batch via targets[] MCP adds a turn per call if not batched
Repo-wide regex search search When results are large; small sets passthrough automatically
Need full file for editing read mode=full One call — do not outline→symbol→expand ladder
Emergency full from prior ref expand(refs[]) Batch rare recovery — not normal exploration
End of session economics stats Terminal only — never mid-task

Reading code

  1. Batch exploration: pass targets: [{path}, ...] — one call for many files. Do not loop single-path read.
  2. Do not drill down by default. No outline → symbol → expand ladder. One read(mode=auto) or read(mode=full) per file.
  3. compression.net_estimate — if negative, the call was economically unprofitable; prefer built-in Read next time.
  4. passthrough_reason — server returned full content because compression would not pay for the MCP turn.
  5. For security review, use mode=full or mode=symbol on specific functions — check warnings before editing.
  6. verified: true means structure verified, not that you saw the entire file.

Commands

  • Prefer run over Bash for tests, builds, and logs (compressed stdout/stderr, full output in ref).

Read the full file on GitHub · 43 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 43 lines · 609 tokens per session scan A e68eb6b16730

Subscribe to this mod's changes

tokendiet is a cursor rule published in the GitHub repository DukeDeSouth/tokendiet-mcp (9 stars, last pushed 1mo ago), licensed MIT. It adds 609 tokens to every session, about $0.0030 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.