Get the FREE Ultimate OpenClaw Setup Guide →

gh-cli

npx machina-cli add skill tenequm/claude-plugins/gh-cli --openclaw
Files (1)
SKILL.md
5.9 KB

GitHub CLI - Remote Analysis & Discovery

Remote repository operations, codebase comparison, and code discovery without cloning.

When to Use

  • Analyze repositories without cloning
  • Compare codebases side-by-side
  • Fetch specific files from any repo
  • Find trending repositories and code patterns
  • Search code across GitHub

Quick Operations

Fetch a file remotely

gh api repos/OWNER/REPO/contents/path/file.ts | jq -r '.content' | base64 -d

Get directory listing

gh api repos/OWNER/REPO/contents/PATH

Search code

gh search code "pattern" --language=typescript

Find trending repos

gh search repos --language=rust --sort stars --order desc

Compare Two Codebases

Systematic workflow for comparing repositories to identify similarities and differences.

Example use: "Compare solana-fm/explorer-kit and tenequm/solana-idls"

Step 1: Fetch directory structures

gh api repos/OWNER-A/REPO-A/contents/PATH > repo1.json
gh api repos/OWNER-B/REPO-B/contents/PATH > repo2.json

If comparing a monorepo package, specify the path (e.g., packages/explorerkit-idls).

Step 2: Compare file lists

jq -r '.[].name' repo1.json > repo1-files.txt
jq -r '.[].name' repo2.json > repo2-files.txt
diff repo1-files.txt repo2-files.txt

Shows files unique to each repo and common files.

Step 3: Fetch key files for comparison

Compare package dependencies:

gh api repos/OWNER-A/REPO-A/contents/package.json | jq -r '.content' | base64 -d > repo1-pkg.json
gh api repos/OWNER-B/REPO-B/contents/package.json | jq -r '.content' | base64 -d > repo2-pkg.json

Compare main entry points:

gh api repos/OWNER-A/REPO-A/contents/src/index.ts | jq -r '.content' | base64 -d > repo1-index.ts
gh api repos/OWNER-B/REPO-B/contents/src/index.ts | jq -r '.content' | base64 -d > repo2-index.ts

Step 4: Analyze differences

Compare the fetched files to identify:

API Surface

  • What functions/classes are exported?
  • Are the APIs similar or completely different?

Dependencies

  • Shared dependencies (same approach)
  • Different dependencies (different implementation)

Unique Features

  • Features only in repo1
  • Features only in repo2

For detailed comparison strategies, see references/comparison.md.

Discover Trending Content

Find trending repositories

# Most starred repos
gh search repos --sort stars --order desc --limit 20

# Trending in specific language
gh search repos --language=rust --sort stars --order desc

# Recently popular (created in last month)
gh search repos "created:>2024-10-01" --sort stars --order desc

# Trending in specific topic
gh search repos "topic:machine-learning" --sort stars --order desc

Discover popular code patterns

# Find popular implementations
gh search code "function useWallet" --language=typescript --sort indexed

# Find code in popular repos only
gh search code "implementation" "stars:>1000"

# Search specific organization
gh search code "authentication" --owner=anthropics

For complete discovery queries and patterns, see references/discovery.md.

Search Basics

Code search

# Search across all repositories
gh search code "API endpoint" --language=python

# Search in specific organization
gh search code "auth" --owner=anthropics

# Exclude results with negative qualifiers
gh search issues -- "bug report -label:wontfix"

Issue & PR search

# Find open bugs
gh search issues --label=bug --state=open

# Search assigned issues
gh search issues --assignee=@me --state=open

For advanced search syntax, see references/search.md.

Special Syntax

Field name inconsistencies

IMPORTANT: GitHub CLI uses inconsistent field names across commands:

Fieldgh repo viewgh search repos
StarsstargazerCountstargazersCount
ForksforkCountforksCount

Examples:

# ✅ Correct for gh repo view
gh repo view owner/repo --json stargazerCount,forkCount

# ✅ Correct for gh search repos
gh search repos "query" --json stargazersCount,forksCount

Excluding search results

When using negative qualifiers (like -label:bug), use -- to prevent the hyphen from being interpreted as a flag:

gh search issues -- "query -label:bug"

For more syntax gotchas, see references/syntax.md.

Advanced Workflows

For detailed documentation on specific workflows:

Core Workflows:

GitHub Operations:

Setup & Configuration:

Resources

Source

git clone https://github.com/tenequm/claude-plugins/blob/main/gh-cli/SKILL.mdView on GitHub

Overview

gh-cli lets you analyze remote GitHub repositories without cloning, compare codebases side-by-side, fetch individual files, and discover trending code and projects. This enables fast, risk-free exploration and informed decision-making for developers and researchers.

How This Skill Works

It uses GitHub's API via gh api to fetch repo contents, directory listings, and file contents. Output is decoded from base64 (with jq) for human reading, and code search/trending queries are performed with gh search. This enables remote analysis and comparison without a local clone.

When to Use It

  • Analyze repositories without cloning
  • Compare codebases side-by-side
  • Fetch specific files from any repo
  • Find trending repositories and code patterns
  • Search code across GitHub

Quick Start

  1. Step 1: Identify target repo and optional path
  2. Step 2: Fetch directory structures or specific files with gh api and decode as needed
  3. Step 3: Use diff/gh search queries to compare or discover patterns

Best Practices

  • Define target repos and paths before starting
  • Fetch directory structures to map repo layout
  • Diff file lists to spot differences and similarities
  • Decode and review key files (package.json, index.ts) for meaningful comparisons
  • Use language/topic filters to focus searches and discoveries

Example Use Cases

  • Compare solana-fm/explorer-kit and tenequm/solana-idls
  • Fetch remote package.json to review dependencies
  • List a repo's top-level directories to audit structure
  • Identify top Rust projects by stars for trend analysis
  • Search for 'function useWallet' in popular TypeScript repos

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers