Repolode
microsoft

microsoft/TokenEconomizer

A plugin for Claude Code, Codex, Copilot CLI and Pi that learns from past sessions in a repository to cut coding-agent token costs.

Stars
4,883
Forks
298
Open issues
6
Last commit
yesterday

What is it?

TokenEconomizer lowers the cost of running coding agents in a repository you work in often, without changing the agent or its model. It records what happened in earlier sessions and uses that history to reduce waste in later ones. It has three mechanisms: micro-skills, which remember repository facts such as the correct test command and inject them at session start once several sessions confirm them; tool pruning, which removes tools that go unused through the agent's own settings and can be restored with one command; and a loop guard, which uses a judge model to detect a stuck turn and sends the agent a redirect, while leaving the decision to stop to the user.

The plugin supports Claude Code, Codex, GitHub Copilot CLI and Pi, with experimental support for opencode. Each mechanism can be toggled, and thresholds such as how many unused prompts trigger pruning are configurable. Its own model calls run through the user's existing agent login, and what it learns is stored locally in ~/.tokeneconomizer.

The accompanying paper reports on SWE-Bench tasks across five agent and model combinations, with mean cost lower by 18.4% to 30.9%. These figures come from the authors' measurements.

Key features

  • 01Injects learned repository facts such as build steps and test commands at session start.
  • 02Removes unused tools through the agent's own settings, with a one-command restore.
  • 03Detects stuck turns with a judge model and redirects the agent up to a configurable number of times.
  • 04Works with Claude Code, Codex, GitHub Copilot CLI and Pi.
  • 05Stores learned data locally and keeps every action reversible.

Use cases

  • Reducing token spend when a team repeatedly runs a coding agent on the same codebase.
  • Cutting cost on long SWE-style tasks where the agent re-discovers the same repository facts.
  • Stopping an agent from looping on the same failing command without manual intervention.

Quick start

  1. 1

    Clone the repository

    git clone https://github.com/microsoft/TokenEconomizer.git
  2. 2

    Add the plugin marketplace to Claude Code

    claude plugin marketplace add "$PWD/TokenEconomizer"
  3. 3

    Install the plugin

    claude plugin install tokeneconomizer@tokeneconomizer
  4. 4

    Start Claude Code and check the plugin status

    /tokeneconomizer:status

Things to know

  • Supports only specific tested versions of each agent; older versions are not supported.
  • Requires Python 3.10 or newer and one of the supported coding agents.
  • Experimental support for opencode, tested only on two versions.

Featured in Repolode Weekly

In collections

Topics

FAQ

What is TokenEconomizer?
A plugin for Claude Code, Codex, Copilot CLI and Pi that learns from past sessions in a repository to cut coding-agent token costs. TokenEconomizer lowers the cost of running coding agents in a repository you work in often, without changing the agent or its model. It records what happened in earlier sessions and uses that history to reduce waste in later ones. It has three mechanisms: micro-skills, which remember repository facts such as the correct test command and inject them at session start once several sessions confirm them; tool pruning, which removes tools that go unused through the agent's own settings and can be restored with one command; and a loop guard, which uses a judge model to detect a stuck turn and sends the agent a redirect, while leaving the decision to stop to the user.
Is TokenEconomizer free to use? What license does it have?
TokenEconomizer is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is TokenEconomizer still maintained?
Actively maintained. The last commit to TokenEconomizer was on Nov 6, 2026.
What can I use TokenEconomizer for?
Reducing token spend when a team repeatedly runs a coding agent on the same codebase. Cutting cost on long SWE-style tasks where the agent re-discovers the same repository facts. Stopping an agent from looping on the same failing command without manual intervention.
How do I install TokenEconomizer?
Clone the repository: git clone https://github.com/microsoft/TokenEconomizer.git Add the plugin marketplace to Claude Code: claude plugin marketplace add "$PWD/TokenEconomizer" Install the plugin: claude plugin install tokeneconomizer@tokeneconomizer Start Claude Code and check the plugin status: /tokeneconomizer:status
Where can I get TokenEconomizer?
The source code and installation instructions are on GitHub: https://github.com/microsoft/TokenEconomizer

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects