# token-optimizer

Audits Claude Code and Codex setups for context waste, applies approved fixes, and calculates reclaimed tokens.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 976 installs · ★ 2710
- Author: alexgreensh
- License: LicenseRef-Unknown · policy=link-only · description only; the file stays with the author
- Source: https://github.com/alexgreensh/token-optimizer/tree/HEAD/skills/token-optimizer/SKILL.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/skills/token-optimizer

## What it does

The skill inspects where your coding setup spends its context window. It reviews `CLAUDE.md`, `MEMORY.md`, registered MCP tools, skills, and caching parameters to find dead weight. Every change requires explicit approval, and files are backed up before anything is modified.

Under the hood, six agents gather context metrics concurrently, while a synthesis agent compiles the final optimization plan. The workflow relies on Python 3 running `measure.py` for runtime checks and metric dashboards. Without Python 3 installed, the pre-check fails immediately and halts the audit.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add alexgreensh/token-optimizer --skill token-optimizer -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/token-optimizer/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/token-optimizer/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add alexgreensh/token-optimizer --skill token-optimizer -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/token-optimizer/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add alexgreensh/token-optimizer --skill token-optimizer -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/token-optimizer/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install alexgreensh/token-optimizer token-optimizer
```

2. **Manually: put the files in place**
- File: `.github/skills/token-optimizer/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add alexgreensh/token-optimizer --skill token-optimizer -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/alexgreensh/token-optimizer --path skills/token-optimizer
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/token-optimizer/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add alexgreensh/token-optimizer --skill token-optimizer -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/alexgreensh/token-optimizer/tree/HEAD/skills/token-optimizer/SKILL.md

## When to use it
- audit instructions in CLAUDE.md and MEMORY.md for bloat
- detect inactive MCP servers and redundant skills
- benchmark context window savings before and after cleanup
- tune cache lifetime and compaction thresholds

## Example prompts
- Run token-optimizer to audit my context window usage
- Check for context waste in CLAUDE.md and MCP settings
- Measure context savings before and after cleaning skills

## Similar
- [caveman-token-optimizer](https://affpapa.org/en/nevibecode/skills/caveman-token-optimizer.md) — skill · 842 installs
- [token-efficiency](https://affpapa.org/en/nevibecode/skills/token-efficiency.md) — skill · 2500 installs
- [hedera-token-service](https://affpapa.org/en/nevibecode/skills/hedera-token-service.md) — skill · 547 installs
- [llm-cost-optimizer](https://affpapa.org/en/nevibecode/skills/llm-cost-optimizer.md) — skill · 73 installs
- [skill-progressive-disclosure-design](https://affpapa.org/en/nevibecode/skills/skill-progressive-disclosure-design.md) — skill · 4300 installs
- [improve-claude-md](https://affpapa.org/en/nevibecode/skills/improve-claude-md.md) — skill · 2500 installs

## Other versions with the same name
- [token-optimizer · d4kooo](https://affpapa.org/en/nevibecode/skills/d4kooo-token-optimizer.md) — 495 installs

From the same set: [alexgreensh/token-optimizer](https://affpapa.org/en/nevibecode/by/alexgreensh/token-optimizer.md) — 3 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
