The Problem

LLM-powered coding agents (Claude Code, Cursor, Copilot) consume large token budgets on routine command output. A single git diff or cargo test can inject tens of thousands of tokens into context, most of it noise. Teams pay for that waste on every session, and it slows agent response times.

What This Does

rtk is a CLI proxy that intercepts commands like ls, grep, git diff, and pytest, filters and compresses their output, then passes only the relevant subset to the LLM. The Rust binary sits between the agent and the shell, rewriting command output in real time. The repo claims 60-90% token reduction with under 10ms overhead per command.

The implementation is organized by language ecosystem under src/cmds/ — git/, js/, python/, rust/, go/, ruby/, dotnet/, and system/ each contain command-specific handlers. Analytics modules in src/analytics/ (cc_economics.rs, gain.rs) track token savings per session. The project also ships per-agent hooks under hooks/ (Claude, Cursor, Copilot, Codex, Cline, Windsurf) and a TypeScript entry point at openclaw/index.ts for the OpenClaw agent.

How To Use It

Setup: Install via Homebrew (brew install rtk), the curl installer, or cargo install --git https://github.com/rtk-ai/rtk. Pre-built binaries for macOS, Linux, and Windows are in the releases page. The Formula/rtk.rb and install.sh files confirm these paths.

Configuration: The .rtk/filters.toml file controls output filtering rules. Per-agent hook configuration lives in the hooks/ directory — e.g., hooks/claude/rtk-rewrite.sh for Claude Code, hooks/cursor/rtk-rewrite.sh for Cursor. No environment variables are required; the binary works as a drop-in shell wrapper.

Running it: Verify with rtk --version and rtk gain (shows token savings stats). The proxy activates automatically once the agent hook is installed. The README documents a name collision with a crates.io package called "rtk" — if rtk gain fails, you have the wrong binary.

brew install rtk rtk --version # should show rtk 0.28.2 rtk gain # token savings stats

Real-World Use

A developer running Claude Code on a TypeScript monorepo. Without rtk, a git diff across 20 files injects ~10,000 tokens of context. With rtk, the proxy strips unchanged hunks, collapses whitespace, and summarizes file-level changes — the agent sees only what changed and why. The same applies to cargo test: instead of full test output, the agent gets pass/fail counts and failed assertion messages. The scripts/rtk-economics.sh script demonstrates how to quantify these savings per session.

Code Health & Issues

Med - Agent-specific hook fragmentation - The hooks/ directory has 9+ per-agent implementations (Claude, Cursor, Copilot, Codex, etc.) with overlapping logic. This will drift over time; the openclaw/index.ts entry point suggests a consolidation effort is underway but incomplete. Low - Heavy reliance on Markdown docs - 99 of 200 files are Markdown, including 40 files under .claude/ for agent configuration. That's a lot of process documentation for a 57-file Rust codebase; some of it may be aspirational rather than reflective of actual behavior. Low - No visible security review - There's a SECURITY.md and CI workflows, but no evidence of fuzzing or adversarial input testing for the command parsers in src/cmds/. Given the binary processes untrusted shell output, this is worth attention. Clean signals - The repo has a Cargo.lock, CI workflows (ci.yml, cd.yml, release.yml), 15 test files, and a release-please config for automated versioning. Structure is clean and well-organized.

The Bottom Line

A pragmatic tool that solves a real cost problem for teams using LLM coding agents. The token savings claims are plausible given the architecture, and the multi-agent hook support makes it broadly applicable. The main risk is maintenance burden from the fragmented hook implementations. Best suited to teams actively using Claude Code or Cursor on large codebases where token spend is a measurable line item.