token-optimizer
Find the ghost tokens. Fix them. Survive compaction. Avoid context quality decay.
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
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 moreandrej-karpathy-skills
A single CLAUDE.md file to improve Claude Code behavior, derived from Andrej Karpathy's observations on LLM coding pitfalls.
claude-mem
Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Understand-Anything
Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
rtk
CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies
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.