Skip to main content

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 with rtk git:
rtk git status    # Compact status
rtk git log       # One-line commits
rtk git diff      # Stat + condensed diff
rtk git show      # Commit details
rtk git add       # Silent success
rtk git commit    # Commit hash only
rtk git push      # Branch confirmation
rtk git pull      # File change summary
rtk git branch    # Branch list
rtk git fetch     # Remote update summary
rtk git stash     # Stash operations
rtk git worktree  # Worktree management

rtk git status

Compact status with file counts and icons.

Examples

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   src/main.rs
        modified:   README.md

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        new_feature.rs

no changes added to commit (use "git add" and/or "git commit -a")
# 14 lines, ~300 tokens

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

rtk git log [options]

Examples

$ git log -n 5
commit abc1234567890abcdef1234567890abcdef12
Author: Jane Dev <[email protected]m>
Date:   Mon Jan 23 10:00:00 2024 -0800

    Add new feature for token optimization
    
    This commit implements the core filtering logic
    and adds tests for edge cases.

commit def4567890abcdef1234567890abcdef123456
...
# 40+ lines, ~500 tokens

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

From src/git.rs:run_log():
  • Executes git log --oneline by 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

rtk git diff [options] [files...]

Examples

$ git diff
diff --git a/src/main.rs b/src/main.rs
index 1234567..89abcde 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -42,7 +42,7 @@ fn main() {
-    let x = 5;
+    let x = 10;
...
# 50+ lines, ~2000 tokens

Options

--stat
flag
Show only stat summary (no diff)
--no-compact
flag
Disable RTK compacting, pass through raw diff
--cached
flag
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

$ git add .
# No output

$ git commit -m "Fix bug"
[main abc1234] Fix bug
 2 files changed, 10 insertions(+), 5 deletions(-)
 create mode 100644 new_file.rs

$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 342 bytes | 342.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To github.com:user/repo.git
   def4567..abc1234  main -> main
# 15+ lines, ~200 tokens

rtk git pull

File change summary instead of full output:
rtk git pull
ok 3 files +10 -2
Shows:
  • Files changed count
  • Lines added (+10)
  • Lines deleted (-2)

rtk git branch

Compact branch list with current indicator.
rtk git branch
* main
  feature/new-ui
  bugfix/fix-parser

rtk git stash

Stash operations with confirmations.

Examples

rtk git stash        # Stash changes
ok stash@{0}

rtk git stash list   # List stashes
stash@{0}: WIP on main: abc1234 Fix bug
stash@{1}: WIP on feature: def4567 Add feature

rtk git stash pop    # Pop stash
ok restored stash@{0}

rtk git worktree

Worktree management with compact output.
rtk git worktree list
/path/to/main    abc1234 [main]
/path/to/feature def4567 [feature/new-ui]

rtk git worktree add ../hotfix hotfix/bug
ok hotfix

Argument Handling

From src/git.rs, RTK uses Clap with:
  • trailing_var_arg = true: Accept arbitrary git flags
  • allow_hyphen_values = true: Support flags like --oneline, --cached
  • Auto-detection: Detects --merges to avoid conflicting with --no-merges

Example: Complex git log

rtk git log -n 10 --since="2 weeks ago" --author="Jane" --grep="fix"
# All flags passed through to git, output compacted

Exit Codes

Critical for CI/CD: RTK preserves git exit codes.
rtk git diff --exit-code  # Exits 1 if differences found
rtk git push              # Exits non-zero on push failure

CI/CD Example

# .github/workflows/ci.yml
- name: Check for uncommitted changes
  run: |
    rtk git diff --exit-code || (
      echo "Uncommitted changes detected"
      exit 1
    )

- name: Push changes
  run: rtk git push origin main

Global Options

RTK supports git global options:
rtk git -C /path/to/repo status     # Run in different directory
rtk git --git-dir=/path/.git status # Specify git directory
rtk git -c color.ui=false diff      # Set config option
From src/git.rs:git_cmd(), global options are prepended before subcommand arguments.

Token Savings Summary

CommandStandard TokensRTK TokensSavings
git status30050-83%
git log -n 10500100-80%
git diff2,000500-75%
git add05N/A
git commit4010-75%
git push20010-95%
git pull15015-90%

Implementation Reference

Key functions in src/git.rs:
  • run_status(): Parses status porcelain format
  • run_log(): Executes with --oneline, truncates output
  • run_diff(): Runs --stat first, then compact diff
  • run_commit(): Extracts commit hash from output
  • run_push()/run_pull(): Parses refs and file changes

Next Steps

Testing

Test runner optimizations (90% savings)

GitHub CLI

GitHub PR/issue management