
Who rtk is for#
Developers on API-billed AI coding tools
Teams using Aider, Gemini CLI, or the OpenAI Codex API pay per input token. For these users, every filtered command call directly reduces cost. The website cites a ten-person team wasting roughly $1,750 per month on CLI noise before filtering. rtk's 89% average bash output reduction on common commands translates to measurable billing impact, diluted by prompt and output tokens but real in absolute terms.
Skip if:
You are on a flat-rate subscription and have never hit context overflow or rate limits during a session. Token compression still extends sessions, but the direct billing impact is absent.
Claude Code and Cursor users with long agentic sessions
On flat-rate plans, rtk extends how many tool calls fit in a session before context overflow forces a restart. For complex multi-file refactors or long debugging sessions with many git and test commands, the extra headroom can mean completing a task in one session instead of two. The auto-rewrite hook makes adoption invisible: install once, restart the agent, and every subsequent Bash call is filtered automatically.
Skip if:
Your sessions are short and focused on reading and editing files through native agent tools. rtk's value compounds with Bash tool call volume; low-Bash workflows see limited benefit.
Teams deploying AI coding infrastructure
Organizations running their own LLM infrastructure can deploy rtk alongside existing tooling without any vendor dependency. Since rtk operates as a local binary that compresses shell output before it reaches any network boundary, it integrates cleanly with on-premise AI coding setups and requires no changes to LLM routing or API configuration.
Skip if:
Your managed AI coding platform already compresses or summarizes tool call output at the platform level, in which case rtk adds redundant filtering.
The problem it solves#
Every command an AI coding agent runs dumps raw output into the context window. A cargo test suite with 262 passing tests outputs over 4,800 tokens of boilerplate. A git diff on a medium-sized change can reach 21,500 tokens. For pay-per-token users on tools like Aider, Gemini CLI, or the raw Anthropic API, that verbose output makes up the majority of the bill. For flat-rate users on Claude Code or Cursor, the same noise fills the context window faster, triggering rate limits and forcing session restarts before complex tasks finish. The website cites a team of ten wasting roughly $1,750 per month on CLI noise alone.
The problem is structural: developer CLI tools output for human readers who scan rather than read every line. Test runners print every passing test. Git diff shows full surrounding context. Directory listings expand to one line per file. None of these tools have an agent-friendly output mode, and teams either accept the waste or maintain fragile per-tool wrappers that break across version updates.
How it solves it#
100+ command-specific output filters
rtk ships pre-built filters for the commands AI coding agents call most: git status, git diff, git log, cargo test, pytest, go test, jest, vitest, docker ps, kubectl pods, AWS CLI subcommands, eslint, tsc, ruff, and more. Each filter applies the right strategy for that command's structure. Cargo test collapses all passing tests to a count and shows only failures; git log trims to hash, author, and subject; git push returns a single confirmation line instead of 15 lines of progress output.
Auto-rewrite hook for 16 AI coding tools
Run `rtk init -g` once to install a PreToolUse hook in your AI tool's configuration. From that point, every Bash call is transparently rewritten to the rtk equivalent before the agent sees any output. Supports Claude Code, GitHub Copilot, Cursor, Gemini CLI, Codex, Windsurf, Cline, OpenCode, Pi, Hermes, Mistral Vibe, Kilo Code, Google Antigravity, Kimi AI, and Factory Droid across macOS, Linux, and native Windows.
Token savings analytics via rtk gain
The `rtk gain` command shows a summary of tokens saved, broken down by command type, with daily, weekly, and monthly views and an ASCII graph of the last 30 days. Savings are stored locally in SQLite with no external telemetry. One developer reported 138 million tokens saved across 15,720 commands after several weeks of daily use. The `rtk discover` command scans recent session logs to identify commands not yet routed through rtk.
Single Rust binary, under 10ms overhead
rtk is a single statically-linked Rust binary with zero runtime dependencies. It adds under 10 milliseconds of overhead per command, making it transparent during interactive and agentic use. Install options: Homebrew (`brew install rtk`), the curl one-liner for Linux and macOS, pre-built binaries for macOS, Linux, and Windows from GitHub releases, or `cargo install --git https://github.com/rtk-ai/rtk`.
Smart file reading and code summarization
The `rtk read` command applies heuristic file summarization: standard mode returns signatures and structure rather than full file bodies; aggressive mode (`-l aggressive`) returns function and type signatures only. The `rtk smart` command produces a two-line heuristic code summary. These reduce the token cost of file inspection operations that AI coding agents frequently perform during code exploration.
Strengths and trade-offs#
Strengths
- Zero-infrastructure deploymentrtk runs locally as a single binary with no server, no API key, and no routing layer between your agent and the LLM. Token savings happen on the input side before any network call. This is categorically different from cloud-based token management tools that require proxying LLM traffic through an external service. A developer on a corporate network with outbound restrictions can use rtk without any external dependency.
- Apache 2.0 license with no commercial restrictionsThe Apache 2.0 license permits commercial use, modification, and redistribution without restriction. Teams can include rtk in internal tooling, CI environments, or shipped developer products without a license review. Unlike paid token management platforms where usage costs scale with volume, rtk's cost is fixed at zero for the binary itself.
- Savings measured on real developer commandsThe 89.2% average noise reduction comes from 2,927 actual developer commands, not a synthetic benchmark. The README explicitly notes that bash output savings do not map 1:1 to billing reduction: bash output is one input token source, and input tokens are only part of the bill. This honest disclosure distinguishes rtk from tools that present savings figures without qualification.
- Native Windows support since v0.37.2The auto-rewrite hook runs as a native binary command on Windows from v0.37.2, requiring no Unix shell, bash, or jq. Command Prompt, PowerShell, and Windows Terminal all work identically to macOS and Linux. Pre-built binaries for x86_64 Windows are available in GitHub releases. WSL is also fully supported with the standard Linux install path.
Trade-offs
- -Token counts are approximations, not exact figuresrtk estimates token counts as bytes divided by 4 rather than using a model-specific tokenizer. The README explicitly flags this: percentage reductions are reliable relative indicators, but the absolute token numbers shown in `rtk gain` are approximate and should not be used for billing reconciliation. If you need exact token counts for cost attribution, compare against your LLM provider's usage dashboard.
- -Hook applies to Bash calls only, not native agent toolsThe auto-rewrite hook intercepts Bash tool calls made by the AI agent. Claude Code built-in tools (Read, Grep, Glob) bypass the hook entirely. To get rtk filtering on those workflows, you must use shell equivalents (cat, rg, find) or call rtk commands directly. Agents that rely heavily on native tool calls rather than shell commands see less benefit.
- -High open issue count reflects broad adoption and coverage gapsThe repo carried 1,970 open issues at time of writing, against 76,500+ stars. The volume reflects both project scale and gaps in filter coverage for niche commands. Core git, cargo, pytest, and docker filters are well-tested; if your toolchain includes less common tools (Scala sbt, some OpenShift oc subcommands), verify filter behavior before relying on it in production sessions.
rtk vs alternatives#
rtk vs Portkey
Portkey is a commercial LLM gateway that routes API calls across providers, adds semantic caching, and provides observability over LLM traffic. rtk operates at a different layer: it compresses bash command output before the AI agent reads it, so the input token load is reduced before the API call is even constructed.
| Feature | rtk | Portkey |
|---|---|---|
| License | Apache-2.0 | Proprietary |
| Deployment | Local CLI binary | Managed cloud or self-hosted gateway |
| Approach | CLI output compression | API routing, caching, observability |
| Cost | Free | Paid commercial tiers |
rtk is the better fit when verbose CLI output (test runners, git, build tools) is the primary source of token waste in your agentic coding workflow. Portkey suits teams building LLM applications that need cross-provider routing, caching of repeated prompts, or compliance-grade audit logs across all LLM calls, which rtk does not provide.
rtk vs TokenShift and Bifrost (Maxim AI)
TokenShift and Bifrost (Maxim AI) are commercial LLMOps platforms that address token costs and model governance at the API and prompt layer. rtk targets an earlier waste source: the raw bash output that fills an AI coding agent's context window before the LLM message is even built.
| Feature | rtk | TokenShift / Bifrost |
|---|---|---|
| License | Apache-2.0 | Proprietary |
| Deployment | Local binary | Managed cloud service |
| Approach | Shell output compression | Prompt and API-level optimization |
| Cost | Free | Paid |
For developers whose primary token waste is in CLI tool output during agentic coding sessions, rtk provides open source coverage that LLMOps platforms do not specifically target. TokenShift and Bifrost remain relevant for broader LLM application observability, model routing, and governance across diverse application types beyond coding agents.
Install and self-host#
Install rtk as a single binary via Homebrew, then run setup to activate the auto-rewrite hook for your AI coding tool.
```bash
brew install rtk
rtk init -g
```What it's built on#
- Languages
- PythonRustTypeScript
FAQ#
Is rtk free to use?
Yes. rtk is Apache 2.0 licensed and free to use, modify, and redistribute. The core CLI tool has no feature restrictions on the open source tier. RTK Pro is a separate commercial tier for teams that need token governance, security controls, and organizational analytics, but the open source binary covers the full filtering and savings analytics feature set.
Does rtk work with Claude Code?
Yes. Run rtk init -g to install a PreToolUse hook in Claude Code's settings.json. After restarting Claude Code, every Bash call is automatically rewritten to the rtk equivalent before execution. Claude Code's built-in tools (Read, Grep, Glob) are not intercepted by the hook; to get rtk filtering on those workflows, use shell commands (cat, rg, find) or explicit rtk subcommands instead.
How much does rtk actually reduce my LLM bill?
rtk removes an average of 89.2% of bash output by bytes, but that does not translate to an 89% billing reduction. Bash output is one contributor to input tokens, alongside your prompt, system prompt, and conversation history. Input tokens are also only part of the bill, which also counts output tokens. The README makes this explicit. The actual billing reduction is real but diluted at each step; it is most significant for API-billed tools where CLI-heavy sessions generate high input token counts.
Does rtk send any data to external servers?
No. rtk runs entirely as a local binary. It intercepts and compresses command output locally and writes savings data to a local SQLite database. No telemetry or usage data is sent externally. RTK Pro, the commercial team tier, may have different data handling for its governance features; check its documentation if that tier is relevant to your team.
What AI coding tools does rtk support?
rtk supports 16 AI coding tools as of the current README: Claude Code, GitHub Copilot (VS Code and CLI), Cursor, Gemini CLI, Codex, Windsurf, Cline and Roo Code, OpenCode, OpenClaw, Pi, Hermes, Mistral Vibe, Kilo Code, Google Antigravity, Kimi AI, and Factory Droid. Each has its own init flag documented in the README and on the project website's supported agents guide.
Similar open-source tools#
Switchyard
LLM proxy with API translation and multi-backend routing
9Router
Smart AI Router with 3-Tier Fallback
Caveman
Token-slashing caveman-speak for cheaper, faster AI code.
Apache APISIX
Cloud-native API gateway with dynamic routing and plugins
agent-toolkit-for-aws
Empower AI agents to build and manage AWS applications
LMCache
Accelerate AI applications with caching technology

