# Token Optimizer

> Local plugin that audits and compresses AI coding assistant context, checkpoints sessions across compaction, and tracks token and cost savings on a dashboard.

Token Optimizer is a source-available plugin by Alex Greenshpun for AI coding assistants such as Claude Code, Codex, OpenCode, OpenClaw, Hermes, GitHub Copilot, Pi, Cursor, Google Antigravity (beta) and Grok Build (beta). It audits a setup for wasted tokens, compresses new content as it enters the context window, checkpoints sessions before compaction, and reports token and dollar usage on a local dashboard. The project documents that it runs locally with no runtime dependencies and no telemetry.

## What It Is

Token Optimizer is a context-management tool for AI coding agents. After installation, a one-time `/token-optimizer` audit produces a per-component token breakdown of items such as CLAUDE.md, skills, MCP servers and memory files, applies safe fixes and recommends the rest. Hooks then run automatically each session. Each supported platform has its own native integration, and a Devin output-filter skill is in contract-only beta.

## How the Waste Model Works

The docs divide waste into three kinds: structural (bloated configs, unused skills, stale memory), runtime (verbose command output, oversized tool results, repeated file reads) and behavioral (cache expiry, late compaction, retry loops, model misrouting). Active compression covers delta re-reads, code-skeleton substitution, bash and search output compression, lean-output nudges, quality nudges, loop detection, activity mode and decision extraction. Large tool results are archived to disk and can be retrieved on demand with an expand command.

## Compaction Survival and Session Continuity

The tool checkpoints session state at several context-fill thresholds and quality drops, then restores what the compaction summary dropped. It also injects a digest of large tool outputs so the model can re-orient without re-reading. Across sessions, relevance-scored checkpoints surface as hints, and a cold-resume command reconstructs lean context from a local SQLite database.

## Dashboard, Scoring and Coaching

A dashboard regenerates after each session and shows per-turn token and cost breakdowns across four pricing tiers, cache analysis, subagent spend and a savings tracker. A 0-100 quality score with S-F grades appears in a terminal status line, and a desktop status bar is available for the Claude desktop app. `/token-coach` analyzes 30 days of history, and 11 waste detectors, per-task model and effort advice, and a Fleet Auditor are documented.

## Licensing Model

The code is published under PolyForm Noncommercial 1.0.0 with a written small-business permission, so it is source-available rather than OSI open source. Commercial use beyond that permission requires contacting the author.

## Features
- Setup audit with per-component token breakdown
- Active compression: delta re-reads, structure maps, bash and search output compression
- Smart compaction with checkpoints and restore
- Session continuity with cross-session hints and cold-resume
- Tool result archive with on-demand expand
- Live local dashboard with cost across four pricing tiers
- Quality scoring with S-F grades and status line
- Loop detection and quality nudges
- Token Coach 30-day trend analysis
- Waste detectors and Fleet Auditor
- Per-task model and effort routing advice
- Memory health audit
- Desktop status bar for the Claude desktop app
- Custom command filters via TOML
- Zero runtime dependencies and zero telemetry

## Integrations
Claude Code, Claude desktop app, Codex, OpenCode, OpenClaw, Hermes, GitHub Copilot, Pi Coding Agent, Cursor, Google Antigravity, Grok Build, Devin

## Platforms
WINDOWS, MACOS, LINUX, WEB, API, VSC_EXTENSION, CLI

## Pricing
Free

## Version
5.13.73

## Links
- Website: https://token-optimizer.dev
- Documentation: https://token-optimizer.dev/start/quickstart/
- Repository: https://github.com/alexgreensh/token-optimizer
- EveryDev.ai: https://www.everydev.ai/tools/token-optimizer
