graph TD
A[AI Agent 发起命令] --> B[RTK 拦截入口]
B --> C{"命令类型识别"}
C -->|"cargo / npm 构建"| D[构建日志压缩器]
C -->|"git 历史与 diff"| E[Git 输出压缩器]
C -->|"find / ls 文件列表"| F[文件清单聚合器]
C -->|"未知命令"| G[透传原始输出]
D --> H[规则引擎:去噪-聚合-截断]
E --> H
F --> H
H --> I[Token 预算校验]
I -->|"超出预算"| J[分级摘要+关键行保留]
I -->|"预算内"| K[直接输出]
J --> L[回传 Agent 上下文]
K --> L
G --> L
① Install & forget: up to 90% less command output.
Test runs, diffs, logs and builds are compressed before your agent reads them. 100+ commands, under 25 ms per command, no config, nothing changes in how you work. rtk gain shows what you saved.
② Go further with pipelines, as far as you take it.
Hand heavy reads to a cheaper model, compress more than bash, clean the API traffic without breaking the prompt cache. One agent-agnostic file: start from a built-in, install one someone shared, or write and share your own.
The community built the bash compressor 85k developers starred. Now it is building pipelines: the best one listed today cuts total cost by 20.2% in its author’s benchmark.
Agents across the whole company?RTK Pro is the control layer for every AI agent: one gateway for every AI call, costs, secrets and personal data, policies, team catalog, audit. Discover RTK Pro ↓
Install & forget
macOS, and Linux with Homebrew
brew install rtk
Windows, with winget
winget install rtk-ai.rtk
Linux, macOS, WSL, or Git Bash on Windows, with the install script
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
Then plug it into your agent
rtk init -g # Claude Code; every other agent: see "Works in your agent"
Restart your agent. That’s it: when it runs git status, RTK runs rtk git status and the agent reads a 3-line summary instead of 40 lines. Nothing to learn, nothing to call, and upgrading RTK never changes this.
Another project named “rtk” exists on crates.io. Check you have this one: rtk gain must show the savings dashboard, not “command not found”.
Cargo, pre-built binaries, native Windows, WSL and uninstall: Installation guide · per-agent setup and --dry-run: Quick Start
Measure it: rtk gain
Every command RTK touches is counted on your machine. One command shows what it saved, today and since you installed it.
rtk gain # Summary stats
rtk gain --graph # ASCII graph (last 30 days)
rtk gain --history # Recent command history
rtk gain --daily # Day-by-day breakdown
rtk gain --all --format json # JSON export for dashboards
rtk discover # Find missed savings opportunities
rtk discover --all --since 7 # All projects, last 7 days
rtk session # Show RTK adoption across recent sessions
What the numbers mean. The compressor reduces the command output your agent reads, which is one part of the input tokens, which are one part of the bill: a 90% cut in command output is not a 90% cut in cost. Token counts are estimated as bytes / 4, so the percentages are reliable and the absolute numbers are approximate.
After a week of data, rtk gain ends with one line about RTK Pro, at most once a day and only on a terminal. pro_hint = false under [display] in config.toml turns it off.
The part 85k developers starred. Built by 200+ contributors, written against real command output, and every filter has to cut at least 20% to ship.
Operation
What the agent reads
cargo test / npm test / pytest / go test
Failures only, with their assertion; passing tests collapsed to a count
git status / git diff / git log
Compact status, reduced diff context, one line per commit
git add/commit/push
A confirmation line instead of progress output
ls / tree / grep / rg
Trees with counts, matches grouped by file, long lines cut
ruff check / eslint / cargo clippy
Grouped by rule and file
docker ps / kubectl
Essential fields only
100+ commands across Git, GitHub CLI, Cargo/Rust, JavaScript (npm, pnpm, vitest, jest, tsc, Next.js, Angular, Playwright, Prisma), Python (ruff, pytest, mypy, pip), Go (go test, golangci-lint), Ruby, .NET, JVM (Gradle, Maven), PHP, Docker, Kubernetes, AWS, Terraform, and the file/search builtins. Every command and its filter: What RTK Optimizes
Three promises
Never blocks. If a filter fails, you get the raw output, and the command’s exit code is passed through unchanged.
Never worse. RTK never prints more than the command did.
Nothing hidden. Output that is cut says where the full version is, and rtk bypass runs any command unfiltered, still tracked in rtk gain:
rtk bypass git log --oneline -20 # full git log, no truncation
rtk bypass npm install express # raw npm output
The hook rewrites shell commands. Built-in tools such as Read, Grep and Glob pass through untouched out of the box; in Claude Code, a pipeline compresses them too (see Pipelines below).
Does RTK break the prompt cache? No: output is filtered once, before it enters the conversation. Details.
Want to go further? Pipelines.
Out of the box, RTK compresses command output and stops there. A pipeline is how you ask it for more: one small file that tells RTK what to do with what your agent reads and sends. No file means the compressor above and nothing else; a pipeline adds one thing at a time, and you can take it back out.
What people turn on first
Compress everything the agent reads, not just shell output: grep results, web pages, lockfiles, any output RTK has no filter for (Claude Code).
Hand big file reads to a cheaper model you choose. The file never enters your agent’s context (Claude Code, with your API key).
Clean the API traffic your agent re-sends every turn, with the prompt cache kept intact (through the optional proxy, below).
Make the agent write less: terse prose, with code, paths, commands and errors kept in full (every agent).
Each of these is a built-in pipeline, one line to turn on. rtk-ai.app/pipelines lists them next to the pipelines the community shares, each with what it saved and how that was measured. Installing one is a single command:
rtk pipeline add github:user/repo # check and install a shared pipeline
A pipeline can rewrite commands and send content to the models it declares, so read its file before you install it. Written once, a pipeline works in every agent RTK supports, as far as that agent’s hooks allow: Agent Coverage shows what runs where.
The rtk-proxy daemon runs the same pipeline on your agent’s provider-API traffic: it strips bytes no model ever needed without breaking the prompt cache, and carries the calls your pipeline routes to cheaper models on the credential your agent already sends, so they show up in rtk gain. rtk init -g offers to set it up; rtk claude starts it and launches Claude through it with no configuration at all.
rtk claude # start the daemon if needed, then launch Claude through it
rtk llm-proxy status # is it up
rtk gain # savings, command filtering and proxy side by side
Separate binary, separate licence (BUSL-1.1), its own rtk-proxy-<target> archive: rtk never links it. Not the same thing as rtk bypass, which runs one local command unfiltered.
Agents across the whole company? Know what they cost, what they touch, and who ran what.
RTK runs on each developer’s machine. RTK Pro connects them into one control layer for the whole company:
Gateway. Every AI call goes through one place, whichever provider each team uses.
Cost control. Spend by team, person and model. Waste found and removed. Budgets that warn, then stop.
Shield. Secrets and personal data masked before any model sees them.
Policies. Risky commands stopped before they run.
Team catalog. Skills, MCP servers and pipelines, assigned per team and project.
Audit log. Who did what, and whether it was allowed.
Nothing changes for the developer. No secret value ever leaves the machine. The CLI stays free and open source.
Just you?
Your team, or the whole company?
The Dev plan: guardrails and analytics for one developer. Your own dashboard of spend per project and per model, the Shield and policies on your machine, nothing to administer.
Teams, Business and Enterprise: the full control layer for every developer, with SSO and the audit log, scaled across the organisation, up to on-premise deployment and a custom SLA.
RTK supports 18 AI coding tools. With a hook or plugin, rtk init installs it and compression is automatic. With a rules file, RTK asks the model to prefer rtk commands instead.
RTK collects no command content and no file contents. Telemetry is anonymous and off by default — it sends nothing until you opt in with explicit consent (GDPR Art. 6 & 7) via rtk telemetry enable, and documented in Telemetry & Privacy.
Editions and licence
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.
Download
Licence
Contains
rtk-<target>
Apache-2.0 + BUSL-1.1
Hook core, every command filter, and the pipeline engine
rtk-oss-<target>
Apache-2.0 only
Hook core and every command filter. No engine.
rtk-proxy-<target>
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 [email protected].
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
The rtk CLI is Apache-2.0 — see LICENSE. It links one component under a different licence: rtk-engine (engine/) is BUSL-1.1, source-available: see engine/LICENSE. Its Additional Use Grant permits production use as part of the rtk binary, so running rtk is covered; using the engine on its own, or inside another product, is not until the Change Date. The rtk-proxy daemon (proxy/) is BUSL-1.1 on the same terms and ships as its own archive with its licence alongside — rtk never links it.
What the Apache-2.0 edition omits and where the licence boundary falls: Editions and Licensing
Contributions welcome: a new filter, a fix, or a pipeline you publish with rtk pipeline share publish. Open an issue or PR on GitHub and read CONTRIBUTING.md first.
评论