|
| 1 | +<!-- rtk-instructions v2 --> |
| 2 | +# RTK (Rust Token Killer) - Token-Optimized Commands |
| 3 | + |
| 4 | +## Golden Rule |
| 5 | + |
| 6 | +**Always prefix commands with `rtk`**. If RTK has a dedicated filter, it uses it. If not, it passes through unchanged. This means RTK is always safe to use. |
| 7 | + |
| 8 | +**Important**: Even in command chains with `&&`, use `rtk`: |
| 9 | +```bash |
| 10 | +# ❌ Wrong |
| 11 | +git add . && git commit -m "msg" && git push |
| 12 | + |
| 13 | +# ✅ Correct |
| 14 | +rtk git add . && rtk git commit -m "msg" && rtk git push |
| 15 | +``` |
| 16 | + |
| 17 | +## RTK Commands by Workflow |
| 18 | + |
| 19 | +### Build & Compile (80-90% savings) |
| 20 | +```bash |
| 21 | +rtk cargo build # Cargo build output |
| 22 | +rtk cargo check # Cargo check output |
| 23 | +rtk cargo clippy # Clippy warnings grouped by file (80%) |
| 24 | +rtk tsc # TypeScript errors grouped by file/code (83%) |
| 25 | +rtk lint # ESLint/Biome violations grouped (84%) |
| 26 | +rtk prettier --check # Files needing format only (70%) |
| 27 | +rtk next build # Next.js build with route metrics (87%) |
| 28 | +``` |
| 29 | + |
| 30 | +### Test (60-99% savings) |
| 31 | +```bash |
| 32 | +rtk cargo test # Cargo test failures only (90%) |
| 33 | +rtk go test # Go test failures only (90%) |
| 34 | +rtk jest # Jest failures only (99.5%) |
| 35 | +rtk vitest # Vitest failures only (99.5%) |
| 36 | +rtk playwright test # Playwright failures only (94%) |
| 37 | +rtk pytest # Python test failures only (90%) |
| 38 | +rtk rake test # Ruby test failures only (90%) |
| 39 | +rtk rspec # RSpec test failures only (60%) |
| 40 | +rtk test <cmd> # Generic test wrapper - failures only |
| 41 | +``` |
| 42 | + |
| 43 | +### Git (59-80% savings) |
| 44 | +```bash |
| 45 | +rtk git status # Compact status |
| 46 | +rtk git log # Compact log (works with all git flags) |
| 47 | +rtk git diff # Compact diff (80%) |
| 48 | +rtk git show # Compact show (80%) |
| 49 | +rtk git add # Ultra-compact confirmations (59%) |
| 50 | +rtk git commit # Ultra-compact confirmations (59%) |
| 51 | +rtk git push # Ultra-compact confirmations |
| 52 | +rtk git pull # Ultra-compact confirmations |
| 53 | +rtk git branch # Compact branch list |
| 54 | +rtk git fetch # Compact fetch |
| 55 | +rtk git stash # Compact stash |
| 56 | +rtk git worktree # Compact worktree |
| 57 | +``` |
| 58 | + |
| 59 | +Note: Git passthrough works for ALL subcommands, even those not explicitly listed. |
| 60 | + |
| 61 | +### GitHub (26-87% savings) |
| 62 | +```bash |
| 63 | +rtk gh pr view <num> # Compact PR view (87%) |
| 64 | +rtk gh pr checks # Compact PR checks (79%) |
| 65 | +rtk gh run list # Compact workflow runs (82%) |
| 66 | +rtk gh issue list # Compact issue list (80%) |
| 67 | +rtk gh api # Compact API responses (26%) |
| 68 | +``` |
| 69 | + |
| 70 | +### JavaScript/TypeScript Tooling (70-90% savings) |
| 71 | +```bash |
| 72 | +rtk pnpm list # Compact dependency tree (70%) |
| 73 | +rtk pnpm outdated # Compact outdated packages (80%) |
| 74 | +rtk pnpm install # Compact install output (90%) |
| 75 | +rtk npm run <script> # Compact npm script output |
| 76 | +rtk npx <cmd> # Compact npx command output |
| 77 | +rtk prisma # Prisma without ASCII art (88%) |
| 78 | +``` |
| 79 | + |
| 80 | +### Files & Search (60-75% savings) |
| 81 | +```bash |
| 82 | +rtk ls <path> # Tree format, compact (65%) |
| 83 | +rtk read <file> # Code reading with filtering (60%) |
| 84 | +rtk grep <pattern> # Search grouped by file (75%). Format flags (-c, -l, -L, -o, -Z) run raw. |
| 85 | +rtk find <pattern> # Find grouped by directory (70%) |
| 86 | +``` |
| 87 | + |
| 88 | +### Analysis & Debug (70-90% savings) |
| 89 | +```bash |
| 90 | +rtk err <cmd> # Filter errors only from any command |
| 91 | +rtk log <file> # Deduplicated logs with counts |
| 92 | +rtk json <file> # JSON structure without values |
| 93 | +rtk deps # Dependency overview |
| 94 | +rtk env # Environment variables compact |
| 95 | +rtk summary <cmd> # Smart summary of command output |
| 96 | +rtk diff # Ultra-compact diffs |
| 97 | +``` |
| 98 | + |
| 99 | +### Infrastructure (85% savings) |
| 100 | +```bash |
| 101 | +rtk docker ps # Compact container list |
| 102 | +rtk docker images # Compact image list |
| 103 | +rtk docker logs <c> # Deduplicated logs |
| 104 | +rtk kubectl get # Compact resource list |
| 105 | +rtk kubectl logs # Deduplicated pod logs |
| 106 | +``` |
| 107 | + |
| 108 | +### Network (65-70% savings) |
| 109 | +```bash |
| 110 | +rtk curl <url> # Compact HTTP responses (70%) |
| 111 | +rtk wget <url> # Compact download output (65%) |
| 112 | +``` |
| 113 | + |
| 114 | +### Meta Commands |
| 115 | +```bash |
| 116 | +rtk gain # View token savings statistics |
| 117 | +rtk gain --history # View command history with savings |
| 118 | +rtk discover # Analyze Claude Code sessions for missed RTK usage |
| 119 | +rtk proxy <cmd> # Run command without filtering (for debugging) |
| 120 | +rtk init # Add RTK instructions to CLAUDE.md |
| 121 | +rtk init --global # Add RTK to ~/.claude/CLAUDE.md |
| 122 | +``` |
| 123 | + |
| 124 | +## Token Savings Overview |
| 125 | + |
| 126 | +| Category | Commands | Typical Savings | |
| 127 | +|----------|----------|-----------------| |
| 128 | +| Tests | vitest, playwright, cargo test | 90-99% | |
| 129 | +| Build | next, tsc, lint, prettier | 70-87% | |
| 130 | +| Git | status, log, diff, add, commit | 59-80% | |
| 131 | +| GitHub | gh pr, gh run, gh issue | 26-87% | |
| 132 | +| Package Managers | pnpm, npm, npx | 70-90% | |
| 133 | +| Files | ls, read, grep, find | 60-75% | |
| 134 | +| Infrastructure | docker, kubectl | 85% | |
| 135 | +| Network | curl, wget | 65-70% | |
| 136 | + |
| 137 | +Overall average: **60-90% token reduction** on common development operations. |
| 138 | +<!-- /rtk-instructions --> |
0 commit comments