repo-forensics
Offline security scanner that audits git repos, AI skills, plugins, MCP servers, and agent credentials for prompt injection, credential theft, and known vulnerabilities. Runs as a skill and as pre-tool-use hooks.
Audits a Claude Code or Codex setup for context-window waste, fixes it with the user's approval, and measures the savings. It also tracks costs, helps resume prior sessions, and offers a usage dashboard.
Claude Code
> /plugin marketplace add alexgreensh/token-optimizer> /plugin install token-optimizer@alexgreensh-token-optimizer
Codex
$ npx skills add alexgreensh/token-optimizer --skill fleet-auditor resume-checkpoint token-coach token-dashboard token-optimizer -a codex
Cursor
$ npx skills add alexgreensh/token-optimizer --skill fleet-auditor resume-checkpoint token-coach token-dashboard token-optimizer -a cursor
Gemini CLI
$ npx skills add alexgreensh/token-optimizer --skill fleet-auditor resume-checkpoint token-coach token-dashboard token-optimizer -a gemini-cli
GitHub Copilot
$ copilot plugin marketplace add alexgreensh/token-optimizer$ copilot plugin install token-optimizer@alexgreensh-token-optimizer
OpenCode
$ npx skills add alexgreensh/token-optimizer --skill fleet-auditor resume-checkpoint token-coach token-dashboard token-optimizer -a opencode
Windsurf
$ npx skills add alexgreensh/token-optimizer --skill fleet-auditor resume-checkpoint token-coach token-dashboard token-optimizer -a windsurf
English · 한국어 · 简体中文 · 日本語
Token Optimizer cuts the tokens your AI coding assistant wastes, keeps your work alive across sessions and compactions, and shows you where every dollar went on a live dashboard. Most of it runs automatically. You install it, run the audit once, and the hooks do the rest.
Why not just use Headroom or RTK? They compress command output, which covers 15-25% of your context. Token Optimizer covers that plus the other 75%: bloated configs, unused skills, stale memory, compaction loss, model misrouting, behavioral waste. Every saving is cache-safe and measured. The dashboard updates after every session, automatically.
Works on the AI coding tools below, with a Devin output-filter beta (manual skill, or install.sh --devin --auto for automatic compression):
Runs automatically, every session, you do nothing:
When you ask for it:
/token-optimizer: full audit with guided fixes/token-coach: 30-day trend analysis with specific fixesquick: 10-second health checkroute: the model and effort this task actually needs, before you spenddoctor: installation checksavings: dollar savings reportreport: per-component token breakdowndashboard: open the full dashboardmemory-review: MEMORY.md structural auditexpand: retrieve archived tool resultresume-lean: reopen a cold sessionInstall, run /token-optimizer once, everything else runs automatically.
A 30-second preview. Watch the full film with sound (50 seconds).
Claude Code now lets a plugin add its own piece of interface, called a mod. Token Optimizer uses one to put your session's health right above the prompt: a quality grade, how full the context is, how long the cache stays warm, and both usage limits. One plain sentence tells you what needs attention, and one button fixes it. Clawd, the small orange mascot, acts out what the session is doing, so you can tell at a glance whether Claude is reading, editing, waiting for your OK, or done.
It comes with the plugin, nothing extra to install. Everything the bar does.
Claude Code (recommended):
/plugin marketplace add alexgreensh/token-optimizer
/plugin install token-optimizer@alexgreensh-token-optimizer
Then in Claude Code: /token-optimizer
Enable auto-update after installing. Claude Code ships third-party marketplaces with auto-update off by default.
/plugin→ Marketplaces tab → selectalexgreensh-token-optimizer→ Enable auto-update. One-time, 10 seconds.After install, run
/token-optimizeronce to set up hooks. From there, everything runs automatically: compression, checkpoints, quality scoring, dashboard updates. You don't need to run any command again unless you want an audit.
Claude Code cloud sessions (claude.ai/code). Cloud sessions load no plugins, not yours and not ones a repo enables, so the commands above don't reach them. Paste one setup script into your cloud environment instead and every session in it, any repo, runs the real Token Optimizer:
- Run
python3 measure.py cloud-setup-script(or ask Claude for "the Token Optimizer cloud setup script").- Paste the output into claude.ai/code → your environment → Setup script.
The script fetches the
@alexgreensh/token-optimizernpm package (the plugin itself, same version), checks its sha512 before running anything, and wires the same hooks ashooks/hooks.jsoninto the VM. Nothing is committed to your repos, and it never fails your setup. State lives in the VM, so each cloud session starts fresh. Details
Other platforms and install methods
Codex:
codex plugin marketplace add alexgreensh/token-optimizer
Then in the Codex TUI: /plugins and install Token Optimizer. See docs/codex.md.
OpenCode V2: add token-optimizer-opencode to the plugins array in your opencode.json (V1 1.18.29+ uses plugin):
{ "$schema": "https://opencode.ai/config.json", "plugins": ["token-optimizer-opencode"] }
See opencode/README.md.
OpenClaw:
openclaw plugins install github:alexgreensh/token-optimizer
See openclaw/README.md.
Hermes:
git clone https://github.com/alexgreensh/token-optimizer.git
token-optimizer/install.sh --hermes
Terminal output compression, cheaper re-reads, loop warnings, checkpoints that survive compaction, prior-session hints, and the dashboard, through Hermes's own plugin hooks. See hermes/README.md.
Pi Coding Agent:
Offline security scanner that audits git repos, AI skills, plugins, MCP servers, and agent credentials for prompt injection, credential theft, and known vulnerabilities. Runs as a skill and as pre-tool-use hooks.
Make your AI agents work as a team. You keep working in 1 session while it orchestrates models via your other subscriptions, local models and more. Run a Software Factory: long plans, proven steps, safe merges. Carries your setup, tracks every cost.
Creates illustrations, animation loops, drawing timelapses, explainer and launch videos, and interactive web animations as code, in many styles with composed scores. Helps keep characters consistent across renders.
See 12 token-optimizer alternatives
Captures what your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions so work carries over. Works with Claude Code and several other coding agents.
Local-first memory for Claude Code. It stores conversations verbatim in a private palace you can search before answering about past work, people, projects, or decisions, with optional shared-brain hub setup.
Gives Claude Code long-term memory through Hindsight. It recalls relevant past context before answering, retains durable facts as the agent learns them, and reflects over stored memory.
Gives Claude Code a private memory that stays on your machine. It stores past conversations word for word, so you can ask what was decided, what happened before, or who was involved and get the original context back. It can also hand tasks to other agents.
Install it with the command on its page. It includes fleet-auditor, resume-checkpoint, token-coach. Its skills do not fire on their own yet. Free and open source.
Is this plugin yours?
Claim it with GitHubSubmit a pluginPromote it