█

AI/TLDR

RTK

A Rust CLI proxy that compresses command output before it reaches your coding agent

Context Compression & Token BudgetsOpen source
Language
Rust
License
Apache-2.0
Coverage
1 story
$brew install rtk

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.

bashbash
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/rtk

Wire 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.

bashbash
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 Code

Restart 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.

bashbash
rtk gain

Tune 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 context compression & token budgets tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
RTK★ 84.3kA Rust CLI proxy that compresses command output before it reaches your coding agent
Headroom★ 77.6kLocal 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.
Context Mode★ 31.8kAn MCP server that keeps raw tool output out of the context window by sandboxing it, and indexes session events into SQLite FTS5 so an agent survives compaction.
TOON★ 25.5kToken-Oriented Object Notation: a lossless, compact encoding of the JSON data model that declares row counts and field lists so tabular data costs fewer prompt tokens.
pxpipe★ 7.5kA local proxy that renders bulky request context — system prompt, tool docs and older turns — as PNG pages the model reads with vision, cutting the input tokens a coding agent re-sends each turn.
LeanCTX★ 3.9kLocal context layer for coding agents with ten file read modes, 95+ shell-output compressors, reversible content-addressed recovery, session memory and a savings ledger.
CliffCompaction★ 65A transparent API proxy that trims a coding agent's history at a token threshold by truncating and dropping content only, never rewriting it, so summaries never stack on summaries.