One command wires Claude Code through the local gateway. It works whether you pay Anthropic per token or run a Claude Pro/Max subscription — the setup is the same; only what you see on the dashboard differs.
Installing wires two things into Claude Code, both pointed at your local gateway on 127.0.0.1:
Read dedup, per-tool line budgets, and structural + recoverable compaction run as Claude Code hooks — each request is trimmed before it's sent, nothing the model needs is dropped. A cost-discipline skill nudges the agent toward leaner tool use.
tokenbeaver_expandRecoverable compaction leaves a small stub in place of trimmed content. When the agent actually needs the full text, it calls tokenbeaver_expand to restore it on demand — so slimming is lossless, not lossy.
The install is identical for both. What changes is how savings are framed — because a per-token bill and a flat subscription are two different things to optimize.
You pay Anthropic per token. Route Claude Code's Anthropic traffic through the gateway with the anthropic provider (or dual upstream), keeping your own key (BYOK, never stored). The dashboard shows dollars saved — an estimate on Free, verified on Pro.
On a Claude subscription there's no per-token bill to cut, so savings show as context stretched % and tokens reclaimed — how much further your 5-hour and weekly quota goes. These are honest estimates of quota runway, not a billed measurement, and you won't see an absolute dollar figure (by design).
Pick your surface. Both wire the same hooks and restore tool.
Keep the gateway running while you use Claude Code.
The ⚡ TokenBeaver status-bar item wires Claude Code for you. To re-apply after a Claude Code update, run TokenBeaver: Repair Claude Code Hooks from the Command Palette.
Nothing hidden — two files in your home directory, each written atomically, backed up first, and fail-open (if the gateway is unreachable, Claude Code keeps working normally).
| File | What's added |
|---|---|
~/.claude/settings.json | PostToolUse, PreToolUse, PreCompact, SessionStart and UserPromptSubmit hooks that call the gateway on 127.0.0.1:<port> |
~/.claude.json | mcpServers.tokenbeaver — the gateway's /mcp restore tool (tokenbeaver_expand) |
Confirm the restore tool registered, then keep the gateway up:
If tokenbeaver shows up and the gateway is running, you're optimizing. Numbers appear on the dashboard (--dashboard) as you work.
Remove every hook and the restore tool with one command — your backups are restored:
--install-claude-hooks, accept consent on first run, and confirm the port with --status.tokenbeaver is missing from claude mcp list--install-claude-hooks or TokenBeaver: Repair Claude Code Hooks). The restore tool is gated on recoverable compaction being enabled — make sure it's on.id=… call tokenbeaver_expand stubtokenbeaver_expand. If expand is ever unreachable, a safe head/tail of the content is kept as a fallback, so the agent never loses the thread.--accept-terms) and it resumes.Open a GitHub issue → · Questions? Support
Email [email protected] or visit the support page — a real developer will get back to you.