From aradotso-trending-skills-37
Compresses outputs from git, ls, pytest, cargo test etc. via Rust CLI proxy and bash hooks to reduce LLM token usage 60-90%.
npx claudepluginhub joshuarweaver/cascade-ai-ml-agents-misc-1 --plugin aradotso-trending-skills-37This skill uses the workspace's default tool permissions.
```markdown
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
---
name: rtk-token-optimizer
description: CLI proxy that reduces LLM token consumption by 60-90% on common dev commands using a single Rust binary
triggers:
- reduce token usage with rtk
- install rtk for claude code
- rtk token savings setup
- optimize llm context with rtk
- rtk git status compact output
- set up rtk hook for ai coding
- rtk command not working
- how to use rtk with cursor or windsurf
---
# RTK Token Optimizer
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
RTK is a high-performance CLI proxy written in Rust that intercepts common dev commands (`git`, `ls`, `cargo test`, `pytest`, etc.) and compresses their output before it reaches your LLM context window. A single static binary with zero runtime dependencies adds less than 10ms overhead while cutting token usage by 60–90%.
---
## Installation
### Homebrew (recommended)
```bash
brew install rtk
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
# Add to PATH if needed:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
cargo install --git https://github.com/rtk-ai/rtk
rtk --version # rtk 0.28.2
rtk gain # shows token savings stats
Crates.io collision: A different package called "rtk" exists on crates.io. Always use
--gitwith cargo.
The hook transparently rewrites Bash tool calls (e.g., git status → rtk git status) before execution. Claude never sees the rewrite — it just receives compressed output.
rtk init -g # Claude Code / Copilot (global, recommended)
rtk init -g --gemini # Gemini CLI
rtk init -g --codex # Codex / OpenAI
rtk init -g --agent cursor # Cursor
rtk init --agent windsurf # Windsurf (project-scoped)
rtk init --agent cline # Cline / Roo Code (project-scoped)
rtk init -g --opencode # OpenCode plugin
rtk init -g --auto-patch # Non-interactive (CI/CD)
rtk init --show # Verify current installation
After installing, restart your AI tool.
Scope: The hook only applies to Bash tool calls. Claude Code built-in tools (
Read,Grep,Glob) bypass it. Use shell equivalents (cat,rg,find) or explicitrtkcommands for those workflows.
rtk ls . # Token-optimized directory tree
rtk read src/main.rs # Smart file reading
rtk read src/main.rs -l aggressive # Signatures only (strips function bodies)
rtk smart src/main.rs # 2-line heuristic code summary
rtk find "*.rs" . # Compact find results
rtk grep "fn parse" src/ # Grouped search results
rtk diff file1.rs file2.rs # Condensed diff
rtk git status # Compact status (~200 tokens vs ~2000)
rtk git log -n 10 # One-line commits
rtk git diff # Condensed diff
rtk git add . # Output: "ok"
rtk git commit -m "fix: parse" # Output: "ok abc1234"
rtk git push # Output: "ok main"
rtk git pull # Output: "ok 3 files +10 -2"
rtk cargo test # Rust — failures only (-90%)
rtk test cargo test # Explicit test wrapper
rtk pytest # Python — failures only (-90%)
rtk go test # Go — NDJSON compact (-90%)
rtk rspec # Ruby — JSON compact (-60%+)
rtk vitest run # Vitest — failures only
rtk playwright test # E2E — failures only
rtk rake test # Ruby minitest (-90%)
rtk cargo build # Rust build (-80%)
rtk cargo clippy # Clippy warnings grouped (-80%)
rtk tsc # TypeScript errors by file
rtk lint # ESLint grouped by rule/file
rtk lint biome # Biome linter
rtk ruff check # Python lint (JSON, -80%)
rtk golangci-lint run # Go lint (JSON, -85%)
rtk rubocop # Ruby lint (JSON, -60%+)
rtk next build # Next.js compact build output
rtk prettier --check . # Files needing formatting only
rtk gh pr list # Compact PR listing
rtk gh pr view 42 # PR details + check status
rtk gh issue list # Compact issue listing
rtk gh run list # Workflow run status
rtk docker ps # Compact container list
rtk docker images # Compact image list
rtk docker logs <container> # Deduplicated log lines
rtk docker compose ps # Compose services
rtk kubectl pods # Compact pod list
rtk kubectl logs <pod> # Deduplicated pod logs
rtk kubectl services # Compact service list
rtk json config.json # Structure without values (schema view)
rtk env -f AWS # Filtered env vars (e.g., AWS_*)
rtk log app.log # Deduplicated application logs
rtk curl https://api.example.com # Auto-detect JSON + print schema
rtk deps # Dependency summary
rtk summary <long command> # Heuristic summary of any command
rtk proxy <command> # Raw passthrough + token tracking
rtk pnpm list # Compact dependency tree
rtk pip list # Python packages (auto-detects uv)
rtk pip outdated # Outdated packages only
rtk bundle install # Ruby gems (strips "Using" lines)
rtk prisma generate # Schema generation (no ASCII art)
rtk -u <command> # --ultra-compact: ASCII icons, inline format
rtk -v <command> # --verbose (stack: -v, -vv, -vvv)
rtk gain # Summary stats
rtk gain --graph # ASCII graph (last 30 days)
rtk gain --history # Recent command history with savings
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 # RTK adoption across recent sessions
# Instead of: cargo test 2>&1 (200+ lines on failure)
rtk cargo test
# Output (~20 lines):
# FAILED: 2/15 tests
# test_edge_case: assertion failed at utils.rs:42
# test_overflow: panic at utils.rs:18
rtk cargo clippy
# Output: grouped warnings by lint rule, not raw rustc noise
rtk pytest # Only failing tests + tracebacks
rtk ruff check # JSON-parsed, grouped by rule
rtk pip outdated # Table of outdated packages only
rtk tsc # TypeScript errors grouped by file
rtk lint # ESLint violations grouped by rule
rtk next build # Next.js build, key metrics only
rtk vitest run # Failures only, not 300 "✓ pass" lines
# Full file (smart truncation)
rtk read src/lib.rs
# Signatures only — ideal for understanding module structure
rtk read src/lib.rs -l aggressive
# 2-line summary heuristic
rtk smart src/lib.rs
rtk git status # ~200 tokens (vs raw ~2000)
rtk git diff HEAD~1 # Condensed patch
rtk git log -n 5 # 5 one-liners
rtk git add . && rtk git commit -m "feat: add parser"
# Output: "ok" then "ok a3f9c12"
RTK is configuration-free by default. All tuning is via CLI flags:
| Flag | Effect |
|---|---|
-u / --ultra-compact | Maximum compression with ASCII icons |
-v / -vv / -vvv | Increase verbosity for debugging |
-l aggressive | Aggressive level for rtk read (signatures only) |
The rtk init command writes hooks to your AI tool's config directory (global -g) or the current project directory (no -g).
rtk gain fails after cargo install rtkWrong package from crates.io. Reinstall from source:
cargo install --git https://github.com/rtk-ai/rtk
rtk init --show # Check hook installation status
rtk init -g # Reinstall hook
# Then restart your AI tool (Claude Code, Cursor, etc.)
Built-in AI tool operations (Read, Grep, Glob in Claude Code) bypass the Bash hook. Use shell equivalents:
# Instead of Claude's Read tool, ask it to run:
rtk read src/main.rs
# Instead of Grep tool:
rtk grep "pattern" src/
export PATH="$HOME/.local/bin:$PATH"
# Persist it:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Download the correct release asset:
rtk-aarch64-apple-darwin.tar.gzrtk-x86_64-apple-darwin.tar.gzrtk gain --history # Should show recent commands
rtk session # Should show adoption %
If empty, the hook may not be active. Run rtk init --show.
RTK applies four compression strategies per command type:
Using gem..., progress bars)Without RTK:
Agent → "git status" → shell → git → ~2,000 tokens raw → Agent
With RTK:
Agent → "git status" → RTK → git → filter/group/truncate → ~200 tokens → Agent
The binary runs in-process before output is returned to the shell, adding <10ms latency.
| Tool | Command | Scope |
|---|---|---|
| Claude Code | rtk init -g | Global |
| GitHub Copilot | rtk init -g | Global |
| Cursor | rtk init -g --agent cursor | Global |
| Gemini CLI | rtk init -g --gemini | Global |
| Codex | rtk init -g --codex | Global |
| Windsurf | rtk init --agent windsurf | Project |
| Cline / Roo Code | rtk init --agent cline | Project |
| OpenCode | rtk init -g --opencode | Global |
# Setup
brew install rtk && rtk init -g && <restart AI tool>
# Most used
rtk git status / diff / log / add / commit / push
rtk cargo test / build / clippy
rtk pytest / go test / vitest run
rtk read <file> / rtk ls . / rtk grep <pat> <dir>
rtk tsc / rtk lint / rtk ruff check
# Analytics
rtk gain --graph
rtk discover
# Flags
rtk -u <cmd> # ultra-compact
rtk -v <cmd> # verbose/debug