Guide · AI coding
TokenEconomizer: Microsoft's free plugin cut coding-agent costs 18–31%. How to install it
TokenEconomizer is a free MIT plugin for Claude Code, Codex and Copilot CLI. It cut SWE-Bench costs 18.4–30.9%. Three commands install it; the savings grow on repos you use often.
The short version
- TokenEconomizer is a free, MIT-licensed plugin from UC Berkeley, Microsoft Research and Microsoft Security; it needs Python 3.10+ and no API key.
- On 277 SWE-Bench tasks it cut mean cost by 18.4% to 30.9%, best on Claude Code with Opus 4.8, and its own model calls are counted in that.
- On Claude Code, Codex and Copilot CLI it installs with 3 commands: clone, add the marketplace, install.
- It learns from earlier sessions, so expect little on a fresh repo: on security audits in new repositories the saving fell to 6–20%.
Prices, checked daily Claude pricing · Claude Code pricing · Codex pricing
In this article · 7 sections
TokenEconomizer is a free plugin that makes Claude Code, Codex and GitHub Copilot CLI spend fewer tokens in repositories you work in again and again. In the authors' tests on 277 SWE-Bench tasks it cut mean cost by 18.4% to 30.9% without changing the model or the agent. On Claude Code it installs with three commands, and it costs nothing beyond a few small model calls billed to the plan or key you already use.
It comes from UC Berkeley, Microsoft Research and Microsoft Security, the code is on GitHub under the MIT license, and the method is in the paper arXiv 2610.22732, posted on 15 October 2026. Below: what it changes, how to install it, and how much you can realistically expect to save.
What it does to your agent
The plugin sits outside the agent and learns from your earlier sessions in the same repository. According to the README, it does three things:
- Tool pruning (on by default). Tools your agent never uses in this repo get hidden through the agent's own deny settings, so their descriptions stop filling every request. A tool is pruned after 10 unused prompts across at least 2 sessions, or 5 sessions of any length. One command,
toolprune restore, brings them back. - Loop guard (on by default). When a turn keeps hitting the same failure, a small judge model checks whether the agent is stuck. If it is at least 0.7 confident, the agent gets one short redirect per turn. The plugin never stops a turn itself.
- Micro-skills (off by default). Facts about the repo, like the right test command or a required environment variable, are written down once three sessions confirm them and given to the agent at the start of later sessions.
None of this is visible as a new model or a new interface. Your agent just starts with less clutter and gets nudged out of loops.
What it saved in the paper
The headline 30.9% is the best case, not the average. Here are the authors' SWE-Bench results, from the README:
| Agent + model | Cost change | Pass@1 change |
|---|---|---|
| Claude Code + Opus 4.8 | −30.9% | −1.0 |
| Codex + GPT-5.6 Sol | −26.1% | +1.6 |
| Codex + GPT-5.6 Terra | −24.7% | +0.9 |
| Claude Code + Sonnet 5 | −23.6% | +1.3 |
| Copilot CLI + Sonnet 5 | −18.4% | +2.6 |
Three details matter. Costs include the plugin's own model calls. Cost fell in all 30 repository-and-agent combinations, by 5% to 40% depending on the repo. And task success held: Pass@1 rose in four of five settings and dropped one point on Opus 4.8.
The weak spot is new code. On two security-auditing benchmarks, where every task is in a fresh repository, the saving was 6–20%, and on Web-Bench it was 16–21%. The plugin earns its keep from history, so a repo you open once a month will see little.
To put the range in money: if your agent spends $100 a month in API tokens on one busy repository, the paper's range would put that at roughly $69 to $82. That is arithmetic on a benchmark, not a promise; check your own numbers with status after a week (see below).
On a Claude subscription you don't pay per token, so the saving shows up as more work before you hit your usage limit. Our guide to Claude usage limits on Free, Pro and Max explains what drains them.
Before you install
You need one supported agent, signed in the usual way, and Python 3.10 or newer on your PATH. The plugin uses only Python's standard library and never asks for an API key.
The README lists the versions it was tested on:
| Agent | Tested versions | Notes |
|---|---|---|
| Claude Code | 2.1.300–2.1.329 | |
| Codex | 0.153.1–0.171.0 | Codex before 0.141.0 doesn't run plugin hooks |
| Copilot CLI | 1.0.83–1.0.114 | |
| Pi | 1.2.0–1.5.2 | |
| Cursor Agent, opencode, Grok Build, Hermes, Antigravity CLI, Factory Droid | one or two versions each, see the README | Experimental, no tool pruning yet |
If your agent is newer than the tested range, it may well work, but run doctor after installing to check.
How to install it on Claude Code, Codex or Copilot CLI
Pick the folder where you want to keep the clone and run the three lines for your agent. These are from the README.
Claude Code
git clone https://github.com/microsoft/TokenEconomizer.git
claude plugin marketplace add "$PWD/TokenEconomizer"
claude plugin install tokeneconomizer@tokeneconomizer
Start claude in a project, trust the folder and run /tokeneconomizer:status. Once per machine, and again after each Claude Code update, run /tokeneconomizer:toolprune refresh-catalog.
Codex
git clone https://github.com/microsoft/TokenEconomizer.git
codex plugin marketplace add "$PWD/TokenEconomizer"
codex plugin add tokeneconomizer@tokeneconomizer
Trust the folder and the hooks, restart Codex and run $tokeneconomizer:status.
Copilot CLI
git clone https://github.com/microsoft/TokenEconomizer.git
copilot plugin marketplace add "$PWD/TokenEconomizer"
copilot plugin install tokeneconomizer@tokeneconomizer
Start copilot, run /tokeneconomizer:status, and once per machine /tokeneconomizer:toolprune refresh-catalog.
Pi is one line: pi install git:github.com/microsoft/TokenEconomizer, then /te status. opencode is experimental: clone the repo and symlink plugin/opencode/tokeneconomizer.ts into ~/.config/opencode/plugins/. The README has the steps for the other experimental agents and for Copilot in VS Code.
To update later, run git pull in the clone (on Codex, then run the codex plugin add line again; on Pi, run pi update --extensions instead).
Installing a plugin means running someone else's code inside your agent, so clone it from the microsoft organisation on GitHub and nowhere else. Our piece on fake Claude Code skills that install a password stealer shows why that matters.
Three settings worth changing
Settings change with config set; add --global to apply to every repository.
- Turn on micro-skills if you work in a few large repos every day:
config set microskills=on --global. If you don't want extra model calls,microskills=envfactslearns only facts that need no model. - Import your history on Claude Code so it doesn't start from zero:
config set history_import=on --global, right after installing. It reads up to 200 earlier sessions from the last 365 days, makes no model call, andhistory import --dry-runshows what it would read first. - Preview pruning instead of applying it:
toolprune=proposechanges nothing until you runtoolprune apply, andtoolprune measureshows how much smaller requests get.
To switch it all off for one session, start the agent with TE_DISABLE=1.
What it sends, and what the extra calls cost
According to the plugin README, by default only the loop guard calls a model. The judge sees the turn's last 24 actions: tool names, commands cut to 90 characters, edited file names and error signatures. The docs say file contents and your prompts are not sent. Learned data stays on your machine in ~/.tokeneconomizer, and the pruning settings it writes are added to .git/info/exclude so they don't end up in commits.
The calls go through your own agent (claude -p, codex exec, copilot -p) and are billed to your existing plan or key. On Claude Code the default judge is the haiku alias (the plugin README doesn't say which Haiku version), and each judge or redirect call sends a prompt of at most about 1,500 tokens and gets back a one-line verdict or a 2–4 sentence note. If the alias runs Claude Haiku 5.5, at its API price of $0.10 per million input and $0.50 per million output tokens (checked 3 December 2026), such a call costs under a tenth of a cent. Codex and Pi use the agent's default model, which can cost more per call; paid_model lets you pick a cheaper one. status shows this overhead as the repository's total plugin overhead; the per-session figures are in the repo's ledger.jsonl under ~/.tokeneconomizer/repos/.
How to check your savings and uninstall
There is no savings dashboard. Running ~/.tokeneconomizer/bin/te --host codex status from a terminal (with your agent's name after --host) shows each session's tokens and cost plus the plugin's overhead, without spending an agent turn. Compare a week before and after on the same repo. For what your current setup costs in the first place, see our Claude pricing guide with four real setups.
To remove it from Claude Code, run /tokeneconomizer:toolprune restore in each repo listed by /tokeneconomizer:repos, then:
claude plugin uninstall tokeneconomizer@tokeneconomizer
claude plugin marketplace remove tokeneconomizer
rm -rf ~/.tokeneconomizer
Codex and Copilot CLI follow the same pattern with their own plugin remove or plugin uninstall commands, listed in the plugin README. Run the restore step first, or the hidden tools stay hidden.