rtk-ai/rtk
CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies
What it solves
RTK (Rust Token Killer) reduces the high cost and token consumption of LLM-based AI coding agents. When agents execute shell commands (like ls, git status, or test runners), the raw output is often filled with boilerplate, whitespace, and noise that consumes thousands of tokens without adding value. RTK filters and compresses this output before it reaches the LLM context, reducing token usage by 60-90%.
How it works
RTK acts as a high-performance CLI proxy written in Rust. It employs four primary strategies to shrink command output:
- Smart Filtering: Removes noise such as comments and boilerplate.
- Grouping: Aggregates similar items, such as grouping files by directory or errors by type.
- Truncation: Cuts redundancy while preserving essential context.
- Deduplication: Collapses repeated log lines with counts.
It integrates with AI tools via an auto-rewrite hook that transparently intercepts Bash commands and rewrites them to rtk equivalents (e.g., git status becomes rtk git status) before execution.
Who it’s for
Developers using AI coding agents (such as Claude Code, Cursor, Windsurf, or GitHub Copilot) who want to lower their API costs and prevent context window saturation.
Highlights
- Broad Support: Optimized filters for 100+ commands across Git, GitHub CLI, AWS, Docker, Kubernetes, and various test runners (Jest, Pytest, Cargo test).
- Transparent Integration: Native binary hooks for multiple agents that require zero manual command prefixing.
- Low Overhead: Written in Rust for sub-10ms overhead.
- Token Analytics: Built-in tools (
rtk gain) to track and visualize token savings. - Failure Recovery: Automatically saves raw output to a log file when a command fails, allowing the LLM to access full details if needed.