rtk-ai / rtk
rtk-ai / rtk
High-performance CLI proxy that reduces LLM token consumption by 60-90% 高性能 CLI 代理,可减少 60-90% 的 LLM Token 消耗。
Token Savings (30-min Claude Code Session)
Token 节省情况(30 分钟 Claude Code 会话)
| Operation | Frequency | Standard | rtk | Savings |
|---|---|---|---|---|
| ls / tree | 10x | 2,000 | 400 | -80% |
| cat / read | 20x | 40,000 | 12,000 | -70% |
| grep / rg | 8x | 16,000 | 3,200 | -80% |
| git status | 10x | 3,000 | 600 | -80% |
| git diff | 5x | 10,000 | 2,500 | -75% |
| git log | 5x | 2,500 | 500 | -80% |
| git add/commit/push | 8x | 1,600 | 120 | -92% |
| cargo test / npm test | 5x | 25,000 | 2,500 | -90% |
| ruff check | 3x | 3,000 | 600 | -80% |
| pytest | 4x | 8,000 | 800 | -90% |
| go test | 3x | 6,000 | 600 | -90% |
| docker ps | 3x | 900 | 180 | -80% |
| Total | ~118,000 | ~23,900 | -80% |
Estimates based on medium-sized TypeScript/Rust projects. Actual savings vary by project size. 以上估算基于中型 TypeScript/Rust 项目。实际节省比例因项目规模而异。
Installation / 安装
Homebrew (recommended)
brew install rtk
Quick Install (Linux/macOS)
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
Installs to ~/.local/bin. Add to PATH if needed: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc (or ~/.zshrc)
安装至 ~/.local/bin。如有需要,请将其添加到 PATH:echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc (或 ~/.zshrc)
Cargo
cargo install --git https://github.com/rtk-ai/rtk
Quick Start / 快速开始
1. Install for your AI tool / 为你的 AI 工具安装
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 --agent windsurf # Windsurf
rtk init --agent cline # Cline / Roo Code
2. Restart your AI tool, then test / 重启 AI 工具并测试
git status # Automatically rewritten to rtk git status
Hook-based agents rewrite Bash commands before execution. Plugin-based agents use their plugin API to rewrite commands. The agent receives compact output without needing to call rtk explicitly. 基于 Hook 的 Agent 会在执行前重写 Bash 命令。基于插件的 Agent 则通过插件 API 重写命令。Agent 无需显式调用 rtk 即可接收精简后的输出。
How It Works / 工作原理
Without rtk: Claude —git status—> shell —> git (~2,000 tokens)
With rtk: Claude —git status—> RTK —> git (~200 tokens)
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. 去重: 合并重复的日志行并显示计数。
Commands / 命令概览
- Files:
rtk ls .,rtk read file.rs,rtk smart file.rs,rtk find "*.rs" .,rtk grep "pattern" . - Git:
rtk git status,rtk git log,rtk git diff,rtk git add/commit/push - GitHub CLI:
rtk gh pr list,rtk gh issue list,rtk gh run list - Test Runners:
rtk jest,rtk vitest,rtk pytest,rtk go test,rtk cargo test - Build & Lint:
rtk lint,rtk tsc,rtk cargo build,rtk ruff check - Package Managers:
rtk pnpm list,rtk pip list,rtk bundle install - AWS:
rtk aws sts get-caller-identity,rtk aws ec2 describe-instances,rtk aws s3 ls