Skip to main content

What is RTK?

RTK (Rust Token Killer) is a high-performance CLI proxy that minimizes LLM token consumption by filtering and compressing command outputs. It achieves 60-90% token savings on common development operations through:
  • 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

Command Categories

File Operations

Directory listing, file reading, search, and find operations

Git

All git operations with ultra-compact output

Testing

Test runners showing failures only (90% savings)

JavaScript/TypeScript

Modern JS stack: ESLint, TypeScript, Next.js, Vitest, Playwright

Python

Ruff, pytest, pip, mypy with JSON/text parsers

Go

Go test, build, vet, golangci-lint with NDJSON streaming

Containers

Docker and Kubernetes with compact container lists

GitHub

GitHub CLI with compact PR/issue/run views

Global Flags

All RTK commands support these global flags:
-v, --verbose
flag
Increase verbosity level. Use multiple times for more detail:
  • -v: Basic debug info
  • -vv: Detailed execution traces
  • -vvv: Maximum verbosity
-u, --ultra-compact
flag
Enable ultra-compact mode:
  • ASCII icons instead of Unicode emoji
  • Inline format with minimal whitespace
  • Extra token savings (10-15% on top of default)

Common Patterns

Exit Code Preservation

All RTK commands preserve the original command’s exit code, making them safe for CI/CD:
# CI pipeline example
rtk cargo test || exit 1
rtk go test ./... || exit 1
rtk pytest || exit 1

Fallback to Raw Commands

If RTK’s filter fails, it automatically falls back to raw command execution:
# If filter crashes, you still get output
rtk git status  # Falls back to raw git status on error

Tee Output Recovery

On command failure, RTK saves full unfiltered output to ~/.local/share/rtk/tee/ so LLMs can read details without re-running:
rtk cargo test  # Fails
# Output: "✗ 2 tests failed"
# [full output: ~/.local/share/rtk/tee/1707753600_cargo_test.log]
LLMs can then read the tee file instead of re-executing the test suite.

Proxy Mode

Bypass RTK filtering but still track usage metrics:
rtk proxy git log --oneline -20  # Full output, tracked in metrics
rtk proxy curl https://api.example.com  # Works with any command

Token Savings by Operation

Typical 30-minute Claude Code session:
OperationFrequencyStandardRTKSavings
ls / tree10×2,000400-80%
cat / read20×40,00012,000-70%
grep / rg16,0003,200-80%
git status10×3,000600-80%
git diff10,0002,500-75%
npm test25,0002,500-90%
pytest8,000800-90%
docker ps900180-80%
Total~118,000~23,900-80%

Performance Targets

RTK maintains strict performance constraints:
  • Startup time: <10ms (zero-overhead CLI experience)
  • Memory: <5MB resident
  • Binary size: <5MB stripped
  • Token savings: 60-90% across all commands

Next Steps

File Operations

Start with file operations (ls, read, grep, find)

Git Commands

Explore git command optimizations