Overview
RTK — "Rust Token Killer" — is a command-line proxy that sits between an AI coding agent and the shell commands it runs. Agent loops burn most of their context on raw tool output: pages of `git status`, a full `pytest` run, a `docker build` log. RTK intercepts that output and compresses it before the model ever sees it, which the project measures at a 60–90% reduction on common development commands.
It compresses with four strategies rather than a model: intelligent filtering to drop noise, grouping to aggregate similar items, truncation that preserves the relevant context, and deduplication to collapse repeated lines. The rules are command-aware — git operations report the confirmation instead of the progress chatter, test runners surface only failures, build tools group errors by file — and it covers more than a hundred commands across git, cargo, npm/pnpm, pytest, docker, the AWS CLI and more.
RTK ships as a single dependency-free Rust binary with under 10 ms of overhead, installable from Homebrew, an install script, Cargo, or pre-built releases for macOS, Linux and Windows. `rtk init` wires it into an agent through that agent's hook or plugin API — the project lists integrations for Claude Code, GitHub Copilot, Cursor, Gemini CLI, Codex, Windsurf, Cline, Kilo Code and others — after which plain commands are transparently rewritten to their `rtk` equivalents. An `rtk gain` dashboard reports the token savings over a 30-day history. It is Apache-2.0 licensed.
What it does
- Command-aware compression of 100+ dev commands (git, cargo, npm/pnpm, pytest, docker, AWS CLI and more)
- Four non-model strategies — filtering, grouping, context-preserving truncation and deduplication
- Single Rust binary with no dependencies and under 10 ms of overhead per command
- Auto-rewrite hook that transparently turns `git status` into `rtk git status` inside the agent
- One-command setup per agent via `rtk init`, with integrations for Claude Code, Copilot, Cursor, Gemini CLI, Codex, Windsurf, Cline and others
- `rtk gain` analytics dashboard tracking token savings across a 30-day history
- Per-command exclusions and a "tee" mode that keeps full output on failures, configured in a single TOML file
Getting started
Install the binary, then run `rtk init` for whichever agent you use and restart it. Nothing else changes — your commands keep the same names.
Install RTK
Homebrew is the recommended path; an install script, Cargo and pre-built release binaries for macOS, Linux and Windows are also available.
brew install rtk
# or, on Linux/macOS:
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
# or from source:
cargo install --git https://github.com/rtk-ai/rtkWire it into your agent
`rtk init` installs the hook or plugin for a specific agent. The `-g` flag installs it globally rather than for the current project.
rtk init -g # Claude Code / Copilot (default)
rtk init -g --gemini # Gemini CLI
rtk init -g --agent cursor # Cursor
rtk init --agent cline # Cline / Roo CodeRestart the agent
After a restart the auto-rewrite hook is active: when the agent runs `git status`, RTK transparently runs `rtk git status` and returns the compressed output instead.
Check what you saved
The gain command reports token savings, with a 30-day history.
rtk gainTune the config
Global configuration lives in a TOML file — `~/.config/rtk/config.toml`, or `~/Library/Application Support/rtk/config.toml` on macOS. Use it to exclude specific commands or to turn on "tee" mode, which keeps the full output when a command fails.
Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Stop a coding agent from filling its context window with build, test and git output
- Cut the per-run cost of long agent loops without changing the model or the prompt
- Keep long agentic sessions coherent by leaving more of the window for actual reasoning
- Measure where an agent's tokens are actually going, per command, with `rtk gain`
How RTK compares
RTK alongside other open-source gateways & routing tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| RTK | ★ 79.1k | A Rust CLI proxy that compresses command output before it reaches your coding agent |
| Headroom | ★ 69.1k | Local context-compression layer that shrinks tool outputs, logs, files and RAG chunks before they reach the model, usable as a library, a drop-in proxy or an MCP server. |
| OmniRoute | ★ 61.9k | A local-first AI gateway that fronts hundreds of model providers with one OpenAI-compatible endpoint, quota-aware auto-fallback, many routing strategies and prompt compression. |
| LiteLLM | ★ 58.2k | A Python SDK and proxy server that gives one OpenAI-compatible API to 100+ LLM providers, with cost tracking, budgets, fallbacks, rate limiting, and an admin UI. |
| Apache APISIX | ★ 17.1k | A cloud-native API gateway whose AI plugins add multi-provider LLM proxying, load balancing, retries and fallbacks, token-based rate limiting, and content moderation. |
| Portkey AI Gateway | ★ 12.9k | An LLM gateway that routes calls to 100+ providers through one API and adds logging, tracing, caching, and fallbacks for production AI traffic. |
| Higress | ★ 9.3k | An AI-native API gateway built on Istio and Envoy that proxies and governs traffic to many LLM providers, with token rate limiting, caching, and MCP server hosting. |
| Bifrost | ★ 7.8k | A high-throughput LLM gateway written in Go that gives a single OpenAI-compatible API to many providers, with failover, load balancing, semantic caching, and very low overhead at high request rates. |