CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

★ 86,046⑂ 5,514👁 216⑃ 2,927● 1,977▤ 475◈ 82
RustApache-2.0Created 2026-01-22www.rtk-ai.app
86,046
stars
+76+723
5,514
forks
216
watchers
2,927
prs
1,977
issues
475
releases
82
discussions

README

高性能 CLI 代理,为你的智能体削减多达 90% 的 bash 输出



  
  
  
  
  



  官网 •
  安装 •
  故障排除 •
  架构 •
  Discord



  English •
  Francais •
  中文 •
  日本語 •
  한국어 •
  Espanol


---

rtk 在命令输出到达 LLM 上下文之前进行过滤和压缩。单一 Rust 二进制文件,零依赖, 完整说明:RTK 的节省是如何计算的

 安装

 Homebrew(推荐)

bash
brew install rtk


 winget(Windows)

Windows 上最简单的安装方式 — 一条命令,无需配置 PATH:

powershell
winget install rtk-ai.rtk


 快速安装(Linux/macOS)

bash
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh


 Cargo

bash
cargo install --git https://github.com/rtk-ai/rtk rtk


 Apache-2.0 版本(仅开源,允许商业使用)

同一个 rtk 二进制文件,构建时不包含 BUSL-1.1 压缩引擎:钩子重写系统和所有命令过滤器,仅遵循 Apache-2.0。

bash
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | RTK_EDITION=oss sh
brew install rtk-ai/tap/rtk-oss
cargo install --git https://github.com/rtk-ai/rtk rtk --no-default-features


 验证

bash
rtk --version    应显示 "rtk 0.27.x"
rtk gain         应显示 token 节省统计


 快速开始

bash
 1. 为对应的 AI 工具安装 hook
rtk init --global                Claude Code(默认)
rtk init --agent trae            Trae(项目级)
rtk init --global --agent trae   Trae(全局)

 2. 重启相应的 AI 工具,然后测试
git status   自动重写为 rtk git status


 工作原理


  没有 rtk:                                      使用 rtk:

  Claude  --git status--  shell  --  git         Claude  --git status--  RTK  --  git
    ^                                   |            ^                      |          |
    |        ~2,000 tokens(原始)       |            |   ~200 tokens        | 过滤     |
    +-----------------------------------+            +------- (已过滤)-----+----------+


四种策略:

1. 智能过滤 - 去除噪音(注释、空白、样板代码)
2. 分组 - 聚合相似项(按目录分文件,按类型分错误)
3. 截断 - 保留相关上下文,删除冗余
4. 去重 - 合并重复日志行并计数

 命令

 下列百分比是 bash 输出字节数的削减比例,由 RTK 的 字节数 / 4 估算器测得。参见节省是如何计算的。

 文件
bash
rtk ls .                         优化的目录树
rtk read file.rs                 智能文件读取
rtk find ".rs" .                紧凑的查找结果
rtk grep "pattern" .             按文件分组的搜索结果


 Git
bash
rtk git status                   紧凑状态
rtk git log -n 10                单行提交
rtk git diff                     精简 diff
rtk git push                     - "ok main"


 测试
bash
rtk jest                         Jest 紧凑输出
rtk vitest                       Vitest 紧凑输出
rtk pytest                       Python 测试(-90%)
rtk go test                      Go 测试(-90%)
rtk test  [args...]         仅显示失败(-90%),直接执行 argv


 构建 & 检查
bash
rtk lint                         ESLint 按规则分组
rtk tsc                          TypeScript 错误分组
rtk cargo build                  Cargo 构建(-80%)
rtk ruff check                   Python lint(-80%)


 容器
bash
rtk docker ps                    紧凑容器列表
rtk docker logs       去重日志
rtk kubectl pods                 紧凑 Pod 列表


 分析
bash
rtk gain                         节省统计
rtk gain --graph                 ASCII 图表(30 天)
rtk discover                     发现遗漏的节省机会


 文档

- TROUBLESHOOTING.md - 解决常见问题
- INSTALL.md - 详细安装指南
- ARCHITECTURE.md - 技术架构

 贡献

欢迎贡献!请在 GitHub 上提交 issue 或 PR。

加入 Discord 社区。

 

Top issues

Discussions

Latest release

v1.2.0 v1.2.0 2026-11-08
1.2.0 (2026-11-08)


 Features

 git: fold ls-tree path listings by directory (1816)


 Bug Fixes

 analytics: sum per-project ccusage rows in monthly economics (4771)
 cargo: keep nextest timeouts and retried failures (4697)
 cicd: build the deb, rpm and aarch64 Linux binaries as static musl (5017)
 dotnet: preserve discovery and classic TRX reports (4628)
 gain: distinguish filtered timings from passthrough lifetimes (4677)
 git: announce the cap on the filtered git log path (4152)
 hermes: close the rewrite's stdin and make its timeout configurable (3833)
 hook: honour opt-outs inside a quo

Snapshot: 2026-11-10T09:35:25Z · Data license Apache-2.0 · JSON