rtk Review: The Rust CLI Proxy That Cuts AI Coding Bills by 80% (2026)

rtk is a zero-dependency Rust binary that intercepts and compresses CLI output before it hits your LLM context. 60–90% token savings across 100+ commands and 13 AI coding tools (Claude Code, Cursor, Copilot, Codex, Gemini CLI). MIT licensed, <10ms overhead, 30-second install.

  • Rust
  • CLI
  • Shell hooks
  • MIT
  • Updated 2026-05-22

📦 资源信息

🔧 最后维护5/20/26
🎯 版本0.28.2

Quick Answer #

Q: What is rtk and how much can it save on AI coding bills?

A: rtk is an open-source Rust CLI proxy that compresses command output before it reaches your AI agent’s context window. It cuts LLM token consumption by 60-90% across 13 AI coding tools (Claude Code, Cursor, GitHub Copilot, Gemini CLI, etc.). Real benchmark: $400/month Claude Code bill drops to ~$80, with <10ms latency overhead. MIT licensed. 30-second install.


TL;DR: rtk is a single Rust binary, zero-dependency CLI proxy that filters and compresses command output before it reaches your AI agent’s context window. It reduces LLM token consumption by 60–90% across 100+ dev commands and 13 AI coding tools, with <10ms overhead. Install in 30 seconds, forget it’s there, watch your API bill drop.


Introduction #

If you’re using Claude Code, Cursor alternatives, GitHub Copilot, Gemini CLI, or any AI coding agent daily, you already know the productivity gains are real. What fewer developers talk about is the cost curve.

dibi8’s take — We’ve spent the last quarter benchmarking AI coding cost across our own team’s workflow. The $400/month Claude API bill we noticed in March 2026 was real, and the surprising finding was that roughly 70% of those tokens were noise — the AI agent dumping git status into context, then git diff, then npm test output, much of which was redundant log lines, progress bars, or stale ASCII tree printouts. rtk is the most direct fix we’ve seen — it lives at the command boundary so you don’t have to rewrite a single workflow file.

Here’s what typical AI tooling spend looks like for a professional developer in mid-2026:

Usage PatternMonthly API CostStack Context
Light (1–2 hrs/day)$50–100Side projects, occasional agent help
Moderate (3–4 hrs/day)$150–400Full-time development with agent assistance
Heavy / Team lead$500–2,000+Agent-driven workflows, multi-file refactoring

That doesn’t include subscription fees: Claude Pro ($20), Cursor Pro ($20), ChatGPT Plus ($20), Copilot Pro ($10). Stack them up and you’re at $840+/year before API calls even start.

But here’s the painful part: a significant chunk of that API spend is pure waste. Every time your AI agent runs git status, cat package.json, cargo test, docker ps, or aws ec2 describe-instances, the raw output contains noise — blank lines, progress bars, ASCII art, redundant logs, verbose metadata — that gets stuffed into the LLM context window and billed at full token rate.

rtk exists to eliminate that waste at the source.


What rtk Actually Does (And What It Doesn’t) #

rtk (GitHub: rtk-ai/rtk) is not another AI model, not a chat interface, and not a Copilot replacement. Its job is singular and precise:

“rtk filters and compresses command outputs before they reach your LLM context.”

It sits as a transparent proxy layer between your AI agent and the shell:

Without rtk:
Claude Code --git status--> shell --> git --> raw 2,000-token output

With rtk:
Claude Code --git status--> RTK --> git --> filtered 200-token output

Core specs at a glance:

FeatureDetail
BinarySingle Rust binary, zero runtime dependencies
Coverage100+ commands across git, testing, builds, Docker, AWS, K8s
Latency<10ms filtering overhead
IntegrationAuto-rewrite hook — AI tools call rtk transparently
LicenseMIT, fully open source

Real Numbers: 80% Token Reduction in a 30-Minute Claude Code Session #

The rtk documentation provides a detailed benchmark. We reproduced it on a mid-sized TypeScript fullstack project and confirmed the savings are accurate:

OperationFrequencyRaw Tokensrtk TokensSavings
ls / tree10×2,000400-80%
cat / file reads20×40,00012,000-70%
grep / rg16,0003,200-80%
git status10×3,000600-80%
git diff10,0002,500-75%
git log2,500500-80%
git add/commit/push1,600120-92%
cargo test / npm test25,0002,500-90%
pytest / go testseveral14,0001,400-90%
Total~118,000~23,900-80%

What an 80% reduction means in practice:

If your Claude Code API bill runs $400/month, rtk drops it to ~$80. The agent receives the same actionable information — just without the noise. You’re not sacrificing context; you’re removing clutter.


The Four Compression Strategies Behind rtk #

rtk doesn’t blindly truncate output. It applies command-specific strategies:

1. Smart Filtering #

Removes LLM-irrelevant noise: comments, whitespace, boilerplate, progress bars, ASCII decorations. git push with rtk returns ok main instead of 15 lines of enumeration and compression stats.

2. Grouping #

Aggregates similar items by category. git status doesn’t list files line-by-line — it groups them by directory: src/ (8 files). Test failures show FAILED: 2/15 tests with only the specific failures expanded.

3. Smart Truncation #

Preserves structure while cutting redundancy. cat a 500-line config file and rtk keeps the structure but compresses values. Use rtk read file.rs -l aggressive to strip bodies and keep only function signatures.

4. Deduplication #

Collapses repeated lines — common in Docker logs and test output — into ... (repeated 47x).


Universal Compatibility: 13 AI Tools, One Install #

rtk’s ecosystem coverage is exceptional. It doesn’t lock you into one agent:

AI ToolInstall CommandInterception Method
Claude Codertk init -gPreToolUse hook (bash)
GitHub Copilot (VS Code)rtk init -g --copilotPreToolUse hook
Cursorrtk init -g --agent cursorhooks.json
Gemini CLIrtk init -g --geminiBeforeTool hook
Codex (OpenAI)rtk init -g --codexAGENTS.md + RTK.md
Windsurfrtk init --agent windsurf.windsurfrules
Cline / Roo Codertk init --agent cline.clinerules
OpenCodertk init -g --opencodePlugin TS
OpenClawopenclaw plugins install ./openclawPlugin TS
Hermesrtk init --agent hermesPython plugin
Kilo Codertk init --agent kilocode.kilocode/rules
Google Antigravityrtk init --agent antigravityrules file

Switch between tools without losing your token savings. rtk follows your workflow, not the other way around.

If you’re juggling multiple AI agents at once (which is common in 2026), pair rtk with CC Switch for unified management.


Installation: 30 Seconds, Zero Config #

brew install rtk
rtk init -g   # Install auto-rewrite hook for your default AI tool
# Restart Claude Code / Cursor / your agent

Linux #

curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
rtk init -g
# Inside WSL — full features
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
rtk init -g

Verify #

rtk --version   # rtk 0.28.2
rtk gain        # View token savings stats

After installation, keep using your tools exactly as before. The hook transparently rewrites bash commands — git status becomes rtk git status — without any change to your workflow.


Hands-On: From Git Workflows to AWS and Kubernetes #

Git Operations #

rtk git status        # Compact status
rtk git log -n 10     # One-line commits
rtk git diff          # Condensed diff
rtk git push          # Returns: ok main

Test Runners: Failures Only #

rtk pytest            # 90% token savings, failures only
rtk cargo test        # Same for Rust
rtk test <cmd>        # Generic test wrapper

Lint & Build: Grouped by Rule #

rtk lint              # ESLint grouped by rule/file
rtk tsc               # TypeScript errors grouped by file
rtk ruff check        # Python lint, 80% savings

Docker & K8s: Deduplicated Logs #

rtk docker ps         # Compact container list
rtk docker logs <id>  # Deduplicated logs
rtk kubectl pods      # Compact pod list

AWS: Stripped + Sanitized #

rtk aws ec2 describe-instances   # Compact instance list
rtk aws lambda list-functions    # Name/runtime/memory, secrets stripped
rtk aws s3 ls                    # Truncated with tee recovery

Data & Analytics: Structured Output #

rtk json config.json    # Structure without values (safe)
rtk deps                # Dependency summary
rtk summary <long cmd>  # Heuristic summary

Limitations and Pro Tips #

Known Limitations #

  1. Bash-only interception: Claude Code’s built-in Read, Grep, Glob tools bypass the bash hook. Workaround: use shell commands (cat, rg, find) or explicit rtk read, rtk grep.

  2. Windows native: Auto-rewrite requires a Unix shell. Native Windows (cmd/PowerShell) falls back to CLAUDE.md injection mode — works, but requires explicit rtk prefix. WSL gives full support.

  3. Edge cases may need full output: rtk saves raw output via tee on failure. Use -v / --verbose flags when you need more detail.

Best Practices #

  • Install and forget: The hook works transparently; don’t force yourself to prepend rtk
  • Check rtk gain weekly: Understand your savings profile
  • Run rtk discover: Find commands in your history that could benefit from rtk but aren’t covered yet
  • Exclude sensitive commands: In ~/.config/rtk/config.toml: exclude_commands = ["curl", "playwright"]

How rtk Compares to Alternatives #

ToolLayerApproachScopeSetup Friction
rtkCLI proxyOutput filtering/compression100+ commands, 13 agents30s, zero config
MorphAPI gatewayModel routing + context compactionGeneric API callsRequires code changes
LiteLLMLLM proxyCaching + routing + observabilityMulti-model APIsService deployment
LLMLinguaPrompt layerSemantic compressionPrompt textManual integration
ccusageMonitoringTracking only, no compressionClaude Code onlyRead-only

rtk’s unique advantage: it lives at the command layer, requires zero code changes, zero infrastructure, and zero new abstractions. It’s a transparent filter you install once and never think about again.


Bottom Line: The Highest-ROI Tool You’ll Install This Year #

In 2026’s developer tooling landscape, everyone is building more — more features, more models, more integrations. rtk is a rare example of building less, but better. It doesn’t replace your AI agent; it just makes it cheaper to feed.

  • No workflow changes
  • No code changes
  • No infrastructure
  • MIT license, completely free
  • 60–90% real token savings

If you’re paying for AI coding tools, rtk isn’t a “nice to have.” It’s the tool that makes every other tool more economically viable.

# 30 seconds. Start saving today.
brew install rtk
rtk init -g

If you’re running AI agents that need persistent shell access (CI runners, remote devboxes, self-hosted Claude Code servers), here are battle-tested VPS providers we use:

  • DigitalOcean — $5/mo droplet handles single-developer AI coding workloads, $200 in free credits for new accounts
  • HTStack — Hong Kong / Singapore VPS for low-latency Asia-Pacific access, USD $4/mo entry

For a complete budget-conscious LLM stack including rtk, see our Cheap LLM Stack collection.

This article contains affiliate links. We may earn a commission if you purchase through these links — at no extra cost to you.


Further Reading #


FAQ #

Does rtk send my code to any third party? #

No. rtk is a local-only binary. It only filters output between your shell and your AI tool’s context window. Nothing is sent over the network.

Will rtk break if I update Claude Code / Cursor? #

The hook mechanism is stable. rtk has been tracking Claude Code’s hook API since 0.10. If a breaking change ships, expect an rtk update within 24-48 hours.

Can I use rtk with custom in-house AI agents? #

Yes — rtk has a Python plugin pattern (used by Hermes) that you can adapt. Documentation in /docs/plugins/ on GitHub.

How does rtk compare to just using --no-pager or --quiet flags everywhere? #

rtk is command-aware. git --no-pager log still produces verbose output. rtk’s git log strategy specifically converts to one-line summaries with deduplication. It’s the difference between “less verbose” and “structurally compressed.”

Is rtk safe for production CI/CD? #

Yes when used in agent workflows. Don’t use it in set -e strict-mode pipelines that depend on exact command output text — but for AI agent loops that read output and decide next steps, rtk’s compressed output is what the agent actually needs.

📦 Featured in collections

💬 Discussion