github
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Skill
GitHub 技能
Use the CLI to interact with GitHub repositories, issues, PRs, and CI.
gh使用 CLI与GitHub仓库、issue、PR、CI进行交互。
ghWhen 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 directly
git - Non-GitHub repos (GitLab, Bitbucket, self-hosted) → different CLIs
- Cloning repositories → use
git clone - Reviewing actual code changes → use skill
coding-agent - Complex multi-file diffs → use or read files directly
coding-agent
❌ 请勿在以下场景使用此技能:
- 本地git操作(提交、推送、拉取、分支管理)→ 直接使用
git - 非GitHub仓库(GitLab、Bitbucket、自托管仓库)→ 需使用对应CLI
- 克隆仓库 → 使用
git clone - 评审实际代码变更 → 使用技能
coding-agent - 复杂多文件差异对比 → 使用或直接读取文件
coding-agent
Setup
配置
bash
undefinedbash
undefinedAuthenticate (one-time)
Authenticate (one-time)
gh auth login
gh auth login
Verify
Verify
gh auth status
undefinedgh auth status
undefinedCommon Commands
常用命令
Pull Requests
PR
bash
undefinedbash
undefinedList 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
undefinedgh pr merge 55 --squash --repo owner/repo
undefinedIssues
Issue
bash
undefinedbash
undefinedList 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
undefinedgh issue close 42 --repo owner/repo
undefinedCI/Workflow Runs
CI/工作流运行
bash
undefinedbash
undefinedList 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
undefinedgh run rerun <run-id> --failed --repo owner/repo
undefinedAPI Queries
API 查询
bash
undefinedbash
undefinedGet 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}'
undefinedgh api repos/owner/repo --jq '{stars: .stargazers_count, forks: .forks_count}'
undefinedJSON Output
JSON 输出
Most commands support for structured output with filtering:
--json--jqbash
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--jqbash
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
undefinedbash
undefinedGet 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
--jq '"(.title) by @(.author.login)\n\n(.body)\n\n📊 +(.additions) -(.deletions) across (.changedFiles) files"' gh pr checks $PR --repo $REPO
undefinedPR=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
--jq '"(.title) by @(.author.login)\n\n(.body)\n\n📊 +(.additions) -(.deletions) across (.changedFiles) files"' gh pr checks $PR --repo $REPO
undefinedIssue Triage
Issue 分类处理
bash
undefinedbash
undefinedQuick 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]))"'
--jq '.[] | "[(.number)] (.title) - ([.labels[].name] | join(", ")) ((.createdAt[:10]))"'
undefinedgh issue list --repo owner/repo --state open --json number,title,labels,createdAt
--jq '.[] | "[(.number)] (.title) - ([.labels[].name] | join(", ")) ((.createdAt[:10]))"'
--jq '.[] | "[(.number)] (.title) - ([.labels[].name] | join(", ")) ((.createdAt[:10]))"'
undefinedNotes
注意事项
- Always specify when not in a git directory
--repo owner/repo - Use URLs directly:
gh pr view https://github.com/owner/repo/pull/55 - Rate limits apply; use for repeated queries
gh api --cache 1h
- 不在git目录下操作时请始终指定参数
--repo owner/repo - 支持直接使用URL:
gh pr view https://github.com/owner/repo/pull/55 - 存在接口速率限制,重复查询可使用参数
gh api --cache 1h