← 返回
未分类 Key 中文

gh-cli

GitHub CLI for remote repository analysis, file fetching, codebase comparison, and discovering trending code/repos. Use when analyzing repos without cloning,...
GitHub CLI 用于远程仓库分析、文件获取、代码库比较及发现热门代码/仓库,适用于不克隆仓库时进行分析。
tenequm
未分类 clawhub v1.1.2 1 版本 100000 Key: 需要
★ 0
Stars
📥 559
下载
💾 5
安装
1
版本
#latest

概述

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 --template '{{.content | base64decode}}'

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
gh api repos/OWNER-B/REPO-B/contents/PATH

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

Step 2: Compare file lists

gh api repos/OWNER-A/REPO-A/contents/PATH -q '.[].name'
gh api repos/OWNER-B/REPO-B/contents/PATH -q '.[].name'

Compare the output of each command to identify 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 --template '{{.content | base64decode}}'
gh api repos/OWNER-B/REPO-B/contents/package.json --template '{{.content | base64decode}}'

Compare main entry points:

gh api repos/OWNER-A/REPO-A/contents/src/index.ts --template '{{.content | base64decode}}'
gh api repos/OWNER-B/REPO-B/contents/src/index.ts --template '{{.content | base64decode}}'

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

  • Official docs: https://cli.github.com/manual/
  • GitHub CLI: https://github.com/cli/cli
  • Search syntax: https://docs.github.com/en/search-github

版本历史

共 1 个版本

  • v1.1.2 当前
    2026-05-03 06:06 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

mcp-best-practices

tenequm
使用 TypeScript SDK(规格 2025-11-25,SDK v1.29 / v2 alpha)构建、保护并优化生产级 MCP 服务器。适用于构建或审查 MCP 服务器。
★ 0 📥 815

python-dev

tenequm
使用 uv + ty + ruff + pytest + just 的固执己见 Python 开发环境。适用于新建 Python 项目、配置 pyproject.toml、设置代码检查等场景。
★ 0 📥 734

x402-development

tenequm
使用x402开放协议构建互联网原生支付——HTTP 402 PaymentRequired,实现链上微支付,无需账户或API密钥。
★ 0 📥 648