# RTK RTK (Rust Token Killer) is an open source CLI proxy written in [[Rust]] that intercepts shell command output and compresses it before it reaches an [[How Coding Agents Work|AI coding agent]]'s [[Context Window]]. It sits as a transparent hook between the agent and the underlying tools (git, cargo, npm, docker, kubectl, AWS CLI, etc.), so prompts and workflows stay unchanged. The premise; most of the [[AI Tokenization|tokens]] burned in an AI coding session are not reasoning, they are noise from verbose command output. A typical `git diff` or `cargo test` floods the context with boilerplate the model never needs. RTK attacks that noise at the source instead of touching the prompt. ## How it works A single Rust binary, zero dependencies, sub-10ms overhead. After `rtk init -g`, an auto-rewrite hook transparently maps `git status` to `rtk git status` (and similar) per supported command. The agent never sees the difference. Four compression strategies; boilerplate filtering, similar-line grouping, intelligent truncation, repetition deduplication. Each command type has its own optimization logic instead of a generic compressor. ## Reported savings - `git diff`: ~12 000 → ~960 tokens (~92%) - `npm test`: ~6 000 → ~600 tokens (~90%) - `cargo test`: ~91.8% reduction - `git status`: ~80.8% - `find`: ~78.3% - 12-file refactoring session: 74 700 → 6 960 tokens - Korben's own measured average over months of use; ~81.5% - Marketing claim across 2 900+ real-world commands; ~89% average noise removed Useless on already-short outputs. The payoff scales with how verbose the underlying tool is. Particularly relevant for autonomous agent loops where noise accumulates across iterations and pollutes the signal as much as the budget. ## Integrations 13+ AI clients via hooks or plugins; [[Claude Code]] (via [[Claude Code Hooks]] of type `PreToolUse`), GitHub Copilot, [[Cursor CLI|Cursor]], [[Codex CLI|Codex]], Gemini CLI, [[Cline]], Windsurf, and others. 100+ commands covered across git, cargo, npm, pip, docker, kubectl, AWS CLI, and test runners. ## Observability - `rtk gain` — total token savings per command, with history - `rtk discover` — flags commands that ran without optimization (missed opportunities) - `rtk session` — adoption rate inside a given Claude Code session ## Install ```bash brew install rtk # macOS cargo install --git https://github.com/rtk-ai/rtk # any platform rtk init -g # install the rewrite hook ``` A curl install script is also published for other platforms. ## Pricing & license RTK itself is free, MIT/Apache-2.0 licensed (the repo lists both; LICENSE file says MIT, GitHub footer Apache-2.0). A paid RTK Cloud tier with team features is announced at ~$15/dev/month. ## Why it matters Different category from a [[LiteLLM Claude Code Proxy|model-routing proxy]]. Those reroute requests between providers; RTK reshapes the *inputs* before they reach whichever model is on the other end. The two can stack, and both can sit in front of the same Claude Code install. The deeper insight; context window pressure is rarely caused by your prompts. It is caused by the tools your agent reaches for. Optimize the tooling layer, not the prompt layer. ## References - GitHub: https://github.com/rtk-ai/rtk - Site: https://www.rtk-ai.app/ - Docs: https://www.rtk-ai.app/docs/ - Korben review (FR): https://korben.info/rtk-proxy-rust-economiser-tokens.html ## Related - [[lowfat (CLI)]] - [[Claude Code]] - [[Claude Code Hooks]] - [[Context Window]] - [[AI Tokenization]] - [[How Coding Agents Work]] - [[Rust]] - [[LiteLLM Claude Code Proxy]]