rtk: A Rust CLI Proxy That Shrinks Agent-Read Bash Output
CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies.
At a glance
- What is it?
- rtk is a single-binary Rust tool that intercepts shell commands and compresses their output before an LLM agent sees it. It claims up to 90% reduction in bash output, but the README is careful to note that this is not the same as a 90% bill cut.
- Who is it for?
- Adopt rtk if you use hook-based agents like Claude Code or Copilot, run repetitive git, grep, or test commands, and want to reduce input tokens from bash output. Skip it if your workflow depends on Claude Code's built-in Read, Grep, or Glob tools, since those bypass the hook and won't be compressed.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
The Problem rtk Solves
LLM-based coding agents read command output to understand what happened. A `git status` or `cargo test` can dump hundreds of lines, most of which are noise. That output becomes input tokens, which add to the cost and slow down the agent's context. rtk sits between the agent and the shell. It rewrites commands like `git status` to `rtk git status`, then filters the output before the agent sees it. The target user is someone who drives an AI assistant through a terminal, not someone who reads output themselves. The README lists support for Claude Code, Copilot, Gemini CLI, Codex, Cursor, Windsurf, Cline, and several others. If you live in a hook-based agent and run common dev commands repeatedly, rtk directly attacks the token bloat.
How rtk Achieves Compression
rtk applies four strategies per command type. Smart filtering removes comments, whitespace, and boilerplate. Grouping aggregates similar items, like files by directory or errors by type. Truncation keeps relevant context while cutting redundancy. Deduplication collapses repeated log lines into counts. The README gives concrete examples. `ls` becomes a tree with file counts instead of one line per entry. `git diff` has headers stripped. `cargo test` shows failures only, with passing tests collapsed to a count. `pytest` trims tracebacks. `docker ps` keeps essential fields only. The architecture diagram shows RTK as a proxy between the agent and the shell. The agent sends a command, RTK filters it, passes it to git or cargo, then compresses the output before returning it. This is not a tokenizer. The README states that token counts are estimated as `bytes / 4`, so the percentages are reliable but absolute numbers are approximate. That is a real limitation to keep in mind.
Installation and Setup
The recommended install on macOS is Homebrew: `brew install rtk`. Linux and macOS users can use the quick install script: `curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh`. That installs to `~/.local/bin`, and you may need to add it to your PATH. Cargo users can run `cargo install --git https://github.com/rtk-ai/rtk`. Pre-built binaries exist for macOS, Linux, and Windows. Windows users must run `rtk.exe` from a terminal, not by double-clicking. After install, verify with `rtk --version` and `rtk gain`, which shows a savings dashboard. There is a name collision warning: another project called rtk on crates.io is a Rust Type Kit. If `rtk gain` fails, you likely have the wrong package. The quick start shows `rtk init -g` for Claude Code and Copilot, with flags for Gemini and Codex, and agent-specific flags for Cursor, Windsurf, Cline, and others. The hook rewrites Bash tool calls only. Built-in tools like Read, Grep, and Glob do not pass through the hook, so they are not compressed.
Command Coverage and Examples
The README lists over 100 supported commands, but the visible table covers a subset. File commands include `rtk ls .`, `rtk read file.rs`, `rtk read file.rs -l aggressive` for signatures only, `rtk smart file.rs` for a 2-line heuristic summary, `rtk find "*.rs" .`, `rtk grep "pattern" .`, and `rtk diff file1 file2`. Git commands include `rtk git status` and `rtk git log -n 10`. Test commands cover cargo, npm, pytest, and go test. The `rtk diff` command returns exit code 1 if files differ, which is useful for scripts. The aggressive read mode strips bodies, which is a trade-off between context and detail. The README emphasizes that the percentages are reductions in bash output, not bill reductions. The savings dilute because bash output is only one contributor to input tokens, and input tokens are only part of the bill. That honesty is refreshing, but it also means you should not expect a 90% cost drop.
Limitations and Failure Modes
The most obvious limitation is that the hook only applies to Bash tool calls. If your agent uses built-in tools like Read, Grep, or Glob, those outputs are not compressed. The README suggests using shell commands or calling `rtk read`, `rtk grep`, or `rtk find` directly. That is a workaround, not a seamless integration. Another limitation is the token estimation method. Since rtk has no tokenizer, it uses `bytes / 4`. That undercounts or overcounts depending on the language and tokenizer. The percentages may be reliable for relative comparisons, but the absolute numbers are guesses. A third failure mode is truncation. For `git diff`, headers are stripped, which may hide commit messages or metadata you need. For `cargo test`, passing tests are collapsed to a count, so you cannot see individual test names unless they fail. If you are debugging a subtle flaky test, that could be a problem. The aggressive read mode strips bodies entirely, which is useful for large files but useless if you need the code.
Alternatives and Trade-offs
The main alternative is to not use a proxy and instead rely on your agent's native context management. Claude Code, for example, has its own token optimization and can summarize output. The difference is that rtk operates at the shell level, before the agent sees anything. That means it can compress output that the agent's built-in tools might not touch. Another alternative is to use a general-purpose tool like `jq` to parse JSON output, or `sed` and `awk` to trim text. Those give you full control but require manual setup for each command. rtk automates the filtering per command type, which is its value. The trade-off is that rtk's filters are fixed heuristics. You cannot easily customize them without modifying the source. The README mentions an architecture doc, but the visible material does not describe a configuration file for custom rules. If you need command-specific output that differs from rtk's defaults, you may fight the tool.
Maintenance and License
rtk is licensed under Apache-2.0, which permits commercial use, modification, and distribution, with conditions on patent and attribution. The project is on the develop branch, with the last push on 2026-08-28 and a release candidate `dev-0.46.1-rc.368`. There is a stable release v0.46.0 from 2026-08-26. The frequent releases suggest active development, but also that the API and behavior may change. The README's quick start shows `rtk init` with many agent flags, which implies the tool tracks agent-specific hook mechanisms. That means upgrades could break compatibility with a particular agent version. The install script points to the master branch, while the default branch is develop. That mismatch is worth noting. If you install from the script, you may get a different version than what is on the develop branch. For production use, pin a release binary rather than following the rolling install script.
Editorial conclusion
Adopt rtk if you use hook-based agents like Claude Code or Copilot, run repetitive git, grep, or test commands, and want to reduce input tokens from bash output. Skip it if your workflow depends on Claude Code's built-in Read, Grep, or Glob tools, since those bypass the hook and won't be compressed. Before adopting, verify the token savings on your own commands with `rtk gain`, confirm the absolute token numbers are estimates (bytes/4), and check that the hook rewrites the exact commands you use. If you rely on full raw output for debugging, rtk's truncation may hide details you need. The project is under active development with frequent releases, so pin a specific version rather than tracking the default develop branch.
Community notes