rtk: a high-performance CLI proxy that compresses shell command outputs to reduce LLM token usage
rtk: a high-performance CLI proxy that compresses shell command outputs to reduce LLM token usage
What it solves
RTK (Rust Token Killer) reduces the high cost and context window usage of LLMs when they execute shell commands. It prevents "token bloat" by filtering and compressing the verbose output of common CLI tools (like git, cargo, npm, docker, and aws) before that output is sent back to the AI agent, typically reducing token consumption by 60-90%.
How it works
RTK acts as a high-performance CLI proxy written in Rust. It intercepts shell commands and applies four primary compression strategies:
- Smart Filtering: Removes noise such as boilerplate, whitespace, and comments.
- Grouping: Aggregates similar items, such as grouping errors by type or files by directory.
- Truncation: Cuts redundant information while keeping essential context.
- Deduplication: Collapses repeated log lines into counts.
It can be integrated via an auto-rewrite hook that transparently changes commands (e.g., git status becomes rtk git status) or via plugins for specific AI agents like Claude Code, Cursor, and Windsurf.
Who it’s for
Developers using AI coding agents (such as Claude Code, GitHub Copilot, Cursor, or Cline) who want to lower their API costs and prevent the LLM from being overwhelmed by massive, redundant command outputs.
Highlights
- Broad Command Support: Optimized filters for 100+ commands across Git, GitHub CLI, test runners (Jest, Pytest, Cargo), build tools, and cloud providers (AWS, Kubernetes).
- Low Overhead: Single Rust binary with less than 10ms of overhead.
- Coded for Agents: Includes a hook system to automatically rewrite commands for 14 different AI tools.
- Token Analytics: Built-in tools (
rtk gain) to track and visualize token savings over time. - Failure Recovery: Automatically saves full unfiltered output to a log file when a command fails, allowing the LLM to retrieve the full context if needed.
Sources
- undefinedrtk-ai/rtk