rtk
CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies
- 84.3k stars
- 5.4k forks
- 1,602 open issues
- Language: Rust
- License: Apache-2.0
- updated
Install
git clone https://github.com/rtk-ai/rtk && cp rtk/*.md ~/.claude/agents/- Clone the repository and copy the agent .md definitions into ~/.claude/agents (or .claude/agents inside a project).
- Start a new Claude Code session to load the agents.
- Delegate work to them with the Task/Agent tool or by name.
Editor's note
RTK is a CLI proxy written in Rust that intercepts shell commands invoked by AI coding agents and compresses their output before it reaches the model's context window. It supports over 100 commands including `git status`, `git diff`, `cargo test`, `pytest`, `grep`, `ls`, `cat`, and `docker ps`, applying four strategies per command: smart filtering to strip noise and boilerplate, grouping of similar items such as files by directory, truncation of verbose output, and format normalization. Integration with Claude Code is handled through a Bash hook installed via `rtk init -g`, which automatically rewrites qualifying shell calls to route through RTK; the agent receives only the compressed output without any explicit changes to its prompts. According to the project's own benchmarks on a medium-sized TypeScript/Rust project, a 30-minute Claude Code session drops from roughly 118,000 tokens to about 23,900 tokens, an 80 percent reduction, with test runners like `pytest` and `go test` achieving up to 90 percent savings. The tool ships as a single static binary with no runtime dependencies, adds under 10 milliseconds of overhead, and is installable via Homebrew. Developers paying per-token API costs or hitting context limits during agentic coding sessions are the primary audience.
Subagents overview
Agent-agnostic token optimization: compress, route, filter, and more. One composable pipeline across everything your AI agent reads and sends — built on RTK's battle-tested bash-output compression (up to 90% smaller).
Website • Install • Troubleshooting • Architecture • Discord
English • Francais • 中文 • 日本語 • 한국어 • Espanol • Português
rtk filters and compresses command outputs before they reach your LLM context. Single Rust binary, 100+ supported commands, <10ms overhead.
What RTK Does
RTK intercepts shell commands and compresses their output before your agent reads it.
| Operation | What RTK does to the output |
|---|---|
ls / tree | Tree format with file counts instead of one line per entry |
cat / read | Smart file reading: signatures and structure over full bodies |
grep / rg | Truncates long lines, groups matches by file |
ast-grep | Groups structural matches by file, caps overflow |
git status | Compact stat format, grouped by state |
git diff | Reduced context, headers stripped |
git log | Hash, author and subject only |
git add/commit/push | Confirmation line instead of full progress output |
cargo test / npm test | Failures only, passing tests collapsed to a count |
ruff check | Grouped by rule and file |
sqlfluff lint | Grouped by rule and file |
pytest | Failures only, traceback trimmed |
go test | NDJSON parsed, failures only |
docker ps | Essential fields only |
How Savings Work
RTK reduces the bash output your agent reads. That is what RTK measures, and it is not the same as cutting your bill by the same amount.
Bash output is one contributor to input tokens, alongside your prompt, the system prompt and conversation history. Input tokens are in turn only part of the bill, which also counts output tokens. The reduction dilutes at every step.
The token counts RTK reports are estimated as bytes / 4 — RTK ships no tokenizer, so the percentages are reliable but the absolute token numbers are approximate.
Full explanation: How RTK Savings Work
Installation
brew install rtk # macOS / Linux
winget install rtk-ai.rtk # Windows
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | shThen check you have the right package — another project named "rtk" exists on crates.io:
rtk --version # any current version
rtk gain # must show the savings dashboard, not "command not found"Cargo, pre-built binaries, native Windows, WSL, and uninstall: Installation guide
What You Install
RTK ships as three downloads. The two rtk editions install a binary with the same name — hooks, scripts and agent config work unchanged across both — so they cannot be installed together. Uninstall one before installing the other.
flowchart TD
agent["Your coding agent"]
subgraph editions["Pick one · both install a binary named rtk"]
direction LR
full["<b>rtk</b><br/>Apache-2.0 + BUSL-1.1<br/>hooks · filters · engine"]
oss["<b>rtk-oss</b><br/>Apache-2.0 only<br/>hooks · filters"]
end
proxy["<b>rtk-proxy</b><br/>BUSL-1.1<br/>compresses API traffic"]
agent -->|"command output"| full
agent -->|"command output"| oss
agent -.->|"API traffic"| proxy
classDef apache stroke:#2da44e,stroke-width:2px,fill:none
classDef busl stroke:#0969da,stroke-width:2px,fill:none
classDef mixed stroke:#8250df,stroke-width:2px,fill:none
classDef plain stroke:#8c959f,stroke-width:1px,fill:none
class full mixed
class oss apache
class proxy busl
class agent plain
style editions fill:none,stroke:#d0d7de,stroke-dasharray:4 4| Download | Licence | Contains |
|---|---|---|
rtk- | Apache-2.0 + BUSL-1.1 | Hook core, every command filter, and the compression engine |
rtk-oss- | Apache-2.0 only | Hook core and every command filter. No engine. |
rtk-proxy- | BUSL-1.1 | The RTK Proxy daemon. Never bundled with either rtk. |
Production use is free, engine and daemon included. What the BUSL grant does not cover is offering RTK or a derivative to third parties as a commercial product or service — for that, contact contact@rtk-ai.app.
curl -fsSL .../install.sh | RTK_EDITION=oss sh # Apache-2.0 edition
brew install rtk-ai/tap/rtk-ossWhat the Apache-2.0 edition omits and where the licence boundary falls: Editions and Licensing
Quick Start
# 1. Install for your AI tool
rtk init -g # Claude Code / Copilot (default)
rtk init -g --gemini # Gemini CLI
rtk init -g --codex # Codex (OpenAI)
rtk init -g --agent cursor # Cursor
rtk init -g --agent windsurf # Windsurf
rtk init --agent cline # Cline / Roo Code
rtk init --agent kilocode # Kilo Code
rtk init --agent antigravity # Google Antigravity
rtk init --agent kimi # Kimi AI
rtk init -g --agent pi # Pi
rtk init --agent omp # Oh My Pi (OMP)
rtk init --agent hermes # Hermes
rtk init -g --agent droid # Factory Droid
rtk init --agent trae # Trae (project: .trae/hooks.json)
rtk init -g --agent trae # Trae global: ~/.trae and existing ~/.trae-cn
# 2. Restart your AI tool, then test
git status # Automatically rewritten to rtk git statusThe agent receives compact output without ever calling rtk explicitly.
The hook only fires on Bash tool calls. Built-in tools like Read, Grep and Glob do not pass through it. Use shell commands (cat, rg, find) or call rtk read, rtk grep, rtk find directly.
Per-agent setup,
--dry-run, and uninstall: Quick Start · Supported Agents
How It Works
Without rtk: With rtk:
Claude --git status--> shell --> git Claude --git status--> RTK --> git
^ | ^ | |
| full raw output | | compact output | filter |
+-----------------------------------+ +------- (filtered) ---+----------+Four strategies applied per command type:
Smart Filtering - Removes noise (comments, whitespace, boilerplate)
Grouping - Aggregates similar items (files by directory, errors by type)
Truncation - Keeps relevant context, cuts redundancy
Deduplication - Collapses repeated log lines with counts
Does RTK break Claude's prompt cache? No. RTK filters output once per command. The result is stored in history and cached normally on subsequent API calls, so the cache keeps working as expected. Smaller outputs also mean cheaper cache writes and reads. See Troubleshooting for details.
Supported AI Tools
RTK supports 18 AI coding tools. Each integration rewrites shell commands to rtk equivalents, reducing the bash output the agent reads where the agent supports command interception.
| Tool | Install | Method |
|---|---|---|
| Claude Code | rtk init -g | PreToolUse hook (native binary) |
What people ask about rtk
What is rtk-ai/rtk?
rtk-ai/rtk is subagents for the Claude AI ecosystem. CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies It has 84.3k GitHub stars and its last recorded update is dated 2026-10-23.
How do I install rtk?
You can install rtk by cloning the repository (https://github.com/rtk-ai/rtk) or following the README instructions on GitHub. ClaudeWave also provides quick install blocks on this page.
Is rtk-ai/rtk safe to use?
Our security agent has analyzed rtk-ai/rtk and assigned a Trust Score of 97/100 (tier: Verified). See the full breakdown of passed checks and flags on this page.
Who maintains rtk-ai/rtk?
rtk-ai/rtk is maintained by rtk-ai. The last recorded GitHub activity is dated 2026-10-23, with 1602 open issues.
Are there alternatives to rtk?
Yes. On ClaudeWave you can browse similar subagents at /categories/agents, sorted by popularity or recent activity.
Maintain this repo? Show its Trust Score in your README
The badge shows this repository's current Trust Score and verdict, and links back to this page. It follows the catalogue data: nobody can buy or edit the score it displays.
[](https://claudewave.com/en/repo/rtk-ai-rtk)<a href="https://claudewave.com/en/repo/rtk-ai-rtk"><img src="https://claudewave.com/api/badge/rtk-ai-rtk" alt="ClaudeWave Trust Score for rtk-ai/rtk" width="320" height="64"></a>