Sponsor

Roundup5 min read

7 Tools to Cut Your Coding Agent's Token Bill (2026)

Seven tools that cut Claude Code, Codex and Cursor token usage by compressing shell output, searching code and fetching current docs, with honest caveats.

By agentools

A big share of what a coding agent costs comes from what it reads, not from the code it writes. Every git log, test run, full file read and stack of MCP tool definitions lands in the context window, and you pay for all of it on every turn that follows.

The tools below go after that waste from different sides. Some compress shell and tool output, some let the agent search instead of reading whole files, one keeps docs current so the agent stops retrying with old APIs, and one keeps MCP tool definitions out of context. I've included install commands and the caveats from each project's own docs.

At a glance

ToolBest forPricingType
RTK (Rust Token Killer)Shrinking shell outputFree CLI, Pro for teamsCLI
HeadroomCompressing JSON, logs and filesFree, open sourceLibrary, proxy, CLI and MCP server
Context ModeOutput folding plus session memoryFree enginePlugin + Platform
XERJSearch instead of grep and catOpen sourceMCP Server
SerenaSymbol-level code navigationOpen sourceMCP Server
Context7Current library docsFree tierHosted MCP server
mcpcMany MCP servers, lean contextFree, open sourceCLI (MCP client)

The 7 picks

1. RTK (Rust Token Killer)

Cut what your coding agent reads by compressing shell output before it hits the context

RTK (Rust Token Killer) is a single Rust binary that hooks into your agent and rewrites common commands (ls, cat, grep, git, test runners, linters, docker) into compact versions. Test runs collapse to failures only, git log keeps hash, author and subject, and directory listings become trees with counts. The project claims 60 to 90% smaller output on common dev commands. It is also upfront that this only covers bash output, which is one part of your bill. Telemetry is off unless you opt in.

Install with brew install rtk, then rtk init -g. One gotcha: another crate named rtk exists, so check that rtk gain works after install. That same command shows the savings from your own use.

Pricing: Free CLI, Pro for teamsCLI

2. Headroom

Shrinks tool outputs, logs and files before your coding agent sends them to the model

Headroom is an open source compression layer between your agent and the model. It squeezes JSON, logs, code and chat history on your machine, keeps the lines that matter and caches the originals so the agent can pull them back. Its README reports about 20% fewer tokens for coding agents and 60 to 95% fewer on JSON-heavy tool output, with the same answers on its benchmarks. The MCP server exposes headroom_compress, headroom_retrieve and headroom_stats.

Install with uv tool install --python 3.13 "headroom-ai[all]", then headroom wrap claude (undo with headroom unwrap claude). Two things to know: an anonymous usage beacon is on by default (set HEADROOM_TELEMETRY=off or DO_NOT_TRACK=1 to turn it off), and headroom wrap also installs Serena unless you pass --code-memory none.

Pricing: Free, open sourceLibrary, proxy, CLI and MCP server

3. Context Mode

Context saving, memory and guardrails for coding agents

Context Mode sits between your agents and the model. Its free Engine is a local plugin that works through MCP and hooks in 18 AI coding tools. It sandboxes tool output so only the answer reaches the model, keeps session memory, loads skills only when a task needs them and makes every prompt and command searchable.

It does more than compression, with rules for what agents may read, run and reach, and a paid hosted control plane for team features. If you want one plugin for output folding and memory, start with the Engine from the GitHub repo.

Pricing: Free enginePlugin + Platform

4. XERJ

Local search engine so coding agents stop reading files one by one

XERJ is a local Rust search engine that indexes a folder (code, docs, logs, PDFs) so the agent queries ranked passages with file:line results instead of reading files one by one. It supports BM25, vector and hybrid search, go-to-definition lookups and an agent memory namespace. The project reports a 2.7x cut in output tokens at the same solve rate in its own case study, based on agents indexing reference repos before writing code.

Install with curl -fsSL https://xerj.org/get | sh, run xerj init to wire it into Claude Code or Cursor, then xerj autoindex ~/my-project. The --insecure dev mode disables TLS and auth, so keep it to a single user on localhost.

Pricing: Open sourceMCP Server

5. Serena

The IDE for your coding agent

Serena gives coding agents IDE-style tools over MCP: symbol-level retrieval, find-references, cross-file renames and edits. Looking up a symbol instead of grepping lines and reading whole files means less code ends up in context.

Install with uv tool install -p 3.13 serena-agent, then launch serena start-mcp-server. Skip the older marketplace one-click installs and use that command. If you already use Headroom's default wrap, you have Serena installed.

Pricing: Open sourceMCP Server

6. Context7

Up-to-date library docs for coding agents

Context7, built by Upstash, serves version-specific docs and code examples to Claude Code, Cursor, Codex and other agents through a hosted MCP server or the ctx7 CLI. When an agent writes against an old API, you pay for the failed attempt, the error output and the retry. Pulling the right docs up front avoids that loop.

Set it up with npx ctx7 setup. The free tier covers 1,000 API calls a month for public repos. Pro is $10 per seat per month and adds private repo parsing.

Pricing: Free tierHosted MCP server

7. mcpc

Command-line MCP client that gives any shell-enabled agent the full protocol through one Bash tool

mcpc is Apify's open source command-line MCP client. It maps every MCP operation to a shell command, so Claude Code or Codex can use any MCP server through bash instead of loading dozens of tool definitions into context. Progressive tool discovery means the agent only reads the schemas it needs.

Install with brew install mcpc (or npm install -g @apify/mcpc), then mcpc connect <server> @name and mcpc @name tools-list. It keeps persistent sessions to several servers, stores OAuth credentials in the OS keychain and never calls an LLM on its own.

Pricing: Free, open sourceCLI (MCP client)

More to consider

Where the tokens actually go

Most of the input a coding agent pays for is stuff it reads along the way. The usual sources:

  • Shell output. Test runs, git log, directory listings and linter output can be long, and most of it is noise for the task at hand.
  • File reads. Agents often read whole files to find one function.
  • Tool definitions. Every connected MCP server adds its tool schemas to the context, whether the agent uses them or not.
  • Logs and JSON. Long logs and verbose API responses usually hold a few useful lines.
  • Outdated docs. When an agent codes against an old API version, the error, the fix and the retry all cost tokens.

All of this stays in context for later turns, so a noisy command early in a session keeps costing you until it gets compacted.

Which ones to combine

These tools overlap, so I'd build a stack instead of installing all seven:

  • One output compressor: RTK or Headroom. Headroom installs Serena by default unless you pass --code-memory none, so take that into account before adding Serena separately.
  • Search or navigation: XERJ for ranked search across code and docs, or Serena for symbol-level navigation.
  • Docs: Context7, so the agent works from the current API.
  • MCP servers: mcpc if you load many servers and their tool definitions are crowding the context.

Otari and Navige work at a different level. Otari is a self-hosted gateway with budgets and scoped keys, and Navige adds caching, loop guards and model routing. Both are about controlling spend across many agents and teammates rather than trimming one coding session. Graphicle and Graphify build code graphs, but Graphicle's authors say they do not claim token savings.

Whatever you pick, measure before and after. Note your usage for a few typical sessions, then check rtk gain or headroom_stats to see what actually changed.

Wrapping up

Start with the biggest source of waste in your own sessions. If you're not sure where that is, a shell output compressor is the easiest first step, since it needs no change to how you work. Add search and docs after that. You can browse more options in the coding tools section of the directory.

If you run agents on a schedule, look at the routine diff check idea. It checks whether anything changed before a scheduled agent runs, which cuts usage for runs that have nothing new to work on.