</>MCP Agents Market
Plugin

token-optimizer

by alexgreensh2.1kPythonUpdated 2026-09-03

Find the ghost tokens. Fix them. Survive compaction. Avoid context quality decay.

Claude CodeCodexOpenCodeOpenClawGitHub CopilotCursorHermes

token-optimizer is a Claude Code plugin and multi-platform AI assistant optimization tool that automatically reduces token waste while preserving session continuity across compactions. Developed by alexgreensh, it operates in the background to compress tool outputs, detect redundant file reads, prevent behavioral loops, and checkpoint session state before auto-compaction events. The plugin provides a real-time quality scoring system, live cost dashboard, and 30-day trend analysis to help developers understand where tokens are spent and which optimizations deliver measurable savings. It supports Claude Code, Codex, OpenCode, OpenClaw, GitHub Copilot, Cursor, and several other AI coding platforms.

Key Features

Nine automated compression features including delta-mode re-reads, bash output compression, search result condensing, and structural skeleton generation for code files
Smart compaction with progressive checkpoints that preserve session state, decisions, and context across auto-compaction events
Real-time context quality scoring (S–F letter grades) based on seven signals tracking resource health and session efficiency
Progressive disclosure system that archives large tool results (>4KB) to disk and makes them retrievable on demand via expand commands
Live HTML dashboard with per-turn token breakdowns, cost tracking across four pricing tiers, cache analysis, and subagent usage metrics
Cross-session continuity hints that score recent checkpoints for relevance and surface them when starting new sessions
Loop and retry detection that catches behavioral patterns before they burn tokens, with cooldown limits and session caps
Local SQLite session database (15 tables) tracking compression events, savings, quality measurements, and full audit trails with zero telemetry

Use Cases

  • 01Reducing API costs for developers working in long AI-assisted coding sessions by compressing command output and preventing redundant file reads
  • 02Recovering session context after Claude Code auto-compaction events without losing decisions or active task state
  • 03Monitoring token spend and context quality in real time through a live dashboard to identify waste patterns before they escalate
  • 04Analyzing 30-day trends with Coach Mode to detect quality drift, cache degradation, and model misrouting across projects
  • 05Preserving work continuity across cold session resumes by reconstructing lean context from SQLite checkpoints instead of full transcripts
  • 06Identifying and eliminating unused skills, bloated configs, and stale memory entries through automated structural audits

Related Plugins

View more

token-optimizer — FAQ

What is token-optimizer?+

token-optimizer is a Claude Code plugin and multi-platform tool that automatically reduces token waste in AI coding sessions through compression, session checkpointing, and quality monitoring. It operates in the background via hooks and provides measurable savings tracking without requiring manual intervention after initial setup.

How do I install token-optimizer for Claude Code?+

Run '/plugin marketplace add alexgreensh/token-optimizer' then '/plugin install token-optimizer@alexgreensh-token-optimizer' in Claude Code. After installation, run '/token-optimizer' once to set up hooks, then enable auto-update in the plugin settings. Everything else runs automatically.

Which AI clients and platforms does token-optimizer support?+

It works with Claude Code (CLI and VS Code), OpenCode, OpenClaw, Codex, Hermes, GitHub Copilot, Cursor, Google Antigravity (beta), and Grok Build (beta). Windsurf is on the roadmap. Installation methods vary by platform; see the README for platform-specific instructions.

Does token-optimizer require any API keys or external dependencies?+

No. It runs entirely locally with zero runtime dependencies (pure Python stdlib or TypeScript). All data stays on your machine in SQLite databases with no telemetry or network calls.

Is token-optimizer free to use?+

Yes for personal, research, educational, and non-commercial use under the PolyForm Noncommercial 1.0.0 license. Small teams (under 5 people or under $20k/month revenue) also get a no-cost commercial license automatically. Larger commercial users need to contact the author for licensing.

Will token-optimizer break my prompt cache or degrade context quality?+

No. It never modifies content already in your context and works on new content entering the window. All hooks are fail-open, so errors do not block your commands. The quality scoring system actively tracks degradation in real time.

How do I install token-optimizer?+

Open the source repository on GitHub and follow its README. token-optimizer is a plugin — MCP Agents Market links you directly to the official repo.

Is token-optimizer free?+

token-optimizer is an open-source project hosted on GitHub. Check the repository for its license and any usage requirements.

Related searches