กลับไปหน้า Tools

GetNotes Tools

rtk-ai/rtk

Tool นี้คืออะไร

`rtk` เป็นพร็อกซี CLI ประสิทธิภาพสูงที่ช่วยลดการใช้โทเค็นของ LLM ลง 60-90% โดยการกรองและบีบอัดผลลัพธ์คำสั่ง เหมาะสำหรับนักพัฒนาที่ใช้เครื่องมือ AI เพื่อประหยัดค่าใช้จ่ายและเพิ่มความเร็วในการโต้ตอบกับ LLM

ข้อมูลโปรเจกต์

ดาว

73.7K

Forks

4.6K

License

Apache-2.0

อัปเดต GitHub ล่าสุด

28 ก.ค. 2569

เพิ่มใน GetNotes

14 ก.ค. 2569

Repository

rtk-ai/rtk

รูปแบบ

CLI / Terminal

เหมาะกับงาน

AI และ AgentsCoding AgentsDeveloper Toolsเพิ่ม Productivity

เหมาะกับอาชีพ

Ecosystem

Rust

แปลและเรียบเรียงโดย AI

เนื้อหาฉบับภาษาไทย

ใช้อ่านเพื่อทำความเข้าใจเบื้องต้น โปรดตรวจสอบรายละเอียดสำคัญกับเอกสารต้นฉบับด้านล่าง

RTK - Rust Token Killer
CIReleaseLicense: Apache 2.0DiscordHomebrew

rtk กรองและบีบอัดผลลัพธ์คำสั่งก่อนที่จะส่งไปยังบริบท LLM ของคุณ ไบนารี Rust เดี่ยว รองรับ 100+ คำสั่ง มีโอเวอร์เฮดน้อยกว่า 10ms

การประหยัดโทเค็น (เซสชัน Claude Code 30 นาที)

การดำเนินการความถี่มาตรฐานrtkการประหยัด
ls / tree10x2,000400-80%
cat / read20x40,00012,000-70%
grep / rg8x16,0003,200-80%
git status10x3,000600-80%
git diff5x10,0002,500-75%
git log5x2,500500-80%
git add/commit/push8x1,600120-92%
cargo test / npm test5x25,0002,500-90%
ruff check3x3,000600-80%
pytest4x8,000800-90%
go test3x6,000600-90%
docker ps3x900180-80%
รวม~118,000~23,900-80%

ประมาณการอิงจากโปรเจกต์ TypeScript/Rust ขนาดกลาง การประหยัดจริงจะแตกต่างกันไปตามขนาดโปรเจกต์

การติดตั้ง

Homebrew (แนะนำ)

bash
brew install rtk

ติดตั้งด่วน (Linux/macOS)

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

ติดตั้งไปที่ ~/.local/bin เพิ่มลงใน PATH หากจำเป็น:

bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc  # หรือ ~/.zshrc

Cargo

bash
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\<you>\.local\bin) รัน RTK จาก Command Prompt, PowerShell, หรือ Windows Terminal — อย่าดับเบิลคลิกที่ .exe (มันจะกะพริบแล้วปิดไป) ระบบ hook เต็มรูปแบบทำงานได้ตามปกติบน Windows (และใน WSL) ดูรายละเอียดที่ การตั้งค่า Windows ด้านล่าง

ตรวจสอบการติดตั้ง

bash
rtk --version   # ควรแสดง "rtk 0.28.2"
rtk gain        # ควรแสดงสถิติการประหยัดโทเค็น

คำเตือนการชนกันของชื่อ: มีโปรเจกต์อื่นชื่อ "rtk" (Rust Type Kit) อยู่บน crates.io หาก rtk gain ล้มเหลว แสดงว่าคุณได้แพ็กเกจผิด ใช้ cargo install --git ด้านบนแทน

เริ่มต้นใช้งานอย่างรวดเร็ว

bash
# 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
rtk init -g --agent droid       # Factory Droid

# 2. รีสตาร์ทเครื่องมือ AI ของคุณ แล้วทดสอบ
git status  # ถูกเขียนใหม่โดยอัตโนมัติเป็น rtk git status

เอเจนต์ที่ใช้ hook จะเขียนคำสั่ง Bash ใหม่ (เช่น git status -> rtk git status) ก่อนการดำเนินการ เอเจนต์ที่ใช้ปลั๊กอิน รวมถึง Hermes จะใช้ API ปลั๊กอินเพื่อเขียนคำสั่งใหม่ก่อนการดำเนินการ เอเจนต์จะได้รับผลลัพธ์ที่กระชับโดยไม่จำเป็นต้องเรียก rtk โดยตรง

สำคัญ: hook จะทำงานเฉพาะกับการเรียกใช้เครื่องมือ Bash เท่านั้น เครื่องมือในตัวของ Claude Code เช่น Read, Grep, และ Glob จะไม่ผ่าน Bash hook ดังนั้นจึงไม่ถูกเขียนใหม่โดยอัตโนมัติ หากต้องการผลลัพธ์ที่กระชับของ RTK สำหรับเวิร์กโฟลว์เหล่านั้น ให้ใช้คำสั่ง shell (cat/head/tail, rg/grep, find) หรือเรียก rtk read, rtk grep, หรือ rtk find โดยตรง

วิธีการทำงาน

code
  Without rtk:                                    With rtk:

  Claude  --git status-->  shell  -->  git         Claude  --git status-->  RTK  -->  git
    ^                                   |            ^                      |          |
    |        ~2,000 tokens (raw)        |            |   ~200 tokens        | filter   |
    +-----------------------------------+            +------- (filtered) ---+----------+

สี่กลยุทธ์ที่ใช้กับแต่ละประเภทคำสั่ง:

  1. 1การกรองอัจฉริยะ (Smart Filtering) - ลบสิ่งรบกวน (ความคิดเห็น, ช่องว่าง, boilerplate)
  2. 2การจัดกลุ่ม (Grouping) - รวบรวมรายการที่คล้ายกัน (ไฟล์ตามไดเรกทอรี, ข้อผิดพลาดตามประเภท)
  3. 3การตัดทอน (Truncation) - เก็บเฉพาะบริบทที่เกี่ยวข้อง, ตัดส่วนที่ซ้ำซ้อน
  4. 4การลบรายการซ้ำ (Deduplication) - ยุบรายการบันทึกที่ซ้ำกันพร้อมจำนวนนับ

คำสั่ง

ไฟล์

bash
rtk ls .                        # โครงสร้างไดเรกทอรีที่ปรับให้เหมาะสมกับโทเค็น
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            # diff แบบย่อ (ออก 1 หากไฟล์แตกต่างกัน)

Git

bash
rtk git status                  # สถานะแบบกระชับ
rtk git log -n 10               # คอมมิตแบบบรรทัดเดียว
rtk git diff                    # 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

bash
rtk gh pr list                  # รายการ PR แบบกระชับ
rtk gh pr view 42               # รายละเอียด PR + การตรวจสอบ
rtk gh issue list               # รายการ issue แบบกระชับ
rtk gh run list                 # สถานะการรันเวิร์กโฟลว์

ตัวรันการทดสอบ

bash
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 <cmd>                   # กรองเฉพาะข้อผิดพลาดจากคำสั่งใดๆ
rtk test <cmd>                  # ตัวห่อการทดสอบทั่วไป - เฉพาะข้อผิดพลาด (-90%)

Build & Lint

bash
rtk lint                        # ESLint จัดกลุ่มตามกฎ/ไฟล์
rtk lint biome                  # รองรับ linters อื่นๆ
rtk tsc                         # ข้อผิดพลาด TypeScript จัดกลุ่มตามไฟล์
rtk next build                  # Next.js build แบบกระชับ
rtk prettier --check .          # ไฟล์ที่ต้องการการจัดรูปแบบ
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%+)

ตัวจัดการแพ็กเกจ

bash
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 art)

AWS

bash
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

### Containers
```bash
rtk docker ps                   # รายการ container แบบย่อ
rtk docker images               # รายการ image แบบย่อ
rtk docker logs <container>     # logs แบบตัดข้อมูลซ้ำ
rtk docker compose ps           # บริการของ Compose
rtk kubectl pods                # รายการ pod แบบย่อ
rtk kubectl logs <pod>          # logs แบบตัดข้อมูลซ้ำ
rtk kubectl services            # รายการ service แบบย่อ
rtk oc get pods                 # สรุปรายการ pod ของ OpenShift
rtk oc get services             # รายการ service ของ OpenShift
rtk oc logs <pod>               # logs แบบตัดข้อมูลซ้ำ

Infrastructure as Code

bash
rtk pulumi preview              # ตัดส่วนหัว/URL/ระยะเวลาที่ไม่จำเป็นออก
rtk pulumi up                   # ผลลัพธ์การ apply แบบย่อ
rtk pulumi destroy              # ผลลัพธ์การ destroy แบบย่อ
rtk pulumi refresh              # สรุปการเปลี่ยนแปลง (Drift summary)
rtk pulumi stack                # เมทาดาตาของ Stack (ตัดเจ้าของ/เวลาออก)

Data & Analytics

bash
rtk json config.json            # แสดงโครงสร้างโดยไม่มีค่าข้อมูล
rtk deps                        # สรุป Dependencies
rtk env -f AWS                  # กรองตัวแปร env
rtk log app.log                 # logs แบบตัดข้อมูลซ้ำ
rtk curl <url>                  # ตัดส่วนท้าย + บันทึกผลลัพธ์ฉบับเต็ม
rtk wget <url>                  # ดาวน์โหลดโดยตัดแถบแสดงความคืบหน้าออก
rtk summary <long command>      # สรุปผลลัพธ์ด้วย Heuristic
rtk proxy <command>             # ส่งผ่านข้อมูลดิบ + ติดตามผล

Token Savings Analytics

bash
rtk gain                        # สถิติสรุป
rtk gain --graph                # กราฟ ASCII (30 วันล่าสุด)
rtk gain --history              # ประวัติคำสั่งล่าสุด
rtk gain --daily                # รายละเอียดแบบรายวัน
rtk gain --all --format json    # ส่งออกเป็น JSON สำหรับแดชบอร์ด

rtk discover                    # ค้นหาโอกาสในการประหยัด token ที่พลาดไป
rtk discover --all --since 7    # ทุกโปรเจกต์ ในช่วง 7 วันล่าสุด

rtk session                     # แสดงการใช้งาน RTK ในเซสชันล่าสุด

Global Flags

bash
-u, --ultra-compact    # ใช้ไอคอน ASCII, รูปแบบ inline (ประหยัด token เพิ่มขึ้น)
-v, --verbose          # เพิ่มระดับความละเอียด (-v, -vv, -vvv)

Examples

การแสดงรายการไดเรกทอรี:

code
# 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:

code
# 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
...

ผลลัพธ์การทดสอบ (Test output):

code
# 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
...

Auto-Rewrite Hook

วิธีที่มีประสิทธิภาพที่สุดในการใช้ rtk โดย hook จะดักจับคำสั่ง Bash และเขียนคำสั่งใหม่ให้เป็นรูปแบบของ rtk โดยอัตโนมัติก่อนการประมวลผล

ผลลัพธ์: ใช้งาน rtk ได้ 100% ในทุกการสนทนาและ subagents โดยไม่มี token overhead

หมายเหตุเรื่องขอบเขต: สิ่งนี้ใช้ได้กับ Bash tool calls เท่านั้น เครื่องมือในตัวของ Claude Code เช่น Read, Grep, และ Glob จะไม่ผ่าน hook นี้ ดังนั้นให้ใช้คำสั่ง shell หรือคำสั่ง rtk โดยตรงเมื่อต้องการการกรองของ RTK ในส่วนดังกล่าว

Setup

bash
rtk init -g                 # ติดตั้ง hook + RTK.md (แนะนำ)
rtk init -g --opencode      # ปลั๊กอิน OpenCode (แทนที่ Claude Code)
rtk init -g --auto-patch    # แบบไม่ต้องโต้ตอบ (สำหรับ CI/CD)
rtk init -g --hook-only     # ติดตั้งเฉพาะ hook โดยไม่มี RTK.md
rtk init --show             # ตรวจสอบการติดตั้ง

หลังจากติดตั้ง ให้ รีสตาร์ท Claude Code

Windows

RTK ทำงานได้อย่างสมบูรณ์บน Windows แบบ native ตั้งแต่ v0.37.2 auto-rewrite hook จะทำงานเป็น native binary command (rtk hook claude) โดยไม่ต้องใช้ Unix shell, bash หรือ jq ดังนั้นคำสั่งจะถูกเขียนใหม่โดยอัตโนมัติบน Command Prompt, PowerShell และ Windows Terminal เช่นเดียวกับบน Linux และ macOS

Native Windows

powershell
# 1. ดาวน์โหลดและแตกไฟล์ rtk-x86_64-pc-windows-msvc.zip จากหน้า releases
# 2. เพิ่ม rtk.exe ลงใน PATH (เช่น C:\Users\<you>\.local\bin)
# 3. เริ่มต้นการทำงาน — ติดตั้ง native binary hook
rtk init -g

อัปเกรดจากการติดตั้งเวอร์ชันเก่า? หากคุณติดตั้ง RTK ก่อน v0.37.2 คุณอาจยังมี shell hook แบบเก่า rtk-rewrite.sh (ซึ่งจำเป็นต้องใช้ Unix shell) ให้รัน rtk init -g อีกครั้งเพื่อย้ายมาใช้ native binary hook

สิ่งที่จำเป็น: ฟิลเตอร์บางตัวต้องเรียกใช้ ripgrep (rg) โปรดติดตั้งและเพิ่มลงใน PATH (เช่น winget install BurntSushi.ripgrep.MSVC) เพื่อหลีกเลี่ยงคำเตือน Binary 'rg' not found on PATH

สำคัญ: ห้ามดับเบิลคลิก rtk.exe เนื่องจากเป็นเครื่องมือ CLI ที่จะแสดงวิธีใช้งานและจบการทำงานทันที ให้รันผ่านเทอร์มินัลเสมอ (Command Prompt, PowerShell หรือ Windows Terminal)

WSL

WSL สามารถใช้งานได้และทำงานเหมือนกับ Linux ทุกประการ:

bash
# ภายใน WSL
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
rtk init -g
ฟีเจอร์Native WindowsWSL
Filters (cargo, git, etc.)สมบูรณ์สมบูรณ์
Auto-rewrite hookใช่ (native binary)ใช่
rtk init -gHook modeHook mode
rtk gain / analyticsสมบูรณ์สมบูรณ์

Supported AI Tools

RTK รองรับเครื่องมือ AI coding 15 รายการ โดยการรวมเข้ากับแต่ละเครื่องมือจะเขียนคำสั่ง shell ใหม่ให้เป็นรูปแบบ rtk เพื่อประหยัด token ได้ 60-90% ในกรณีที่ agent รองรับการดักจับคำสั่ง (command interception)

เครื่องมือการติดตั้งวิธีการ
Claude Codertk init -gPreToolUse hook (native binary)
GitHub Copilot (VS Code)rtk init -g --copilotPreToolUse hook — rewrite แบบโปร่งใส
GitHub Copilot CLIrtk init -g --copilotPreToolUse deny-with-suggestion (ข้อจำกัดของ CLI)
Cursorrtk init -g --agent cursorpreToolUse hook (hooks.json)
Gemini CLIrtk init -g --geminiBeforeTool hook
Codexrtk init -g --codexคำแนะนำใน AGENTS.md + RTK.md
Windsurfrtk init -g --agent windsurf.windsurfrules (ระดับโปรเจกต์)
Cline / Roo Codertk init --agent cline.clinerules (ระดับโปรเจกต์)
OpenCodertk init -g --opencodePlugin TS (tool.execute.before)
OpenClawopenclaw plugins install ./openclawPlugin TS (before_tool_call)
Pirtk init -g --agent pi (global)TypeScript extension (tool_call)
Hermesrtk init --agent hermesPython plugin adapter (เปลี่ยนคำสั่งเทอร์มินัลผ่าน rtk rewrite)
Mistral Vibeกำลังดำเนินการ (#800)รอการอัปเดตจาก upstream
Kilo Codertk init --agent kilocode.kilocode/rules/rtk-rules.md (ระดับโปรเจกต์)
Google Antigravityrtk init --agent antigravity.agents/rules/antigravity-rtk-rules.md (ระดับโปรเจกต์)
Factory Droidrtk init -g --agent droid (หรือรายโปรเจกต์)PreToolUse hook ใน ~/.factory/hooks.json (matcher Execute)

สำหรับรายละเอียดการตั้งค่าราย agent, การควบคุมการ override และการลดระดับการทำงาน (graceful degradation) โปรดดูที่ Supported Agents guide ซอร์สโค้ดและแบบทดสอบของปลั๊กอิน Hermes อยู่ใน hooks/hermes/ และไฟล์ runtime ของ Hermes ที่ติดตั้งแล้วจะอยู่ที่ ~/.hermes/plugins/rtk-rewrite/

Configuration

~/.config/rtk/config.toml (macOS: ~/Library/Application Support/rtk/config.toml):

toml
[hooks]
exclude_commands = ["curl", "playwright"]  # ข้ามการ rewrite สำหรับคำสั่งเหล่านี้

[tee]
enabled = true          # บันทึกผลลัพธ์ดิบเมื่อเกิดข้อผิดพลาด (ค่าเริ่มต้น: true)
mode = "failures"       # "failures", "always", หรือ "never"

เมื่อคำสั่งล้มเหลว RTK จะบันทึกผลลัพธ์ฉบับเต็มที่ไม่ได้กรอง เพื่อให้ LLM สามารถอ่านได้โดยไม่ต้องรันคำสั่งซ้ำ:

code
FAILED: 2/15 tests
[full output: ~/.local/share/rtk/tee/1707753600_cargo_test.log]

สำหรับข้อมูลอ้างอิงการตั้งค่าฉบับเต็ม (ทุกส่วน, env vars, ฟิลเตอร์รายโปรเจกต์) โปรดดูที่ Configuration guide

Uninstall

bash
rtk init -g --uninstall     # ลบ hook, RTK.md, และรายการใน settings.json
cargo uninstall rtk          # ลบ binary
brew uninstall rtk           # หากติดตั้งผ่าน Homebrew

Documentation

  • rtk-ai.app/guide — คู่มือผู้ใช้ฉบับเต็ม (การติดตั้ง, agent ที่รองรับ, สิ่งที่ถูกปรับแต่ง, การวิเคราะห์, การตั้งค่า, การแก้ไขปัญหา)
  • INSTALL.md — ข้อมูลอ้างอิงการติดตั้งโดยละเอียด
  • ARCHITECTURE.md — การออกแบบระบบและการตัดสินใจทางเทคนิค
  • CONTRIBUTING.md — คู่มือการมีส่วนร่วม
  • SECURITY.md — นโยบายความปลอดภัย

ความเป็นส่วนตัวและการเก็บข้อมูลการใช้งาน (Privacy & Telemetry)

RTK อาจมีการเก็บ ข้อมูลการใช้งานแบบรวมกลุ่มและไม่ระบุตัวตน (anonymous, aggregate usage metrics) วันละหนึ่งครั้ง โดยระบบ Telemetry จะถูก ปิดการใช้งานเป็นค่าเริ่มต้น และต้องได้รับ ความยินยอมอย่างชัดเจน (explicit opt-in consent) (ตาม GDPR Art. 6, 7) ในระหว่างขั้นตอน rtk init หรือผ่านคำสั่ง rtk telemetry enable ข้อมูลนี้ช่วยให้เราพัฒนาผลิตภัณฑ์ให้ดียิ่งขึ้น เช่น การระบุว่าคำสั่งใดที่จำเป็นต้องมี filter, filter ตัวไหนที่ต้องปรับปรุง และ RTK สร้างมูลค่าได้มากน้อยเพียงใด สำหรับรายการฟิลด์ข้อมูลทั้งหมด การจัดการข้อมูล และแนวทางสำหรับผู้ร่วมพัฒนา สามารถดูได้ที่ docs/TELEMETRY.md

ข้อมูลที่ถูกเก็บและเหตุผล:

หมวดหมู่ข้อมูลเหตุผล
ตัวตน (Identity)Salted device hash (SHA-256, ไม่สามารถย้อนกลับได้)เพื่อนับจำนวนการติดตั้งที่ไม่ซ้ำกันโดยไม่ติดตามรายบุคคล
สภาพแวดล้อม (Environment)RTK version, OS, architecture, วิธีการติดตั้งเพื่อให้ทราบว่าควรสนับสนุนและทดสอบบนแพลตฟอร์มใดบ้าง
ปริมาณการใช้งาน (Usage volume)จำนวนคำสั่ง (24 ชม.), จำนวนคำสั่งทั้งหมด, จำนวน token ที่ประหยัดได้ (24 ชม./30 วัน/ทั้งหมด)เพื่อวัดการนำไปใช้งานและมูลค่าที่ส่งมอบ
คุณภาพ (Quality)5 อันดับคำสั่งที่ส่งผ่านทั้งหมด (ประหยัด 0%), จำนวนครั้งที่ parse ล้มเหลว, คำสั่งที่ประหยัดได้ <30%เพื่อระบุ filter ที่ขาดหายไปหรือตัวที่ประสิทธิภาพต่ำเพื่อนำมาปรับปรุง
ระบบนิเวศ (Ecosystem)การกระจายหมวดหมู่คำสั่ง (เช่น git 45%, cargo 20%, js 15%)เพื่อจัดลำดับความสำคัญในการพัฒนา filter สำหรับระบบนิเวศที่ได้รับความนิยม
การรักษาผู้ใช้ (Retention)จำนวนวันนับตั้งแต่ใช้งานครั้งแรก, จำนวนวันที่ใช้งานใน 30 วันล่าสุดเพื่อทำความเข้าใจความผูกพันของผู้ใช้และตรวจจับการเลิกใช้งาน (churn)
การนำไปใช้ (Adoption)ประเภท AI agent hook (claude/gemini/codex), จำนวน custom TOML filterเพื่อติดตามความครอบคลุมของการเชื่อมต่อและการนำ DSL ไปใช้งาน
การตั้งค่า (Configuration)การมีอยู่ของ config.toml, จำนวนคำสั่งที่ยกเว้น, จำนวนโปรเจกต์เพื่อทำความเข้าใจระดับความเชี่ยวชาญของผู้ใช้และรูปแบบการปรับแต่ง
ฟีเจอร์ (Features)จำนวนการใช้งาน meta-commands (gain, discover, proxy, verify)เพื่อให้ทราบว่าฟีเจอร์ใดของ RTK ที่มีประโยชน์และฟีเจอร์ใดที่ไม่มีคนใช้
ความคุ้มค่า (Economics)ประมาณการมูลค่าที่ประหยัดได้เป็น USD (อ้างอิงจากราคา API token)เพื่อวัดมูลค่าเชิงปริมาณที่ RTK มอบให้กับผู้ใช้

ข้อมูลทั้งหมดจะเป็น จำนวนแบบรวมกลุ่มหรือชื่อคำสั่งที่ไม่ระบุตัวตน (เก็บเพียง 3 คำแรก และไม่มี arguments) สำหรับคำสั่งยอดนิยมจะรายงานเพียงชื่อเครื่องมือ (เช่น "git", "cargo") และจะไม่มีการเก็บคำสั่งแบบเต็มบรรทัดโดยเด็ดขาด

สิ่งที่ไม่ถูกเก็บ: ซอร์สโค้ด, พาธของไฟล์, arguments ของคำสั่ง, ความลับ (secrets), environment variables, ข้อมูลส่วนบุคคล หรือเนื้อหาใน repository

การจัดการ telemetry:

bash
rtk telemetry status     # ตรวจสอบสถานะการยินยอมในปัจจุบัน
rtk telemetry enable     # ให้ความยินยอม (ผ่าน interactive prompt)
rtk telemetry disable    # ถอนความยินยอม — หยุดการเก็บข้อมูลทั้งหมดทันที
rtk telemetry forget     # ถอนความยินยอม + ลบข้อมูลท้องถิ่นทั้งหมด + ร้องขอให้ลบข้อมูลฝั่งเซิร์ฟเวอร์

การบังคับปิดผ่าน environment variable:

bash
export RTK_TELEMETRY_DISABLED=1   # บล็อก telemetry โดยไม่คำนึงถึงการยินยอม

Star History

Star History Chart

StarMapper

StarMapper

ทีมงานหลัก (Core team)

การมีส่วนร่วม (Contributing)

ยินดีรับการสนับสนุน! โปรดเปิด issue หรือ PR บน GitHub

เข้าร่วมชุมชนได้ที่ Discord

ไลเซนส์ (License)

Apache License 2.0 - ดูรายละเอียดได้ที่ LICENSE

ข้อสงวนสิทธิ์ (Disclaimer)

ดูรายละเอียดที่ DISCLAIMER.md

เอกสารโปรเจกต์

อ่านเอกสารต้นฉบับ

README วิธีติดตั้ง วิธีใช้งาน และข้อกำหนดจาก repository ต้นฉบับ

ดูไฟล์บน GitHub
RTK - Rust Token Killer
CIReleaseLicense: Apache 2.0DiscordHomebrew

rtk filters and compresses command outputs before they reach your LLM context. Single Rust binary, 100+ supported commands, <10ms overhead.

What RTK Does

RTK intercepts shell commands and compresses their output before your agent reads it.

OperationWhat RTK does to the output
ls / treeTree format with file counts instead of one line per entry
cat / readSmart file reading: signatures and structure over full bodies
grep / rgTruncates long lines, groups matches by file
git statusCompact stat format, grouped by state
git diffReduced context, headers stripped
git logHash, author and subject only
git add/commit/pushConfirmation line instead of full progress output
cargo test / npm testFailures only, passing tests collapsed to a count
ruff checkGrouped by rule and file
pytestFailures only, traceback trimmed
go testNDJSON parsed, failures only
docker psEssential fields only

How Savings Work

RTK cuts up to 90% of the bash output your agent reads. That is what RTK measures, and it is not the same as cutting your bill by 90%.

Bash output is one contributor to input tokens, alongside your prompt, the system prompt and conversation history. Input tokens are in turn only part of the bill, which also counts output tokens. The reduction dilutes at every step.

The token counts RTK reports are estimated as bytes / 4 — RTK ships no tokenizer, so the percentages are reliable but the absolute token numbers are approximate.

Full explanation: How RTK Savings Work

Installation

Homebrew (recommended)

bash
brew install rtk

Quick Install (Linux/macOS)

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

Installs to ~/.local/bin. Add to PATH if needed:

bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc  # or ~/.zshrc

Cargo

bash
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

Windows users: Extract the zip and place rtk.exe somewhere 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.

Verify Installation

bash
rtk --version   # Should show "rtk 0.28.2"
rtk gain        # Should show the savings dashboard

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

bash
# 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 --agent kimi           # Kimi AI
rtk init -g --agent pi          # Pi
rtk init --agent hermes         # Hermes
rtk init -g --agent droid       # Factory Droid

# 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.

How It Works

code
  Without rtk:                                    With rtk:

  Claude  --git status-->  shell  -->  git         Claude  --git status-->  RTK  -->  git
    ^                                   |            ^                      |          |
    |         full raw output           |            |  compact output      | filter   |
    +-----------------------------------+            +------- (filtered) ---+----------+

Four strategies applied per command type:

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

Commands

Percentages below are reductions in bash output, not reductions in your bill. See How Savings Work.

Files

bash
rtk ls .                        # Compact 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)

Git

bash
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

bash
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

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

Build & Lint

bash
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 sbt test                    # ScalaTest output (-90%)
rtk sbt compile                 # Compilation errors only (-75%)
rtk sbt run                     # Strip SBT preamble noise

Package Managers

bash
rtk pnpm list                   # Compact dependency tree
rtk uv run pytest               # Preserve uv env, keep program output
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  # 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

Containers

bash
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

Infrastructure as Code

bash
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)

Data & Analytics

bash
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

Token Savings Analytics

bash
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

Global Flags

bash
-u, --ultra-compact    # ASCII icons, inline format (further output reduction)
-v, --verbose          # Increase verbosity (-v, -vv, -vvv)

Examples

Directory listing:

code
# ls -la (45 lines)                     # rtk ls (12 lines)
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:

code
# git push (15 lines)                    # rtk git push (1 line)
Enumerating objects: 5, done.             ok main
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
...

Test output:

code
# 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
...

Auto-Rewrite Hook

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, with no per-command context 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.

Setup

bash
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.

Windows

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.

Native Windows

powershell
# 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

WSL also works and behaves exactly like Linux:

bash
# Inside WSL
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
rtk init -g
FeatureNative WindowsWSL
Filters (cargo, git, etc.)FullFull
Auto-rewrite hookYes (native binary)Yes
rtk init -gHook modeHook mode
rtk gain / analyticsFullFull

Supported AI Tools

RTK supports 15 AI coding tools. Each integration rewrites shell commands to rtk equivalents, reducing the bash output the agent reads where the agent supports command interception.

ToolInstallMethod
Claude Codertk init -gPreToolUse hook (native binary)
GitHub Copilot (VS Code)rtk init -g --copilotPreToolUse hook — transparent rewrite
GitHub Copilot CLIrtk init -g --copilotPreToolUse deny-with-suggestion (CLI limitation)
Cursorrtk init -g --agent cursorpreToolUse hook (hooks.json)
Gemini CLIrtk init -g --geminiBeforeTool hook
Codexrtk init -g --codexAGENTS.md + RTK.md instructions
Windsurfrtk init -g --agent windsurf.windsurfrules (project-scoped)
Cline / Roo Codertk init --agent cline.clinerules (project-scoped)
OpenCodertk init -g --opencodePlugin TS (tool.execute.before)
OpenClawopenclaw plugins install ./openclawPlugin TS (before_tool_call)
Pirtk init -g --agent pi (global)TypeScript extension (tool_call)
Hermesrtk init --agent hermesPython plugin adapter (terminal command mutation via rtk rewrite)
Mistral VibePlanned (#800)Blocked on upstream
Kilo Codertk init --agent kilocode.kilocode/rules/rtk-rules.md (project-scoped)
Google Antigravityrtk init --agent antigravity.agents/rules/antigravity-rtk-rules.md (project-scoped)
Kimi AIrtk init --agent kimiAGENTS.md (project-scoped)
Factory Droidrtk init -g --agent droid (or per-project)PreToolUse hook in ~/.factory/hooks.json (matcher Execute)

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/.

Configuration

~/.config/rtk/config.toml (macOS: ~/Library/Application Support/rtk/config.toml):

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:

code
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.

Uninstall

bash
rtk init -g --uninstall     # Remove hook, RTK.md, settings.json entry
cargo uninstall rtk          # Remove binary
brew uninstall rtk           # If installed via Homebrew

Documentation

Privacy & Telemetry

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:

CategoryDataWhy
IdentitySalted device hash (SHA-256, not reversible)Count unique installations without tracking individuals
EnvironmentRTK version, OS, architecture, install methodKnow which platforms to support and test
Usage volumeCommand count (24h), total commands, estimated tokens saved (24h/30d/total)Measure adoption and value delivered
QualityTop 5 passthrough commands (0% reduction), parse failure count, commands with <30% reductionIdentify missing filters and weak ones to improve
EcosystemCommand category distribution (e.g. git 45%, cargo 20%, js 15%)Prioritize filter development for popular ecosystems
RetentionDays since first use, active days in last 30Understand engagement and detect churn
AdoptionAI agent hook type (claude/gemini/codex), custom TOML filter countTrack integration coverage and DSL adoption
ConfigurationWhether config.toml exists, number of excluded commands, project countUnderstand user maturity and customization patterns
FeaturesUsage counts for meta-commands (gain, discover, proxy, verify)Know which RTK features are valued vs unused
EconomicsEstimated USD value, derived from the estimated tokens saved and a fixed internal constantQuantify 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:

bash
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:

bash
export RTK_TELEMETRY_DISABLED=1   # Blocks telemetry regardless of consent

Star History

Star History Chart

StarMapper

StarMapper

Core team

Contributing

Contributions welcome! Please open an issue or PR on GitHub.

Join the community on Discord.

License

Apache License 2.0 - see LICENSE for details.

Disclaimer

See DISCLAIMER.md.

#agentic-coding#ai-coding#anthropic#claude-code#cli#command-line-tool#cost-reduction#developer-tools#llm#open-source#productivity#rust