# Token Optimizer

Audits a Claude Code or Codex setup for context-window waste, fixes it with the user's...

- Repository: https://github.com/alexgreensh/token-optimizer (2831 stars)
- Category: AI and agents
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add alexgreensh/token-optimizer --skill token-optimizer -g -a claude-code -y`
Codex: `npx skills add alexgreensh/token-optimizer --skill token-optimizer -g -a codex -y`
Cursor: `npx skills add alexgreensh/token-optimizer --skill token-optimizer -g -a cursor -y`
Gemini CLI: `npx skills add alexgreensh/token-optimizer --skill token-optimizer -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add alexgreensh/token-optimizer`

## Description

Audits a Claude Code or Codex setup for context-window waste, fixes it with the user's approval, and measures the saving. Use when context feels tight, sessions degrade, or costs climb.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Token Optimizer

Measures where a setup spends its context window, proposes fixes, applies the ones the user approves, and re-measures. The deliverable is a before-and-after the user can verify, with every change backed up. Typical recovery is 5-15% of the window from config cleanup, more when compaction and caching settings are wrong for the way the user works.

Token Optimizer's own skills (`token-optimizer`, `token-coach`, `token-dashboard`, `fleet-auditor`, `resume-checkpoint`) are the measurement layer, so leave them out of every unused-skill, archive or consolidation suggestion, however rarely they run.

## Step 0: pick the right workflow for this runtime

The audit below reads and edits `~/.claude`, which is the wrong target anywhere but Claude Code, so settle the runtime before touching any path. Run exactly this, in this order.

**a. Environment check** (touches no file; an explicit `TOKEN_OPTIMIZER_RUNTIME` wins, and Claude plugin variables are checked before stray `OPENCODE_*` exports, the same order `detect_runtime()` uses):

The rest: https://github.com/alexgreensh/token-optimizer/blob/HEAD/cowork/token-optimizer/skills/token-optimizer/SKILL.md
