Inspired by rtk-ai/rtk.
Source: rtk-ai/rtkReverse-engineered from real GitHub workflow.
CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies
CLI proxy that compresses command outputs to reduce LLM token consumption by 60-90%
I'm building a CLI proxy tool called RTK that intercepts and compresses command outputs before they reach LLM context windows. The goal is to reduce token consumption by 60-90% on common developer commands like git, cargo, npm, pytest, and docker. Think of it as a middleware layer that understands what information LLMs actually need versus what's just noise in a terminal output.
The whole thing should be a single statically-compiled Rust binary with zero external dependencies. It needs to be fast — we're talking sub-10ms overhead — and support 100+ common commands out of the box. I want it distributed via Homebrew, curl install script, and cargo, with pre-built binaries for macOS, Linux, and Windows.
Here's the architecture: RTK should work as a transparent proxy that intercepts stdout from commands. When a command runs, RTK analyzes the output type (is this git output? a test result? a file listing?) and applies command-specific compression rules. For example, `git diff` should strip unchanged context lines and only keep hunks with changes. A `cargo test` failure should show just the failed test name and assertion, not the full backtrace. `ls` output should be deduplicated and show directory structure more compactly. The core should be a command matcher that recognizes patterns and dispatches to specialized compressors.
The key features: configurable compression levels (normal, aggressive, minimal), ability to whitelist/blacklist specific commands, support for piping and redirection, and compatibility with terminal colors and ANSI sequences. It should gracefully fall through to uncompressed output for unknown commands rather than breaking anything. Include a config file system so users can customize rules per project.
Build it as a Cargo project with a build.rs script that can embed version and metadata. Keep the code modular so new command handlers can be easily plugged in. Make sure it compiles to a truly minimal binary — aim for under 10MB. Test against real-world command outputs from TypeScript, Rust, Python, and Go projects.
The compression strategies should be smart: remove boilerplate, collapse similar lines, show summaries instead of full lists, highlight what changed, and preserve the essential signal for LLMs while cutting the noise. Think about what Claude or Cursor actually needs to understand what happened in that command versus what's just repetitive detail.
Ship it with good documentation, multilingual README support, Discord community infrastructure, and CI/CD for cross-platform builds. Make installation smooth with Homebrew and a one-liner curl script that works across platforms.