Overview
RTK provides token-optimized alternatives to GitHub CLI (gh) commands. Achieve 26-87% token savings through:
- JSON parsing: Structured output from
ghJSON format - Markdown filtering: Strip badges, HTML comments, and noise
- Compact lists: Tabular format for PRs/issues
- Status summaries: CI check aggregation
Supported Commands
Pull Requests
List, view, create, merge PRs
Issues
List, view, create, comment on issues
Workflow Runs
View CI/CD run status
Repository
Repository info and stats
API
Direct GitHub API access
rtk gh pr
Pull request operations with compact views.rtk gh pr list
Compact PR listing.Examples
Features
- Status icons: ✓ (approved), ✗ (changes requested), ⏸ (in review)
- Labels: Show PR labels in brackets
- Author: Compact @username format
- Review state: Show review status
rtk gh pr view
Compact PR details with CI checks.Examples
Features
- Markdown filtering: Strips HTML comments, badges, horizontal rules
- Code block preservation: Keeps code blocks intact
- Checklist summary: Shows completion ratio
- CI aggregation: Groups check results
- Review state: Shows reviewer decisions
Markdown Filtering
Fromsrc/gh_cmd.rs:filter_markdown_body():
<!-- HTML comments -->[](link)badge linesimage-only lines---/***/___horizontal rules- Excessive blank lines (3+ → 2)
- Code blocks (``` fenced or ~~~ tildes)
- Regular markdown (headings, lists, links, bold, italic)
- Inline images/badges (mixed with text)
rtk gh pr create
Create PR with compact confirmation.rtk gh pr merge
Merge PR with compact confirmation.rtk gh pr checks
CI check status for PR.rtk gh issue
Issue operations with compact views.rtk gh issue list
Compact issue listing.rtk gh issue view
Compact issue details.rtk gh run
Workflow run status with compact output.rtk gh run list
Compact workflow run list.rtk gh run view
Compact workflow run details.rtk gh repo
Repository information.rtk gh repo view
Compact repository details.rtk gh api
Direct GitHub API access (passthrough with JSON formatting).Implementation Details
Fromsrc/gh_cmd.rs, key functions:
JSON Parsing
Markdown Filtering Strategy
- Split by code blocks: Preserve ``` and ~~~ fenced blocks
- Filter non-code segments: Apply regex to remove noise
- Reassemble: Combine filtered text + preserved code blocks
- Final cleanup: Collapse excessive whitespace
Status Icons
Token Savings Summary
| Command | Standard Tokens | RTK Tokens | Savings |
|---|---|---|---|
gh pr list (10 PRs) | 650 | 180 | -72% |
gh pr view (with body) | 800 | 200 | -75% |
gh pr checks (4 checks) | 200 | 50 | -75% |
gh issue list (10 issues) | 450 | 120 | -73% |
gh issue view (with body) | 350 | 90 | -74% |
gh run list (10 runs) | 500 | 120 | -76% |
gh run view (3 jobs) | 300 | 70 | -77% |
gh repo view (with README) | 1,200 | 80 | -93% |
CI/CD Integration
All gh commands preserve exit codes:Next Steps
File Operations
File listing, reading, and search
Git Commands
Git operation optimizations
