Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rtk-ai/rtk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
RTK provides token-optimized alternatives to all common git operations. Achieve 75-92% token savings through:- Stat summaries: Show file counts instead of full diffs
- One-line confirmations: “ok ✓” for successful operations
- Compact diffs: Condensed change summaries
- Exit code preservation: Safe for CI/CD pipelines
Supported Commands
All git subcommands are prefixed withrtk git:
rtk git status
Compact status with file counts and icons.Examples
Features
- Branch indicator: Shows current branch
- File counts: Summary of changes
- Status icons:
M(modified),A(added),D(deleted),?(untracked) - Compact format: One line per file
rtk git log
One-line commit history with smart truncation.Usage
Examples
Supported Options
-n <count>: Limit number of commits--oneline: Already compact (passes through)--since <date>: Filter by date--author <name>: Filter by author--grep <pattern>: Search commit messages
Implementation Details
Fromsrc/git.rs:run_log():
- Executes
git log --onelineby default - Truncates to max lines (configurable)
- Preserves commit hashes for reference
- Strips ANSI color codes
rtk git diff
Stat summary first, then condensed diff.Usage
Examples
Options
Show only stat summary (no diff)
Disable RTK compacting, pass through raw diff
Show staged changes
Features
- Stat first: File change summary before diff
- Smart truncation: Shows context around changes
- Max lines: Configurable truncation (default 100 lines)
- Exit code preservation: Fails if diff fails
rtk git add/commit/push/pull
Ultra-compact confirmations for write operations.Examples
rtk git pull
File change summary instead of full output:- Files changed count
- Lines added (
+10) - Lines deleted (
-2)
rtk git branch
Compact branch list with current indicator.rtk git stash
Stash operations with confirmations.Examples
rtk git worktree
Worktree management with compact output.Argument Handling
Fromsrc/git.rs, RTK uses Clap with:
trailing_var_arg = true: Accept arbitrary git flagsallow_hyphen_values = true: Support flags like--oneline,--cached- Auto-detection: Detects
--mergesto avoid conflicting with--no-merges
Example: Complex git log
Exit Codes
Critical for CI/CD: RTK preserves git exit codes.CI/CD Example
Global Options
RTK supports git global options:src/git.rs:git_cmd(), global options are prepended before subcommand arguments.
Token Savings Summary
| Command | Standard Tokens | RTK Tokens | Savings |
|---|---|---|---|
git status | 300 | 50 | -83% |
git log -n 10 | 500 | 100 | -80% |
git diff | 2,000 | 500 | -75% |
git add | 0 | 5 | N/A |
git commit | 40 | 10 | -75% |
git push | 200 | 10 | -95% |
git pull | 150 | 15 | -90% |
Implementation Reference
Key functions insrc/git.rs:
run_status(): Parses status porcelain formatrun_log(): Executes with--oneline, truncates outputrun_diff(): Runs--statfirst, then compact diffrun_commit(): Extracts commit hash from outputrun_push()/run_pull(): Parses refs and file changes
Next Steps
Testing
Test runner optimizations (90% savings)
GitHub CLI
GitHub PR/issue management
