用途:该技能通过 gh CLI 与 GitHub 仓库、议题、PR 和 CI 交互,适合检查 PR 状态、评审或可合并性,查看 CI/工作流运行状态与日志,创建、关闭或评论议题,创建或合并拉取请求,查询 GitHub API 获取仓库数据,以及列出仓库、发布或协作者。
主要能力:gh pr 系列可列出、查看、检查 CI、创建与合并 PR;gh issue 系列可列出、创建、关闭议题;gh run 系列可列出近期运行、查看指定运行、仅查看失败步骤日志、重跑失败任务;gh api 可获取指定字段数据并用 --jq 过滤。多数命令支持 --json 结构化输出配合 --jq 筛选。
用法:一次性认证 gh auth login,验证 gh auth status。常用示例:gh pr list --repo owner/repo;gh pr checks 55 --repo owner/repo;gh pr view 55 --repo owner/repo;gh pr create --title "feat: add feature" --body "Description";gh pr merge 55 --squash --repo owner/repo;gh issue list --repo owner/repo --state open;gh issue create --title "Bug: something broken" --body "Details...";gh issue close 42 --repo owner/repo;gh run list --repo owner/repo --limit 10;gh run view <run-id> --repo owner/repo;gh run view <run-id> --repo owner/repo --log-failed;gh run rerun <run-id> --failed --repo owner/repo;gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login';gh api repos/owner/repo/labels --jq '.[].name';gh api repos/owner/repo --jq '{stars: .stargazers_count, forks: .forks_count}'。JSON 输出示例:gh pr list --json number,title,state,mergeable --jq '.[] | select(.mergeable == "MERGEABLE")'。
适用场景:需要在代理流程中远程查询或操作 GitHub 仓库状态、CI 结果与议题/PR 管理时使用。
限制:不适用于本地 git 操作(提交、推送、拉取、分支)应直接使用 git;不适用于非 GitHub 仓库(GitLab、Bitbucket、自托管)需用各自 CLI;克隆仓库应使用 git clone;审阅实际代码变更应直接读取文件。不在 git 目录时须指定 --repo owner/repo,可直接使用完整 URL,注意速率限制,重复查询可用 gh api --cache 1h。