📦 rtk-ai/rtk:将常见开发命令的 LLM Token 消耗降低 60-90% 的 CLI 代理
英文标题:📦 rtk-ai/rtk
rtk 是一个用 Rust 编写的高性能 CLI 代理,可在常见的开发命令上减少 60-90% 的 LLM token 消耗。它通过智能过滤、分组、截断和去重策略压缩输出,支持 git、测试、AWS、Docker 等 100 多种命令。借助钩子自动将 Bash 命令重写为优化版本,实现零开销 token 优化,显著降低开发者和 AI 编码助手的 API 成本。
25.5 KB
95.4 KB
中文
高性能 CLI 代理,将 LLM token 消耗降低 60-90%
英语 • 法语 • 中文 • 日语 • 韩语 • 西班牙语 • 葡萄牙语
rtk 在输出到达 LLM 上下文之前对命令输出进行过滤和压缩。单个 Rust 二进制文件,支持 100 多个命令,开销 <10ms。
Token 节省量(基于 30 分钟的 Claude Code 会话)
| 操作 | 频率 | 标准 | rtk | 节省比例 |
|---|---|---|---|---|
ls / tree |
10 次 | 2,000 | 400 | -80% |
cat / read |
20 次 | 40,000 | 12,000 | -70% |
grep / rg |
8 次 | 16,000 | 3,200 | -80% |
git status |
10 次 | 3,000 | 600 | -80% |
git diff |
5 次 | 10,000 | 2,500 | -75% |
git log |
5 次 | 2,500 | 500 | -80% |
git add/commit/push |
8 次 | 1,600 | 120 | -92% |
cargo test / npm test |
5 次 | 25,000 | 2,500 | -90% |
ruff check |
3 次 | 3,000 | 600 | -80% |
pytest |
4 次 | 8,000 | 800 | -90% |
go test |
3 次 | 6,000 | 600 | -90% |
docker ps |
3 次 | 900 | 180 | -80% |
| 总计 | ~118,000 | ~23,900 | -80% |
基于中型 TypeScript/Rust 项目的估计值。实际节省量因项目大小而异。
快速安装(Linux/macOS)
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
安装到
~/.local/bin。如果需要,添加到 PATH:echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # 或 ~/.zshrc
cargo install --git https://github.com/rtk-ai/rtk
从 releases 下载:
- macOS:
rtk-x86_64-apple-darwin.tar.gz/rtk-aarch64-apple-darwin.tar.gz - Linux:
rtk-x86_64-unknown-linux-musl.tar.gz/rtk-aarch64-unknown-linux-gnu.tar.gz - Windows:
rtk-x86_64-pc-windows-msvc.zip
Windows 用户:解压 zip 并将
rtk.exe放到 PATH 中的某个位置(例如C:\Users\<你>\.local\bin)。从 命令提示符、PowerShell 或 Windows Terminal 运行 RTK —— 不要双击.exe(会闪退)。完整的钩子系统在 Windows 上原生工作(以及在 WSL 中)。详情见下方 Windows 设置。
rtk --version # 应显示 "rtk 0.28.2" rtk gain # 应显示 token 节省统计信息
名称冲突警告:crates.io 上存在另一个名为 "rtk"(Rust Type Kit)的项目。如果
rtk gain失败,说明你安装了错误的包。请改用上面的cargo install --git方式。
1. 为你的 AI 工具安装
rtk init -g # Claude Code / Copilot(默认) rtk init -g --gemini # Gemini CLI rtk init -g --codex # Codex (OpenAI) rtk init -g --agent cursor # Cursor rtk init -g --agent windsurf # Windsurf rtk init --agent cline # Cline / Roo Code rtk init --agent kilocode # Kilo Code rtk init --agent antigravity # Google Antigravity rtk init -g --agent pi # Pi rtk init --agent hermes # Hermes
2. 重启你的 AI 工具,然后测试
git status # 自动重写为 rtk git status
基于钩子的代理在执行前将 Bash 命令(例如 git status -> rtk git status)重写。基于插件的代理(包括 Hermes)使用其插件 API 在执行前重写命令。代理接收紧凑的输出而无需显式调用 rtk。
重要提示: 钩子仅对 Bash 工具调用生效。Claude Code 内置工具如 Read、Grep 和 Glob 不会经过 Bash 钩子,因此它们不会被自动重写。若想在这些工作流中获得 RTK 的紧凑输出,请使用 shell 命令(cat/head/tail、rg/grep、find)或直接调用 rtk read、rtk grep 或 rtk find。
不使用 rtk: 使用 rtk:
Claude --git status--> shell --> git Claude --git status--> RTK --> git ^ | ^ | | | ~2,000 tokens (raw) | | ~200 tokens | filter | +-----------------------------------+ +------- (filtered) ---+----------+
四种策略按命令类型应用:
- 智能过滤 - 移除噪声(注释、空白、样板代码)
- 分组 - 聚合相似项(按目录分组文件,按类型分组错误)
- 截断 - 保留相关上下文,切除冗余
- 去重 - 将重复的日志行折叠并计数
常规命令
rtk ls . # Token 优化的目录树 rtk read file.rs # 智能文件读取 rtk read file.rs -l aggressive # 仅函数签名(去除函数体) rtk smart file.rs # 2 行启发式代码摘要 rtk find "*.rs" . # 紧凑的查找结果 rtk grep "pattern" . # 分组搜索结果 rtk diff file1 file2 # 浓缩差异(文件不同时退出码为 1)
Git 命令
rtk git status # 紧凑状态 rtk git log -n 10 # 单行提交记录 rtk git diff # 浓缩差异 rtk git add # -> "ok" rtk git commit -m "msg" # -> "ok abc1234" rtk git push # -> "ok main" rtk git pull # -> "ok 3 files +10 -2"
GitHub CLI
rtk gh pr list # 紧凑的 Pull Request 列表 rtk gh pr view 42 # PR 详情 + 检查信息 rtk gh issue list # 紧凑的 Issue 列表 rtk gh run list # 工作流运行状态
测试命令
rtk jest # Jest 紧凑输出(仅失败项) rtk vitest # Vitest 紧凑输出(仅失败项) rtk playwright test # E2E 结果(仅失败项) rtk pytest # Python 测试 (-90%) rtk go test # Go 测试 (NDJSON, -90%) rtk cargo test # Cargo 测试 (-90%) rtk rake test # Ruby minitest (-90%) rtk rspec # RSpec 测试 (JSON, -60%+) rtk err # 仅过滤任何命令的错误输出 rtk test # 通用测试包装器 - 仅失败项 (-90%)
Lint / 构建命令
rtk lint # ESLint 按规则/文件分组 rtk lint biome # 支持其他 linter rtk tsc # TypeScript 错误按文件分组 rtk next build # Next.js 构建紧凑输出 rtk prettier --check . # 需要格式化的文件 rtk cargo build # Cargo 构建 (-80%) rtk cargo clippy # Cargo clippy (-80%) rtk ruff check # Python linting (JSON, -80%) rtk golangci-lint run # Go linting (JSON, -85%) rtk rubocop # Ruby linting (JSON, -60%+)
包管理器命令
rtk pnpm list # 紧凑的依赖树 rtk uv run pytest # 保留 uv 环境,仅错误项 rtk pip list # Python 包(自动检测 uv) rtk pip outdated # 过期的包 rtk bundle install # Ruby gems(去除 "Using" 行) rtk prisma generate # Schema 生成(无 ASCII 艺术)
AWS 命令
rtk aws sts get-caller-identity # 单行身份信息 rtk aws ec2 describe-instances # 紧凑的实例列表 rtk aws lambda list-functions # 名称/运行时/内存(去除密钥) rtk aws logs get-log-events # 仅带时间戳的消息 rtk aws cloudformation describe-stack-events # 优先显示失败事件 rtk aws dynamodb scan # 解包类型注释 rtk aws iam list-roles # 去除策略文档 rtk aws s3 ls # 截断并支持 tee 恢复
容器与编排命令
rtk docker ps # 紧凑的容器列表 rtk docker images # 紧凑的镜像列表 rtk docker logs # 去重的日志 rtk docker compose ps # Compose 服务列表 rtk kubectl pods # 紧凑的 Pod 列表 rtk kubectl logs # 去重的日志 rtk kubectl services # 紧凑的服务列表 rtk oc get pods # OpenShift Pod 摘要 rtk oc get services # OpenShift 服务列表 rtk oc logs # 去重的日志
基础设施即代码命令
rtk pulumi preview # 去除摘要头/URL/持续时间噪音 rtk pulumi up # 紧凑的应用输出 rtk pulumi destroy # 紧凑的销毁输出 rtk pulumi refresh # 偏离摘要 rtk pulumi stack # 堆栈元数据(去除所有者和时间戳)
通用工具命令
rtk json config.json # 不含值的结构 rtk deps # 依赖摘要 rtk env -f AWS # 过滤后的环境变量 rtk log app.log # 去重的日志 rtk curl # 截断并保存完整输出 rtk wget # 下载,去除进度条 rtk summary # 启发式摘要 rtk proxy # 原始透传并跟踪
统计数据
rtk gain # 摘要统计 rtk gain --graph # ASCII 图表(最近 30 天) rtk gain --history # 最近的命令历史 rtk gain --daily # 每日详细分析 rtk gain --all --format json # 用于仪表板的 JSON 导出
rtk discover # 查找错过的节省机会 rtk discover --all --since 7 # 所有项目,最近 7 天
rtk session # 显示近期会话中 RTK 的采用情况
选项
-u, --ultra-compact # ASCII 图标、内联格式(额外 token 节省) -v, --verbose # 增加详细程度 (-v, -vv, -vvv)
目录列表对比:
ls -la (45 行, ~800 tokens) # rtk ls (12 行, ~150 tokens)
drwxr-xr-x 15 user staff 480 ... my-project/ -rw-r--r-- 1 user staff 1234 ... +-- src/ (8 files) ... | +-- main.rs +-- Cargo.toml
Git 操作对比:
git push (15 行, ~200 tokens) # rtk git push (1 行, ~10 tokens)
Enumerating objects: 5, done. ok main Counting objects: 100% (5/5), done. Delta compression using up to 8 threads ...
测试输出对比:
cargo test (失败时 200+ 行) # rtk test cargo test (~20 行)
running 15 tests FAILED: 2/15 tests test utils::test_parse ... ok test_edge_case: assertion failed test utils::test_format ... ok test_overflow: panic at utils.rs:18 ...
钩子是使用 rtk 最高效的方式。它透明地拦截 Bash 命令并在执行前将其重写为 rtk 等价命令。
结果:在所有对话和子代理中实现 100% rtk 采用率,零 token 开销。
范围说明: 仅适用于 Bash 工具调用。Claude Code 内置工具如 Read、Grep 和 Glob 会绕过钩子,因此若想对这些工作流应用 RTK 过滤,请使用 shell 命令或显式 rtk 命令。
rtk init -g # 安装钩子 + RTK.md(推荐) rtk init -g --opencode # OpenCode 插件(而非 Claude Code) rtk init -g --auto-patch # 非交互模式 (CI/CD) rtk init -g --hook-only # 仅钩子,不含 RTK.md rtk init --show # 验证安装
安装后,重启 Claude Code。
RTK 在原生 Windows 上完全可用。从 v0.37.2 起,自动重写钩子作为 原生二进制命令(rtk hook claude)运行 —— 无需 Unix shell、bash 或 jq —— 因此命令可以在命令提示符、PowerShell 和 Windows Terminal 上透明重写,就像在 Linux 和 macOS 上一样。
1. 从 releases 下载并解压 rtk-x86_64-pc-windows-msvc.zip
2. 将 rtk.exe 添加到你的 PATH(例如 C:\Users<你>.local\bin)
English / 原文
High-performance CLI proxy that reduces LLM token consumption by 60-90%
Website • Install • Troubleshooting • Architecture • Discord
English • Francais • 中文 • 日本語 • 한국어 • Espanol • Português
rtk filters and compresses command outputs before they reach your LLM context. Single Rust binary, 100+ supported commands, <10ms overhead.
Token Savings (30-min Claude Code Session)
| 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.
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
cargo install --git https://github.com/rtk-ai/rtk
Download from releases:
- macOS:
rtk-x86_64-apple-darwin.tar.gz/rtk-aarch64-apple-darwin.tar.gz - Linux:
rtk-x86_64-unknown-linux-musl.tar.gz/rtk-aarch64-unknown-linux-gnu.tar.gz - Windows:
rtk-x86_64-pc-windows-msvc.zip
Windows users : Extract the zip and place
rtk.exesomewhere in your PATH (e.g.C:\Users\<you>\.local\bin). Run RTK from Command Prompt , PowerShell , or Windows Terminal — do not double-click the.exe(it will flash and close). The full hook system works natively on Windows (and in WSL). See Windows setup below for details.
rtk --version # Should show "rtk 0.28.2"
rtk gain # Should show token savings stats
Name collision warning : Another project named "rtk" (Rust Type Kit) exists on crates.io. If
rtk gainfails, you have the wrong package. Usecargo install --gitabove instead.
# 1. Install for your AI tool
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 -g --agent windsurf # Windsurf
rtk init --agent cline # Cline / Roo Code
rtk init --agent kilocode # Kilo Code
rtk init --agent antigravity # Google Antigravity
rtk init -g --agent pi # Pi
rtk init --agent hermes # Hermes
# 2. Restart your AI tool, then test
git status # Automatically rewritten to rtk git status
Hook-based agents rewrite Bash commands (e.g., git status -> rtk git status) before execution. Plugin-based agents, including Hermes, use their plugin API to rewrite commands before execution. The agent receives compact output without needing to call rtk explicitly.
Important: the hook only runs on Bash tool calls. Claude Code built-in tools like Read, Grep, and Glob do not pass through the Bash hook, so they are not auto-rewritten. To get RTK's compact output for those workflows, use shell commands (cat/head/tail, rg/grep, find) or call rtk read, rtk grep, or rtk find directly.
Without rtk: With rtk:
Claude --git status--> shell --> git Claude --git status--> RTK --> git
^ | ^ | |
| ~2,000 tokens (raw) | | ~200 tokens | filter |
+-----------------------------------+ +------- (filtered) ---+----------+
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
rtk ls . # Token-optimized directory tree
rtk read file.rs # Smart file reading
rtk read file.rs -l aggressive # Signatures only (strips bodies)
rtk smart file.rs # 2-line heuristic code summary
rtk find "*.rs" . # Compact find results
rtk grep "pattern" . # Grouped search results
rtk diff file1 file2 # Condensed diff (exit 1 if files differ)
rtk git status # Compact status
rtk git log -n 10 # One-line commits
rtk git diff # Condensed diff
rtk git add # -> "ok"
rtk git commit -m "msg" # -> "ok abc1234"
rtk git push # -> "ok main"
rtk git pull # -> "ok 3 files +10 -2"
rtk gh pr list # Compact PR listing
rtk gh pr view 42 # PR details + checks
rtk gh issue list # Compact issue listing
rtk gh run list # Workflow run status
rtk jest # Jest compact (failures only)
rtk vitest # Vitest compact (failures only)
rtk playwright test # E2E results (failures only)
rtk pytest # Python tests (-90%)
rtk go test # Go tests (NDJSON, -90%)
rtk cargo test # Cargo tests (-90%)
rtk rake test # Ruby minitest (-90%)
rtk rspec # RSpec tests (JSON, -60%+)
rtk err <cmd> # Filter errors only from any command
rtk test <cmd> # Generic test wrapper - failures only (-90%)
rtk lint # ESLint grouped by rule/file
rtk lint biome # Supports other linters
rtk tsc # TypeScript errors grouped by file
rtk next build # Next.js build compact
rtk prettier --check . # Files needing formatting
rtk cargo build # Cargo build (-80%)
rtk cargo clippy # Cargo clippy (-80%)
rtk ruff check # Python linting (JSON, -80%)
rtk golangci-lint run # Go linting (JSON, -85%)
rtk rubocop # Ruby linting (JSON, -60%+)
rtk pnpm list # Compact dependency tree
rtk uv run pytest # Preserve uv env, errors only
rtk pip list # Python packages (auto-detect uv)
rtk pip outdated # Outdated packages
rtk bundle install # Ruby gems (strip Using lines)
rtk prisma generate # Schema generation (no ASCII art)
rtk aws sts get-caller-identity # One-line identity
rtk aws ec2 describe-instances # Compact instance list
rtk aws lambda list-functions # Name/runtime/memory (strips secrets)
rtk aws logs get-log-events # Timestamped messages only
rtk aws cloudformation describe-stack-events # Failures first
rtk aws dynamodb scan # Unwraps type annotations
rtk aws iam list-roles # Strips policy documents
rtk aws s3 ls # Truncated with tee recovery
rtk docker ps # Compact container list
rtk docker images # Compact image list
rtk docker logs <container> # Deduplicated logs
rtk docker compose ps # Compose services
rtk kubectl pods # Compact pod list
rtk kubectl logs <pod> # Deduplicated logs
rtk kubectl services # Compact service list
rtk oc get pods # OpenShift pod summary
rtk oc get services # OpenShift service list
rtk oc logs <pod> # Deduplicated logs
rtk pulumi preview # Strip header/URL/duration noise
rtk pulumi up # Compact apply output
rtk pulumi destroy # Compact destroy output
rtk pulumi refresh # Drift summary
rtk pulumi stack # Stack metadata (strips owner/timestamps)
rtk json config.json # Structure without values
rtk deps # Dependencies summary
rtk env -f AWS # Filtered env vars
rtk log app.log # Deduplicated logs
rtk curl <url> # Truncate + save full output
rtk wget <url> # Download, strip progress bars
rtk summary <long command> # Heuristic summary
rtk proxy <command> # Raw passthrough + tracking
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
-u, --ultra-compact # ASCII icons, inline format (extra token savings)
-v, --verbose # Increase verbosity (-v, -vv, -vvv)
Directory listing:
# ls -la (45 lines, ~800 tokens) # rtk ls (12 lines, ~150 tokens)
drwxr-xr-x 15 user staff 480 ... my-project/
-rw-r--r-- 1 user staff 1234 ... +-- src/ (8 files)
... | +-- main.rs
+-- Cargo.toml
Git operations:
# git push (15 lines, ~200 tokens) # rtk git push (1 line, ~10 tokens)
Enumerating objects: 5, done. ok main
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
...
Test output:
# cargo test (200+ lines on failure) # rtk test cargo test (~20 lines)
running 15 tests FAILED: 2/15 tests
test utils::test_parse ... ok test_edge_case: assertion failed
test utils::test_format ... ok test_overflow: panic at utils.rs:18
...
The most effective way to use rtk. The hook transparently intercepts Bash commands and rewrites them to rtk equivalents before execution.
Result : 100% rtk adoption across all conversations and subagents, zero token overhead.
Scope note: this only applies to Bash tool calls. Claude Code built-in tools such as Read, Grep, and Glob bypass the hook, so use shell commands or explicit rtk commands when you want RTK filtering there.
rtk init -g # Install hook + RTK.md (recommended)
rtk init -g --opencode # OpenCode plugin (instead of Claude Code)
rtk init -g --auto-patch # Non-interactive (CI/CD)
rtk init -g --hook-only # Hook only, no RTK.md
rtk init --show # Verify installation
After install, restart Claude Code.
RTK works fully on native Windows. Since v0.37.2 the auto-rewrite hook runs as a native binary command (rtk hook claude) — no Unix shell, bash, or jq required — so commands are rewritten transparently on Command Prompt, PowerShell, and Windows Terminal, just like on Linux and macOS.
# 1. Download and extract rtk-x86_64-pc-windows-msvc.zip from releases
# 2. Add rtk.exe to your PATH (e.g. C:\Users\<you>\.local\bin)
# 3. Initialize — installs the native binary hook
rtk init -g
Upgrading from an older install? If you set RTK up before v0.37.2 you may still have the legacy rtk-rewrite.sh shell hook (which does need a Unix shell). Re-run rtk init -g to migrate to the native binary hook.
Prerequisites : some filters shell out to ripgrep (rg). Install it and keep it on your PATH (e.g. winget install BurntSushi.ripgrep.MSVC) to avoid Binary 'rg' not found on PATH warnings.
Important : Do not double-click rtk.exe — it is a CLI tool that prints usage and exits immediately. Always run it from a terminal (Command Prompt, PowerShell, or Windows Terminal).
WSL also works and behaves exactly like Linux:
# Inside WSL
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
rtk init -g
| Feature | Native Windows | WSL |
|---|---|---|
| Filters (cargo, git, etc.) | Full | Full |
| Auto-rewrite hook | Yes (native binary) | Yes |
rtk init -g |
Hook mode | Hook mode |
rtk gain / analytics |
Full | Full |
RTK supports 14 AI coding tools. Each integration rewrites shell commands to rtk equivalents for 60-90% token savings where the agent supports command interception.
| Tool | Install | Method |
|---|---|---|
| Claude Code | rtk init -g |
PreToolUse hook (native binary) |
| GitHub Copilot (VS Code) | rtk init -g --copilot |
PreToolUse hook — transparent rewrite |
| GitHub Copilot CLI | rtk init -g --copilot |
PreToolUse deny-with-suggestion (CLI limitation) |
| Cursor | rtk init -g --agent cursor |
preToolUse hook (hooks.json) |
| Gemini CLI | rtk init -g --gemini |
BeforeTool hook |
| Codex | rtk init -g --codex |
AGENTS.md + RTK.md instructions |
| Windsurf | rtk init -g --agent windsurf |
.windsurfrules (project-scoped) |
| Cline / Roo Code | rtk init --agent cline |
.clinerules (project-scoped) |
| OpenCode | rtk init -g --opencode |
Plugin TS (tool.execute.before) |
| OpenClaw | openclaw plugins install ./openclaw |
Plugin TS (before_tool_call) |
| Pi | rtk init -g --agent pi (global) |
TypeScript extension (tool_call) |
| Hermes | rtk init --agent hermes |
Python plugin adapter (terminal command mutation via rtk rewrite) |
| Mistral Vibe | Planned (#800) | Blocked on upstream |
| Kilo Code | rtk init --agent kilocode |
.kilocode/rules/rtk-rules.md (project-scoped) |
| Google Antigravity | rtk init --agent antigravity |
.agents/rules/antigravity-rtk-rules.md (project-scoped) |
For per-agent setup details, override controls, and graceful degradation, see the Supported Agents guide. The Hermes plugin source and tests live in hooks/hermes/; installed Hermes runtime files still live under ~/.hermes/plugins/rtk-rewrite/.
~/.config/rtk/config.toml (macOS: ~/Library/Application Support/rtk/config.toml):
[hooks]
exclude_commands = ["curl", "playwright"] # skip rewrite for these
[tee]
enabled = true # save raw output on failure (default: true)
mode = "failures" # "failures", "always", or "never"
When a command fails, RTK saves the full unfiltered output so the LLM can read it without re-executing:
FAILED: 2/15 tests
[full output: ~/.local/share/rtk/tee/1707753600_cargo_test.log]
For the full config reference (all sections, env vars, per-project filters), see the Configuration guide.
rtk init -g --uninstall # Remove hook, RTK.md, settings.json entry
cargo uninstall rtk # Remove binary
brew uninstall rtk # If installed via Homebrew
RTK can collect anonymous, aggregate usage metrics once per day. Telemetry is disabled by default and requires explicit opt-in consent (GDPR Art. 6, 7) during rtk init or via rtk telemetry enable. This data helps us build a better product: identifying which commands need filters, which filters need improvement, and how much value RTK delivers. For the full list of fields, data handling, and contributor guidelines, see docs/TELEMETRY.md.
What is collected and why:
| Category | Data | Why |
|---|---|---|
| Identity | Salted device hash (SHA-256, not reversible) | Count unique installations without tracking individuals |
| Environment | RTK version, OS, architecture, install method | Know which platforms to support and test |
| Usage volume | Command count (24h), total commands, tokens saved (24h/30d/total) | Measure adoption and value delivered |
| Quality | Top 5 passthrough commands (0% savings), parse failure count, commands with <30% savings | Identify missing filters and weak ones to improve |
| Ecosystem | Command category distribution (e.g. git 45%, cargo 20%, js 15%) | Prioritize filter development for popular ecosystems |
| Retention | Days since first use, active days in last 30 | Understand engagement and detect churn |
| Adoption | AI agent hook type (claude/gemini/codex), custom TOML filter count | Track integration coverage and DSL adoption |
| Configuration | Whether config.toml exists, number of excluded commands, project count | Understand user maturity and customization patterns |
| Features | Usage counts for meta-commands (gain, discover, proxy, verify) | Know which RTK features are valued vs unused |
| Economics | Estimated USD savings (based on API token pricing) | Quantify the value RTK provides to users |
All data is aggregate counts or anonymized command names (first 3 words, no arguments). Top commands report only tool names (e.g. "git", "cargo"), never full command lines.
What is NOT collected: source code, file paths, command arguments, secrets, environment variables, personal data, or repository contents.
Manage telemetry:
rtk telemetry status # Check current consent state
rtk telemetry enable # Give consent (interactive prompt)
rtk telemetry disable # Withdraw consent — stops all collection immediately
rtk telemetry forget # Withdraw consent + delete all local data + request server-side erasure
Override via environment:
export RTK_TELEMETRY_DISABLED=1 # Blocks telemetry regardless of consent
Contributions welcome! Please open an issue or PR on GitHub.
Join the community on Discord.
Apache License 2.0 - see LICENSE for details.
See DISCLAIMER.md.