AI 节省Token,节约成本 - 守护你的Token

AI 节省Token,节约成本 - 守护你的Tokenlt p align center gt lt img src https avatars githubuserco com u v 4 alt RTK Rust Token Killer

大家好,我是讯享网,很高兴认识大家。这里提供最前沿的Ai技术和互联网信息。



https://avatars.githubusercontent.com/u/258253854?v=4" alt="RTK - Rust Token Killer" width="500">

High-performance CLI proxy that reduces LLM token consumption by 60-90%

https://github.com/rtk-ai/rtk/actions"> src="https://github.com/rtk-ai/rtk/workflows/Security%20Check/badge.svg" alt="CI"> https://github.com/rtk-ai/rtk/releases"> src="https://img.shields.io/github/v/release/rtk-ai/rtk" alt="Release"> https://opensource.org/licenses/MIT"> src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"> https://discord.gg/RySmvNF5kF"> src="https://img.shields.io/discord/1470188214710046894?label=Discord&logo=discord" alt="Discord"> https://formulae.brew.sh/formula/rtk"> src="https://img.shields.io/homebrew/v/rtk" alt="Homebrew">

https://www.rtk-ai.app">WebsiteInstall" target="_blank">https://download.csdn.net/download/liu/"#installation">Install • Troubleshooting" target="_blank">https://download.csdn.net/download/liu/"docs/TROUBLESHOOTING.md">Troubleshooting • Architecture" target="_blank">https://download.csdn.net/download/liu/"docs/contributing/ARCHITECTURE.md">Architecture • https://discord.gg/RySmvNF5kF">Discord

English" target="_blank">https://download.csdn.net/download/liu/"README.md">English • Francais" target="_blank">https://download.csdn.net/download/liu/"README_fr.md">Francais • 中文" target="_blank">https://download.csdn.net/download/liu/"README_zh.md">中文 • 日本語" target="_blank">https://download.csdn.net/download/liu/"README_ja.md">日本語 • 한국어" target="_blank">https://download.csdn.net/download/liu/"README_ko.md">한국어 • Espanol" target="_blank">https://download.csdn.net/download/liu/"README_es.md">Espanol


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.

Installation

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 >

Cargo

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

Pre-built Binaries

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

Verify Installation

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 gain fails, you have the wrong package. Use cargo install --git above instead.

Quick Start

# 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 --agent windsurf # Windsurf rtk init --agent cline # Cline / Roo Code # 2. Restart your AI tool, then test git status # Automatically rewritten to rtk git status 

The hook transparently rewrites Bash commands (e.g., git status -> rtk git status) before execution. Claude never sees the rewrite, it just gets compressed output.

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.

How It Works

 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:

  1. Smart Filtering - Removes noise (comments, whitespace, boilerplate)
  2. Grouping - Aggregates similar items (files by directory, errors by type)
  3. Truncation - Keeps relevant context, cuts redundancy
  4. Deduplication - Collapses repeated log lines with counts

Commands

Files

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 

Git

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" 

GitHub CLI

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 

Test Runners

rtk test cargo test # Show failures only (-90%) rtk err npm run build # Errors/warnings only rtk vitest run # 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%+) 

Build & Lint

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%+) 

Package Managers

rtk pnpm list # Compact dependency tree 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) 

AWS

”`bash rtk aws sts get-caller-identity # One-line identity rtk aws ec2 describe-instances # Compa

小讯
上一篇 2026-04-11 16:30
下一篇 2026-04-11 16:28

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/256446.html