- Node.js 18 or newer — check with
node --version - Claude Code installed —
~/.claude/directory should exist - No npm install needed; the optimizer engine is bundled
git clone https://github.com/iterate-ai/token-optimizer
cd token-optimizer/claude_plugin
bash scripts/install.shThen restart Claude Code (or open a new session).
The installer is idempotent — running it again is safe and will overwrite older files.
If you'd rather control the install yourself:
-
Copy the plugin somewhere stable:
cp -R claude_plugin ~/.claude/plugins/agentone-token-compression -
Make the optimizer engine resolvable. Either:
- Symlink:
ln -sfn /path/to/nodejs_optimizer ~/.claude/plugins/agentone-token-compression/node_modules/@iterate/token-optimizer - Or run
npm installinside the plugin dir if you have a published version.
- Symlink:
-
Copy the slash commands:
cp ~/.claude/plugins/agentone-token-compression/commands/*.md ~/.claude/commands/
-
Copy the skill:
mkdir -p ~/.claude/skills/agentone-token-compression cp ~/.claude/plugins/agentone-token-compression/skills/agentone-token-compression/SKILL.md ~/.claude/skills/agentone-token-compression/
-
Merge the hooks into your
~/.claude/settings.json. The file~/.claude/plugins/agentone-token-compression/settings.jsonhas the exact block. Manually:{ "hooks": { "PostToolUse": [ { "matcher": "Read|Grep|Glob|Bash|WebFetch|NotebookRead", "hooks": [{ "type": "command", "command": "node $HOME/.claude/plugins/agentone-token-compression/hooks/compress-tool-output.js" }] } ], "UserPromptSubmit": [ { "hooks": [{ "type": "command", "command": "node $HOME/.claude/plugins/agentone-token-compression/hooks/compress-prompt.js" }] } ], "SessionEnd": [ { "hooks": [{ "type": "command", "command": "node $HOME/.claude/plugins/agentone-token-compression/hooks/session-end.js" }] } ] }, "statusLine": { "type": "command", "command": "node $HOME/.claude/plugins/agentone-token-compression/hooks/statusline.js" } } -
Restart Claude Code.
After restart, in a Claude Code session:
/tokens
You should see a stats panel. After a few file reads or bash commands:
/tokens
…shows accumulated savings.
By default we hook Read|Grep|Glob|Bash|WebFetch|NotebookRead. To restrict, edit the matcher field in ~/.claude/settings.json. For example, only Read and Grep:
"matcher": "Read|Grep"Put a .claude/settings.json in your project root to override globally. The plugin's hooks will still fire — just the matcher / config changes per project.
Temporarily for one shell:
export TOKEN_OPTIMIZER_DISABLED=1Permanently:
bash ~/.claude/plugins/agentone-token-compression/scripts/uninstall.shcd token-optimizer
git pull
bash claude_plugin/scripts/install.shCaches and stats are preserved across updates.
Install Node.js 18+ from https://nodejs.org or your package manager.
- Verify Claude Code reloads the settings on session start (it does). Restart Claude Code.
- Verify your
~/.claude/settings.jsonhas thehooksblock from above. - Check that the file paths exist:
ls ~/.claude/plugins/agentone-token-compression/hooks/.
Re-run install.sh from the cloned repo — it bundles the engine. If you're testing from the source repo, ensure nodejs_optimizer is alongside claude_plugin so the symlink works.
Run time (echo '{}' | node ~/.claude/plugins/agentone-token-compression/hooks/compress-tool-output.js) — should be under 100ms. If not, your Node startup is slow; consider using a Node version manager (nvm/fnm) for a fast Node 20+.
The installer is additive — it appends to existing arrays without clobbering. If something looks off, restore from the backup ~/.claude/settings.json.bak.<timestamp> the installer creates.