OpenSource-Hub
R

rtk

SHA-256
51.2k stars·开发工具·已提供 SHA-256 校验码,下载后可自行核对文件完整性

CLI 代理,可将常见开发命令的 LLM token 消耗降低 60-90%。单 Rust 二进制文件,零依赖。

智能下载

下载 Download 版本

v0.40.0 · 3.9 MB

AI 开发工具的 token 省钱利器,自动压缩命令输出,省 80% token。

核心功能

  • 智能过滤命令输出,去除注释、空白、样板代码
  • 按目录/类型分组聚合相似结果
  • 截断冗余信息,保留关键上下文
  • 去重重复日志行并统计次数
  • 自动集成到 Claude Code、Copilot、Gemini CLI 等 AI 工具

避坑指南

  • rtk 只对通过 shell 执行的命令生效,AI 工具的内置工具(如 Claude Code 的 Read、Grep、Glob)不会自动经过钩子,需手动使用 rtk read、rtk grep 等命令。另外,crates.io 上有同名项目 'Rust Type Kit',如果安装后运行 rtk gain 报错,说明装错了包,需改用 git 安装方式。Windows 用户建议使用 WSL 以获得完整的钩子系统支持。

适用场景

  • 使用 AI 编码助手时大幅降低 token 消耗和费用
  • 在 CI/CD 管道中优化测试日志输出,减少 LLM 处理的噪音

详细介绍

rtk 是一个高性能的 CLI 代理,位于 AI 开发工具(如 Claude Code、Copilot、Gemini CLI 等)和 shell 命令之间,在输出到达 LLM 上下文之前进行过滤和压缩,通常可减少 60-90% 的 token 消耗。它采用 Rust 单二进制文件构建,零依赖,支持超过 100 个常用命令,包括 git、测试运行器、代码检查工具、包管理器、Docker、kubectl 和 AWS CLI。通过智能过滤、分组、截断和去重四种策略,在不到 10 毫秒的开销内透明融入你的工作流。不同于需要手动调整提示或复杂管道的传统方法,rtk 通过 shell 钩子或直接命令包装自动生效,无需任何配置,即可在各类项目中实现一致的 token 节约。与 LLM 上下文压缩工具或临时的 grep/sed 脚本相比,rtk 专为开发者命令行场景设计,是同类工具中唯一聚焦于 CLI 输出优化的轻量级解决方案。

标签

CLI proxytoken optimizationLLM cost reductionRustdeveloper toolsAI assistant enhancement

快速上手

1

下载安装包

点击上方按钮下载对应系统的安装包

2

安装软件

根据你的发行版安装对应的包(dpkg / rpm / AppImage)

3

使用 Homebrew 安装:brew install rtk

4

或运行快速安装脚本:curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh

5

验证安装:rtk --version 应显示版本号

安装指引
  1. 使用 Homebrew 安装:brew install rtk
  2. 或运行快速安装脚本:curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
  3. 验证安装:rtk --version 应显示版本号

最新更新

## [0.40.0](https://github.com/rtk-ai/rtk/compare/v0.39.0...v0.40.0) (2026-05-13)

### Features

* **gradlew:** Gradle support for Android/Kotlin developers ([833026b](https://github.com/rtk-ai/rtk/commit/833026b893822be4e1c64d22d640e979cd9eff51))

* **hermes:** add Hermes Agent support via rtk init --agent hermes ([55f998d](https://github.com/rtk-ai/rtk/commit/55f998d08cd80ece970fe5e61eaae3533512288b))

* **hooks:** add transparent_prefixes config for wrapper commands ([998f1ee](https://github.com/rtk-ai/rtk/commit/998f1ee0a3cf8d73ea0d6d87c121117f351e4992))

* **init:** add --dry-run flag to preview changes without writing ([172ec54](https://github.com/rtk-ai/rtk/commit/172ec54580ddb0d737ef3e3be8a075eaeeb0a01b))

### Bug Fixes

* **cicd:** pr-target clean msg + git app token ([e4c3ed7](https://github.com/rtk-ai/rtk/commit/e4c3ed7d889ede726df7986ade94a4714c7c7f99))

* **cicd:** set release-please target-branch to master [skip ci] ([0c6a838](https://github.com/rtk-ai/rtk/commit/0c6a838594e87346b67bd13c092b8a46a783af87))

* correct ARCHITECTURE.md path in README links ([2a41e03](https://github.com/rtk-ai/rtk/commit/2a41e039903049543aa6c69482747eddcce9ee5a))

* don't inject -json for go test -bench runs ([380a7c9](https://github.com/rtk-ai/rtk/commit/380a7c9f1189fafe7d0b878b3821a720ac6ab4b2))

* **dotnet:** format build/test/restore output sections ([106305b](https://github.com/rtk-ai/rtk/commit/106305b1978ad5fdd47139d3543cfa53a5e8172e))

* **dotnet:** format warnings section in build/test/restore outputs ([c5245d7](https://github.com/rtk-ai/rtk/commit/c5245d74fafc066072615d804c27d5c2892db7d9))

* **dotnet:** move build/test/restore status line to the bottom ([ed161b0](https://github.com/rtk-ai/rtk/commit/ed161b0a33a2a784bb933792501aa2747b0df3c3)), closes [#1574](https://github.com/rtk-ai/rtk/issues/1574)

* **gradlew:** use resolved_command for system gradle fallback ([9e3a5ae](https://github.com/rtk-ai/rtk/commit/9e3a5ae68d4adc3d7fc374f36235cb5164e6efc8))

* **hooks:** address transparent prefix review ([fdf0ed0](https://github.com/rtk-ai/rtk/commit/fdf0ed0b597f1ebdc96a2793df2725a1e62bc65c))

* **hooks:** compose env and transparent prefixes ([b234bc6](https://github.com/rtk-ai/rtk/commit/b234bc6db1ab301334412409a4cfd67fe99c58f0))

* **hooks:** make Cursor preToolUse rewrites work and stay visible ([f00977a](https://github.com/rtk-ai/rtk/commit/f00977aa338ce6bafe8df69c271679951310b045))

* minor code cleanup, avoid duplicating logic ([20cac8a](https://github.com/rtk-ai/rtk/commit/20cac8a4e7c2b7e0e2675dbcab4fbd0fb1ad79ed))

* new rewite_command test call after rebase ([5cfb8e1](https://github.com/rtk-ai/rtk/commit/5cfb8e1d2bdf85d60633868cb420aba9a7b923f4))

文件完整性

已提供 SHA-256 校验码,下载后可自行核对文件完整性

该校验码提取自 GitHub 官方 Release 页面

SHA256 校验码

a75d210a445874106bc16da2b4efba01d36d297afa33ec134728f2d5f42ef5af

该校验码提取自 GitHub Release 页面,下载后请自行核对文件完整性

本平台所有 SHA-256 校验码均提取自项目在 GitHub 官方 Release 页面发布的文件,未做任何修改。你可以通过 GitHub Releases 页面自行验证。

运维指引

卸载说明

若通过 Homebrew 安装,运行 brew uninstall rtk;若通过脚本安装,删除 ~/.local/bin/rtk 文件,并从 shell 配置文件中移除相关环境变量。对于通过 Cargo 安装的,运行 cargo uninstall rtk。最后检查 AI 工具的钩子配置文件(如 .bashrc 或 .zshrc)中移除 rtk 初始化的行。

无额外依赖

下载后即可直接使用,无需安装其他运行环境

项目信息
开源协议Apache-2.0
最后更新2026-05-20T06:29:34Z
GitHub 仓库官方网站

相似推荐