github

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub Skill

GitHub 技能

Use the
gh
CLI to interact with GitHub repositories, issues, PRs, and CI.
使用
gh
CLI与GitHub仓库、issue、PR、CI进行交互。

When to Use

适用场景

USE this skill when:
  • Checking PR status, reviews, or merge readiness
  • Viewing CI/workflow run status and logs
  • Creating, closing, or commenting on issues
  • Creating or merging pull requests
  • Querying GitHub API for repository data
  • Listing repos, releases, or collaborators
适用此技能的场景:
  • 检查PR状态、评审情况或合并就绪状态
  • 查看CI/工作流运行状态和日志
  • 创建、关闭issue或对issue发表评论
  • 创建或合并PR
  • 调用GitHub API查询仓库数据
  • 列出仓库、版本发布或协作者信息

When NOT to Use

不适用场景

DON'T use this skill when:
  • Local git operations (commit, push, pull, branch) → use
    git
    directly
  • Non-GitHub repos (GitLab, Bitbucket, self-hosted) → different CLIs
  • Cloning repositories → use
    git clone
  • Reviewing actual code changes → use
    coding-agent
    skill
  • Complex multi-file diffs → use
    coding-agent
    or read files directly
请勿在以下场景使用此技能:
  • 本地git操作(提交、推送、拉取、分支管理)→ 直接使用
    git
  • 非GitHub仓库(GitLab、Bitbucket、自托管仓库)→ 需使用对应CLI
  • 克隆仓库 → 使用
    git clone
  • 评审实际代码变更 → 使用
    coding-agent
    技能
  • 复杂多文件差异对比 → 使用
    coding-agent
    或直接读取文件

Setup

配置

bash
undefined
bash
undefined

Authenticate (one-time)

Authenticate (one-time)

gh auth login
gh auth login

Verify

Verify

gh auth status
undefined
gh auth status
undefined

Common Commands

常用命令

Pull Requests

PR

bash
undefined
bash
undefined

List PRs

List PRs

gh pr list --repo owner/repo
gh pr list --repo owner/repo

Check CI status

Check CI status

gh pr checks 55 --repo owner/repo
gh pr checks 55 --repo owner/repo

View PR details

View PR details

gh pr view 55 --repo owner/repo
gh pr view 55 --repo owner/repo

Create PR

Create PR

gh pr create --title "feat: add feature" --body "Description"
gh pr create --title "feat: add feature" --body "Description"

Merge PR

Merge PR

gh pr merge 55 --squash --repo owner/repo
undefined
gh pr merge 55 --squash --repo owner/repo
undefined

Issues

Issue

bash
undefined
bash
undefined

List issues

List issues

gh issue list --repo owner/repo --state open
gh issue list --repo owner/repo --state open

Create issue

Create issue

gh issue create --title "Bug: something broken" --body "Details..."
gh issue create --title "Bug: something broken" --body "Details..."

Close issue

Close issue

gh issue close 42 --repo owner/repo
undefined
gh issue close 42 --repo owner/repo
undefined

CI/Workflow Runs

CI/工作流运行

bash
undefined
bash
undefined

List recent runs

List recent runs

gh run list --repo owner/repo --limit 10
gh run list --repo owner/repo --limit 10

View specific run

View specific run

gh run view <run-id> --repo owner/repo
gh run view <run-id> --repo owner/repo

View failed step logs only

View failed step logs only

gh run view <run-id> --repo owner/repo --log-failed
gh run view <run-id> --repo owner/repo --log-failed

Re-run failed jobs

Re-run failed jobs

gh run rerun <run-id> --failed --repo owner/repo
undefined
gh run rerun <run-id> --failed --repo owner/repo
undefined

API Queries

API 查询

bash
undefined
bash
undefined

Get PR with specific fields

Get PR with specific fields

gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'
gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'

List all labels

List all labels

gh api repos/owner/repo/labels --jq '.[].name'
gh api repos/owner/repo/labels --jq '.[].name'

Get repo stats

Get repo stats

gh api repos/owner/repo --jq '{stars: .stargazers_count, forks: .forks_count}'
undefined
gh api repos/owner/repo --jq '{stars: .stargazers_count, forks: .forks_count}'
undefined

JSON Output

JSON 输出

Most commands support
--json
for structured output with
--jq
filtering:
bash
gh issue list --repo owner/repo --json number,title --jq '.[] | "\(.number): \(.title)"'
gh pr list --json number,title,state,mergeable --jq '.[] | select(.mergeable == "MERGEABLE")'
大多数命令支持
--json
参数配合
--jq
筛选来获取结构化输出:
bash
gh issue list --repo owner/repo --json number,title --jq '.[] | "\(.number): \(.title)"'
gh pr list --json number,title,state,mergeable --jq '.[] | select(.mergeable == "MERGEABLE")'

Templates

模板

PR Review Summary

PR 评审摘要

bash
undefined
bash
undefined

Get PR overview for review

Get PR overview for review

PR=55 REPO=owner/repo echo "## PR #$PR Summary" gh pr view $PR --repo $REPO --json title,body,author,additions,deletions,changedFiles
--jq '"(.title) by @(.author.login)\n\n(.body)\n\n📊 +(.additions) -(.deletions) across (.changedFiles) files"' gh pr checks $PR --repo $REPO
undefined
PR=55 REPO=owner/repo echo "## PR #$PR Summary" gh pr view $PR --repo $REPO --json title,body,author,additions,deletions,changedFiles
--jq '"(.title) by @(.author.login)\n\n(.body)\n\n📊 +(.additions) -(.deletions) across (.changedFiles) files"' gh pr checks $PR --repo $REPO
undefined

Issue Triage

Issue 分类处理

bash
undefined
bash
undefined

Quick issue triage view

Quick issue triage view

gh issue list --repo owner/repo --state open --json number,title,labels,createdAt
--jq '.[] | "[(.number)] (.title) - ([.labels[].name] | join(", ")) ((.createdAt[:10]))"'
undefined
gh issue list --repo owner/repo --state open --json number,title,labels,createdAt
--jq '.[] | "[(.number)] (.title) - ([.labels[].name] | join(", ")) ((.createdAt[:10]))"'
undefined

Notes

注意事项

  • Always specify
    --repo owner/repo
    when not in a git directory
  • Use URLs directly:
    gh pr view https://github.com/owner/repo/pull/55
  • Rate limits apply; use
    gh api --cache 1h
    for repeated queries
  • 不在git目录下操作时请始终指定
    --repo owner/repo
    参数
  • 支持直接使用URL:
    gh pr view https://github.com/owner/repo/pull/55
  • 存在接口速率限制,重复查询可使用
    gh api --cache 1h
    参数