- Home
- Skills
- Prompt & Skill Engineering
- Token Diet Guardian
More screenshots
Works with the AI Agents you already use
Token Diet Guardian
Keep your AI coding assistant sharp and token-efficient. Audit oversized instructions, neutralize unmonitored git hooks, and convert monolithic prompts into on-demand LUT Routers.
Free
Token Diet Guardian
Example session with this skill installed
Audit my .cursorrules file for bloat and optimize it using the LUT pattern. It's getting too big and the AI is losing track of my tech stack.
- Read your context and instructions
- Compiled the token diet guardian
[Engine: token-diet-cli (Python CLI v0.3.2) | Skill: Token Diet Guardian v1.0]
I audited your workspace directives and pre-commit hooks:
Baseline Footprint Audit
| Directive / File | Bytes | Tokens | CLI Engine Status | Skill Target (3 KB) |
|---|---|---|---|---|
.cursorrules | 5,432 B | ~1,358 | [WARN] | Exceeds Target |
.git/hooks/pre-commit | 58 B | - | 🚨 HOOK ALERT | Action Required |
Proposed Refactor Preview (Diff against .cursorrules.bak)
--- a/.cursorrules
+++ b/.cursorrules
@@ -1,80 +1,13 @@
-# Phoenix Storefront Directives (Monolithic Instructions)
+# Phoenix Storefront Directives (Core Router)
Project: Phoenix E-Commerce
Core Stack: Next.js 14, TypeScript, Tailwind CSS, Prisma ORM.
-Test Runner: npm run test:unit
-Linter: npm run lint
+Test Command: npm run test:unit
+Lint Command: npm run lint
+
+## On-Demand Instructions (LUT Router)
+Load specialized procedure files only when active task requires them:
+- Database Migrations & Schemas: Read skills/database/SKILL.md
+- Styling & Tailwind Design System: Read skills/styling/SKILL.md
+- API Security & Zod Validation: Read skills/security/SKILL.md
+- Production Deployment Checklist: Read skills/deployment/SKILL.md
+- Domain Business Rules (Orders, Billing): Read docs/business-rules.md
Proposed Hook Remediation (--dry-run preview)
--- a/pre-commit
+++ b/pre-commit
@@ -2,4 +2,4 @@
set -e
npm run test:unit
-claude review --all
+# [token-diet disabled]: claude review --all
Would you like me to apply these changes? (Safety backups will be created as .bak).
[User approves: "Yes, proceed"]
[Engine: token-diet-cli (Python CLI v0.3.2) | Verification Re-Audit]
Post-Remediation Verification
| Metric | Baseline | Post-Refactor | Delta | Status |
|---|---|---|---|---|
Root File (.cursorrules) | 5,432 B (~1,358 tok) | 634 B (~158 tok) | -88.3% | [OK] Lean Router |
| Hook Status | Unmonitored LLM active | Neutralized with .bak | Neutralized | Neutralized, backup created |
- [Engine: token-diet-cli v0.3.2 | Re-audit] Sizes and hook status confirmed deterministically.
- [Agent check, not CLI] Rule coverage: 100% of original domain rules, database schemas, and style constraints placed in on-demand skill files; 0 lines unplaced.
- Backups Created:
.cursorrules.bak,.git/hooks/pre-commit.bak.
Connects securely to your tools. The creator never sees your data.
About this skill
"Your AI agent doesn't need more context. It needs the right context."
As projects grow, developer instructions naturally accumulate: database schemas, framework constraints, styling rules, deployment checklists, and testing patterns. Before long, files like .cursorrules, CLAUDE.md, or .windsurfrules swell into 15–30 KB instruction monoliths.
This creates friction in every development session:
- Static Overhead: Your agent re-reads thousands of instruction tokens on every message, even when fixing a 2-line typo.
- Instruction Clutter: Forcing dozens of pages of guidelines into working memory clutters prompt space with rules unrelated to your immediate task.
- Unexpected Background Leaks: Background scripts or pre-commit hooks can silently invoke cloud LLMs on local commits, unexpectedly consuming API quota.
Token Diet Guardian brings Context Engineering to your workspace. It restructures monolithic prompt files into lean Look-Up Table (LUT) Routers with on-demand pointers.
What it does
- Dual-Mode Context Auditing: Runs in Native Heuristic Mode (zero dependencies) or via the optional official CLI engine (
token-diet-cli==0.3.2) for byte-exact metrics, optional MCP schema auditing (--mcp), and global directive inspection (--global). - Look-Up Table (LUT) Routing: Reorganizes monolithic directives into a lean central router under 3 KB with on-demand pointers.
- On-Demand Knowledge Extraction: Offloads specialized workflows (like deployment runbooks or database protocols) into modular reference files (
skills/<name>/SKILL.md). - Safe Pre-Commit Hook Neutralization: Inspects
.git/hooks/pre-commitfor unmonitored cloud LLM calls, previews remediation with--dry-run, and neutralizes them only after explicit confirmation. - Measured Impact Reporting: Re-measures after refactoring to show before-and-after byte counts and estimated token savings.
How it works
- Engine Discovery & Consent: Runs non-mutating discovery queries (
command -v token-diet,python3 --version). If missing, asks if you want to install it via pipx/venv or proceed with native heuristic file inspection (zero installs). - Baseline Audit: Generates an initial report labeled
[Engine: token-diet-cli (Python CLI v<version>)]or[Engine: Native Heuristic Inspection]. - In-Memory Preview & Confirmation: Drafts the new router and extracted modules entirely in memory first, checks rule coverage, and shows you the proposed diff before creating any files. Only after your explicit approval does it create safety backups (
<file>.bak, timestamped if one exists) and write to disk. - Post-Refactor Verification: Re-measures sizes (CLI or native) and runs a rule-coverage check. Lines without a destination are listed for your review.
Supported Environments
Designed for coding assistants and environments with project-level instruction files and filesystem access:
| Environment | Instruction File | Engine Support |
|---|---|---|
| Claude Code | CLAUDE.md, ~/.claude/CLAUDE.md* | CLI + native |
| Cursor | .cursorrules | CLI + native |
| Cursor (project rules) | .cursor/rules/*.mdc, .md | CLI + native |
| Windsurf | .windsurfrules | CLI + native |
| Codex / multi-agent | AGENTS.md, ~/.codex/AGENTS.md* | CLI + native |
| Gemini CLI | GEMINI.md, ~/.gemini/GEMINI.md* | CLI + native |
| OpenCode | AGENTS.md (refactor), opencode.json (audit-only) | CLI + native |
| Roo Code / Cline | .clinerules | CLI + native |
*Note on Global Files: Directives in home directories (~/.claude/CLAUDE.md, ~/.codex/AGENTS.md, ~/.gemini/GEMINI.md) are audited on request only. The skill will never refactor global user directives without explicit, separate approval.
Why this beats prompting it yourself
Manual prompt optimization is tedious and prone to accidental rule loss. Token Diet Guardian enforces a rigorous safety protocol: in-memory preview before writes, safety backups (<file>.bak, timestamped if one exists), user diff confirmation before writing, post-refactor re-audit, and transparent engine labeling. Application code is never modified (the skill only modifies prompt governance files and optionally .git/hooks/pre-commit with explicit confirmation).
Known Limitations & Transparency
- Byte vs. Token Counts: Byte counts are exact in CLI mode. Token counts are estimates in both modes (~4 characters per token).
- Pointer Adherence: The router reduces context only if the assistant follows its pointers and loads the referenced files on demand; this depends on the agent and cannot be guaranteed. Use plain-text pointers ("Read X when..."), not
@pathimports, which some tools load at session start regardless. - Hook Inspection Scope: Only
.git/hooks/pre-commitis inspected (husky, lefthook, or pre-push hooks are not covered). - Application Code Untouched: Focuses strictly on prompt architecture and pre-commit hooks; application code is never modified.
- Network & Privacy: The skill itself makes no network calls; your assistant processes your files as it normally does with its LLM provider.
- Terminal Execution: Command execution is optional and used solely when the user approves using the CLI engine (
token-diet-cli) or running--fix-hooks. In Native Heuristic Mode, only file read/write tools are used; non-mutating discovery queries check tool availability. - Workflow Variations: Actual API invoice savings depend on session length, agent implementation, and provider caching dynamics.
- Requires workspace filesystem tools to inspect files and create backups.
Versioning Note
The Agensi Skill package is versioned at v1.0 (the instruction bundle). The underlying optional open-source Python engine on PyPI (token-diet-cli==0.3.2) follows its own independent library semantic versioning.
Open Source Engine Companion
Token Diet Guardian is the official skill companion to the open-source token-diet engine:
- GitHub: https://github.com/joseoper/token-diet
- PyPI: https://pypi.org/project/token-diet-cli/
- Engine Quality: 132 automated unit tests across Python 3.10, 3.11, 3.12, and 3.13 in GitHub Actions CI.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Prompt & Skill Engineering.
Byte counts are exact in CLI mode; token counts are estimates (approx. 4 chars/token). Router reduces context only if assistant follows on-demand pointers. Only .git/hooks/pre-commit is inspected. Global user directives (~/.claude, ~/.codex, ~/.gemini) are audited on request only and never refactored without separate explicit consent. Application code is never modified. The skill itself makes no network calls.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 4 days ago
- Free with an Agensi account
- Software
Git
- Optional
Python 3.10+
pipxorvenvTerminal / Shell Execution
Works out of the box with native file tools. Python 3.10+ and terminal execution are required only for the optional deterministic CLI engine. Non-mutating read-only discovery queries check engine availability.
Permissions
Zero network calls made by the skill itself; your assistant processes files as it normally does with its LLM provider. Network is used solely if the user explicitly approves installing the optional token-diet-cli engine from PyPI.