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

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

Examples

Options

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

rtk git pull

File change summary instead of full output:
Shows:
  • 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

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

Exit Codes

Critical for CI/CD: RTK preserves git exit codes.

CI/CD Example

Global Options

RTK supports git global options:
From src/git.rs:git_cmd(), global options are prepended before subcommand arguments.

Token Savings Summary

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