AI terminal agents like Claude Code, Aider, and Gemini CLI are revolutionizing developer workflows. However, running shell commands through these agents is a massive source of context window pollution.
When an agent runs a command (e.g., npm install --verbose or cargo build), the output streams hundreds of lines of progress bars, registry fetches, compile dot indicators, and ANSI escape codes into the LLM. You are charged for every single line of this noise, and it pollutes the context window, causing the LLM to lose focus.
Introducing RTK (Rust Token Killer)
RTK is a zero-dependency CLI proxy written in Rust that intercepts Bash tool commands in your AI agent's tool lifecycle, compresses the output, and feeds clean, semantically dense output to the LLM.
It achieves 60โ90% token savings per tool call with less than 10ms of overhead.
The 4 Compression Strategies
- Smart Filtering: Strips out ANSI terminal escape codes, carriage-return animation overrides, spinner characters, and empty lines.
-
Dynamic Grouping: Sequences of identical log outputs are collapsed (e.g.,
[120 identical lines: "PASS"]). - Truncation: Outputs are intelligently capped to preserve the first few lines, the last lines (where errors appear), and a middle summary.
- Deduplication: Repeated stack trace frames are consolidated to preserve clean debugging signals.
Pro Tips & Caveats
-
Bash Tool Calls Only: The automatic global hook (
rtk init -g) only wraps shell commands. Claude Code's native file tools (like Read, Grep, Edit) bypass the hook. Use terminal commands (likecatorrg) to ensure outputs are compressed. -
Crates.io Naming Collision: The
rtkcrate name on crates.io points to an unrelated "Rust Type Kit" library. To install the token killer, install directly from the source:
cargo install --git https://github.com/rtk-ai/rtk.git
-
Fail-Safe Tee Logs: On command failure, RTK writes the full raw logs to
~/.local/share/rtk/tee/so you can debug without losing details.
Read the complete setup guide, benchmarks, and configuration steps on MeshWorld

Top comments (0)