Skip to main content

Overview

RTK provides token-optimized alternatives to GitHub CLI (gh) commands. Achieve 26-87% token savings through:
  • JSON parsing: Structured output from gh JSON 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

From src/gh_cmd.rs:filter_markdown_body():
Removes:
  • <!-- HTML comments -->
  • [![badge](url)](link) badge lines
  • ![image](url) image-only lines
  • --- / *** / ___ horizontal rules
  • Excessive blank lines (3+ → 2)
Preserves:
  • 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

From src/gh_cmd.rs, key functions:

JSON Parsing

Markdown Filtering Strategy

  1. Split by code blocks: Preserve ``` and ~~~ fenced blocks
  2. Filter non-code segments: Apply regex to remove noise
  3. Reassemble: Combine filtered text + preserved code blocks
  4. Final cleanup: Collapse excessive whitespace

Status Icons

Token Savings Summary

CI/CD Integration

All gh commands preserve exit codes:

Next Steps

File Operations

File listing, reading, and search

Git Commands

Git operation optimizations