rtk-ai /
rtk
A command-line proxy that shrinks shell output before your AI coding agent reads it
- 84.3k stars
- 2.1k stars since 3 Oct
- Rust
- Updated today
- Beginner friendly
- Token & cost savings
AI coding agents run shell commands constantly, and the raw output is often long: full git diffs, progress bars, hundreds of passing tests. All of that lands in the model's context and costs tokens. RTK sits between the agent and the command and passes along a shorter version.
It works through a hook. When the agent runs a Bash command like git status, the hook rewrites it to rtk git status. RTK runs the real command, then trims the result by filtering noise, grouping similar items, truncating, and collapsing repeated lines into counts. The agent never has to call rtk itself.
The README is careful about what the numbers mean. Up to 90% is the cut in bash output only, not in your bill, because bash output is just one part of the input and input is only part of the cost. Token counts are estimated as bytes divided by four, so the percentages are more reliable than the absolute numbers. It also says the filtering does not break Claude's prompt cache.
What it does
Compact output for 100+ commands
Covers git, GitHub CLI, test runners (pytest, jest, cargo, go), linters, package managers, Docker, kubectl, AWS and Pulumi. Test runs show failures only, with passing tests collapsed to a count.
Automatic command rewriting
A hook rewrites Bash calls such as
git statustortk git statusbefore they run. Plugin-based agents like Hermes use their plugin API instead.Works with many agents
rtk inithas setup options for Claude Code, Copilot, Gemini CLI, Codex, Cursor, Windsurf, Cline, Kilo Code and several others.Smart file reading
rtk readshows signatures and structure instead of full bodies, andrtk smartgives a two-line summary of a code file. Built-in tools like Read, Grep and Glob in Claude Code bypass the hook, so you call these directly.Savings dashboard
rtk gainshows how much output RTK has trimmed. The tool is one Rust binary with under 10ms of overhead per command.
What you could build
- Cut the noise from test and build output when an agent runs cargo, pytest or npm test in a loop.
- Keep long agent sessions inside the context window by shrinking git diff, log and status output.
- Make Docker, kubectl or AWS CLI output readable for an agent without it wading through full JSON or logs.
- Check how much bash output your agent reads by running rtk gain after a working session.
- Set up the same output compression across several agents, such as Claude Code, Cursor and Gemini CLI.
Get started
Install RTK with Homebrew (or winget, the install script, or cargo), then run rtk init with the flag for your agent. Restart the agent, run a command like git status, and check rtk gain to see the savings. If rtk gain fails you may have the unrelated Rust Type Kit package, so install with cargo from the GitHub repo.
brew install rtkrtk init -grtk gainCommands are copied from the project's README. Read it on GitHub for the full setup.
More in Token & cost savings
caveman
Makes coding agents answer tersely and shrinks the logs and output they read
billion-context
A proxy that compresses long coding-agent chats so one session can run for weeks