AI 助手 -> 执行 shell 命令 -> 原始输出 -> 进入 AI 上下文AI 助手 -> RTK hook -> rtk 命令代理 -> 压缩输出 -> 进入 AI 上下文rtk gain 能显示 token savings dashboard = 安装的是正确的 Rust Token Killer
rtk gain 提示 not a rtk command = 安装错了,可能是 Rust Type Kit
rtk 命令不存在 = 还没有安装rtk gain 正常,不需要重复安装,直接进入初始化步骤。rtk 命令,把 ~/.local/bin 加入 PATH。set -gx PATH $HOME/.cargo/bin $PATHrtk-x86_64-pc-windows-msvc.ziprtk.exertk.exe 放到 PATH 目录中rtk --version不要双击 rtk.exertk --version 能显示版本号
rtk gain 能显示 token savings dashboardrtk: 'gain' is not a rtk command.github/hooks/rtk-rewrite.json
.github/copilot-instructions.md~/.copilot/hooks/rtk-rewrite.json
~/.copilot/copilot-instructions.md~/.config/opencode/plugins/rtk.tsgit status 改写为 rtk git status,说明 hook 生效。git status:压缩为紧凑状态git log:保留 hash、作者、标题git diff:减少上下文,去掉冗余 headergit show:类似 diff 压缩git stash list:每条 stash 一行展示rtk smart 会生成更短的代码摘要,适合让 AI 快速理解文件结构。discover 命令,用于分析 Claude Code 命令历史,找出哪些命令没有经过 RTK。~/.config/rtk/config.toml~/Library/Application Support/rtk/config.toml[tracking]
enabled = true
history_days = 90
database_path = "/custom/path/history.db"
[display]
colors = true
emoji = true
max_width = 120
[filters]
ignore_dirs = [".git", "node_modules", "target", "__pycache__", ".venv", "vendor"]
ignore_files = ["*.lock", "*.min.js", "*.min.css"]
[tee]
enabled = true
mode = "failures"
max_files = 20
[telemetry]
enabled = true
[hooks]
exclude_commands = [][hooks]
exclude_commands = ["git rebase", "git cherry-pick", "docker exec"][hooks]
exclude_commands = ["psql", "docker exec", "git rebase"]rtk xxx。FAILED: 2/15 tests
[full output: ~/.local/share/rtk/tee/1707753600_cargo_test.log][tee]
enabled = true
mode = "failures"
max_files = 20failures = 只保存失败命令
always = 总是保存
never = 不保存为了减少 token 消耗,执行 shell 命令时请优先使用 RTK。
常见命令请优先使用:
- rtk git status
- rtk git diff
- rtk git log
- rtk read
- rtk grep
- rtk find
- rtk cargo test
- rtk npm test
- rtk pnpm test
- rtk pytest
- rtk go test
- rtk docker ps
- rtk kubectl get pods
除非我明确要求完整原始输出,否则不要直接输出大量日志、目录树、测试结果或构建日志。
如果 RTK 返回了完整日志文件路径,先阅读摘要;只有摘要不足以定位问题时,再读取完整日志。rtk gain 提示不是 RTK 命令rtk: 'gain' is not a rtk command安装成了 Rust Type Kit,而不是 Rust Token KillerAI 仍然直接执行 cargo test,而不是 rtk cargo testrtk 命令找不到.bashrc 换成 .zshrc。CMD / PowerShell / Windows Terminalrtk --versionprogram not foundRust 1.70+