tokenSaver
Current release: 1.0.9.
A Claude Code and Codex CLI plugin that compresses tool round-trips — smart file search, batch editing with fuzzy matching, and SQL introspection in single MCP calls — and accounts for the calls it saves (status line on Claude Code, tokensaver savings on Codex).
Fully local. No account, no login, no telemetry, no subscription. Everything the plugin does runs on your machine. The only network access is the one-time dependency install and a daily update check against GitHub (disable it with the updateCheck setting).
Built as a clean-room reimplementation: every behavior is reproduced from a functional specification, the code is readable JavaScript, and there is no bundled or obfuscated code.
Install
Claude Code
Inside a Claude Code session:
/plugin marketplace add Brucee/tokensaver
/plugin install tokensaver@tokensaver-marketplace
Codex CLI
From a terminal:
codex plugin marketplace add Brucee/tokensaver
codex plugin add tokensaver@tokensaver-marketplace
On first use Codex asks you to review the plugin's hooks — open /hooks and trust them once (they are re-verified whenever hooks.json changes).
On first load the MCP server installs its npm dependencies once (network needed for ~30s), then everything is cached and works offline.
What differs on Codex
Same tools, same savings accounting — Codex state lives under ~/.codex/tokensaver/ and transcripts are read from ~/.codex/sessions/ rollouts. Tool redirect, savings, recall, post-compaction recovery and the multi-lens review (via spawn_agent instead of Task) all work. There is no status line — Codex has its own TUI and no statusline hook surface — and the tokensaver:* agent files are Claude-only, so the Task(Explore) rewrite does not apply.
The review selects up to 7 lenses. On Codex it respects the concurrency limit reported by the available collaboration tools, counting the parent agent too. It launches batches or reuses completed reviewers for the remaining lenses.
What you get
MCP tools (server code)
| Tool | What it does |
|---|
Search | File glob + content regex + per-file context + TS/JS symbol summary + importer graph + image peek — in one call, with an output cap and if_modified_since delta mode |
Edit | cwd + edits[] batch across files: exact → fuzzy (normalized-Unicode Levenshtein, 0.90 threshold, ±10% window, 2s budget) → replace_all; #line-range, #cell= ipynb addressing with cell_action (insert/delete/move), protected paths, syntax validation |
Sql | postgres / mysql / sqlite / duckdb: schema introspection, auto-LIMIT, SQL auto-fixer, table/csv/json output, host-scoped connection policy |
Agents (Claude Code only)
tokensaver:code — the workhorse coding agent wired to the three tools.
tokensaver:explore — Haiku-powered read-only lookups (Search only, ≤5 calls, compact Defs/Refs/Callers output).
tokensaver:recall — finds past answers in your session history via the recall CLI.
Hooks
SessionStart — primes session state; on Claude Code, registers the status line.
UserPromptSubmit — updates savings accounting; on Claude Code, derives the session title.
PostToolUse, Stop, SubagentStop — incremental savings accounting from the transcript (subagent usage merged per agent).
PreCompact / PostCompact — arm and inject the post-compaction digest (see below).
PreToolUse — injects cwd into plugin tool calls; suggests Search/Edit/Sql when a Bash command re-implements them (cat/grep/find/ls/sed -i/psql/mysql/sqlite3…); on Claude Code, redirects Task(Explore) to the Haiku agent. On Windows Codex, PowerShell file operations and apply_patch receive the corresponding MCP hints.
StopFailure — safe no-op logging.
All hooks read the hook envelope on stdin, answer JSON on stdout, never throw, and always exit 0.
Savings
Every successful MCP call is mapped to the native calls it replaced (Edit batch of 10 edits on 3 files → 13.5 calls). The engine parses your transcript JSONL incrementally (byte-offset scanning, requestId dedup, failed results don't count) and rolls up session + daily + lifetime stats under ~/.claude/tokensaver/ (~/.codex/tokensaver/ on Codex, parsed from rollout-*.jsonl — subagent usage is tracked per-agent and merged). On Claude Code the status line rotates the numbers; on Codex use tokensaver savings. Codex input accounting separates ordinary input, cache reads and cache writes. If a multi-call exec wrapper reports an error, the wrapper earns no savings credit because individual successful calls cannot be reliably identified. Previously recorded cost estimates keep their original calculation.
Recall