Community编程与开发github.com

GitHub

通过 `gh` CLI 操作 GitHub 问题、PR、CI/检查日志、评论、审查、发布、仓库及 API 查询。

GitHub 是什么?

该技能通过 `gh` 命令行工具提供完整的 GitHub 操作能力,涵盖 Pull Request 管理(创建、查看、合并、审查)、Issue 管理、CI 运行监控与等待、以及通用 API 查询。支持异步合并(Async Merge)并通过 Octopool 守卫头部确保安全性,提供智能的 CI 等待循环脚本以精确追踪推送提交的检查状态,避免竞态条件。技能包含详细的着陆/合并所有权逻辑:要求持续监控直到 PR 状态变为 `MERGED`,处理审查反馈、冲突和失败的检查,在权限不足或需要产品决策时报告精确阻塞原因。适用于 Claude Code、Cursor 等 AI 编码代理,在自动化工作流中可靠地完成 GitHub 操作。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/clawdbot/clawdbot/tree/main/skills/github

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

GitHub 是做什么的?

使用 gh 处理 GitHub 操作。使用 git 处理本地提交/分支/推送/拉取。使用代码阅读工具进行深度审查。

认证

git auth status
git auth login

Gateway HOME 可能不同于操作员 HOME。如果 gh 认证存在于其他位置,请在 gateway 服务环境中设置 GH_CONFIG_DIR 并重启。

PRs

git pr list --repo owner/repo --json number,title,state,author,url
git pr view 55 --repo owner/repo --json title,body,author,files,commits,reviews,reviewDecision
git pr checks 55 --repo owner/repo
git pr diff 55 --repo owner/repo
git pr create --repo owner/repo --title "feat: title" --body-file /tmp/pr.md

在创建或刷新 PR 正文时,仅当 Runtime 行提供了 sessionUrl=<exact-url> 时,才追加以下最终页脚。将 <sessionUrl> 替换为该确切的 URL;不要构造或修改它。sessionUrl 仅在明确公开的会话中提供。如果缺少该页脚,则省略它;切勿替换为私有聊天 URL 或启用共享以获取一个。在任何公开标记之前保留一个页脚,并保持页脚为最终内容:

---
[查看 OpenClaw 团队会话](https://raw.githubusercontent.com/clawdbot/clawdbot/main/<sessionUrl>)

URL 可直接使用:gh pr view https://github.com/owner/repo/pull/55。

异步合并

如果提供了仓库的原生着陆工作流,则使用它。对于其他地方经过授权的编程式合并,请通过 gh api 使用 GitHub 的异步合并 API;gh pr merge 不会选择此 API。提供已审查的头部 SHA,保留所需的审查/检查,并首先检查堆栈成员资格:提交一个堆叠 PR 也会合并或排队其打开的向下堆栈 PR,这些 PR 需要它们自己的审查和授权。

git api -H 'X-Octopool-Require: merge-async-v1' \
  --method PUT repos/owner/repo/pulls/55/merge-async \
  -H 'X-GitHub-Api-Version: 2026-03-10' \
  -f sha=REVIEWED_HEAD_SHA -f merge_method=squash -f merge_action=direct_merge
git api -H 'X-Octopool-Require: merge-async-v1' \
  repos/owner/repo/pulls/55/merge-async/REQUEST_UUID \
  -H 'X-GitHub-Api-Version: 2026-03-10' -H 'Cache-Control: max-age=0'

将 Octopool 守卫头部放在 api 之后的首位。受保护的旧版包装器会在它们重写合并权限之前拒绝它;如果被拒绝,请使用包含异步守卫的 Octopool 构建。支持的包装器保留 SHA/method/action/bypass,仅重写提交文本。原生 gh 可以传递该头部。不要删除它、禁用策略或选择原始二进制文件来绕过拒绝。

在轮询之前,从 202 响应中保留 details.uuid。pending 表示等待;merged 包含 details.sha,但仍需要最终的 PR/头部验证。enqueued 表示已排队,未合并:监视 PR 本身。为了遵守配置的队列,请使用 merge_action=default(或显式入队使用 merge_queue),省略仅限直接的方法/标题/消息字段。未经授权切勿启用 bypass_rules。

在 failed 时,报告 details.message。409 标识一个现有请求;在不重新提交的情况下检查其 UUID 和选项。丢失的回复、轮询错误以及 24 小时后的结果过期需要协调,切勿盲目重试或使用同步回退。使用有限等待和新鲜读取进行轮询。异步处理不会为未满足的检查启用自动合并;当该行为获得授权时,请使用原生工作流或 gh pr merge --auto。

着陆所有权

当用户要求着陆或合并 PR 时,最终结果是 PR 已验证的 GitHub 状态,而不是审查、工作轮次或 CI 观察的结束。

  • 保持作业活动状态,直到 gh pr view ... --json state,mergedAt,mergeCommit 证明 state 为 MERGED。
  • 将审查发现、合并冲突、失败的检查以及请求的更改视为范围之内的持续工作。修补它们,重新运行所需的门禁,并重新评估确切更新的头部。
  • 待定的检查是等待状态,而不是完成。使用仓库支持的等待或合并工作流;不要从部分绿色的检查中声称成功。
  • 如果工作已委托给持久会话,并且该运行在合并前停止,请继续同一会话,而不是将其报告视为最终结果。
  • 仅当继续需要新的权限、不可用的凭据或无法安全推断的产品决策时,才以阻塞状态停止。报告确切的阻塞原因并保持 PR 未合并。

Issues

git issue list --repo owner/repo --state open --json number,title,labels,url
git issue view 42 --repo owner/repo --json title,body,comments,labels,state
git issue create --repo owner/repo --title "Bug: ..." --body-file /tmp/issue.md
git issue comment 42 --repo owner/repo --body-file /tmp/comment.md
git issue close 42 --repo owner/repo --comment "Fixed in ..."

CI/runs

git run list --repo owner/repo --limit 10
git run view <run-id> --repo owner/repo --json status,conclusion,headSha,url
git run view <run-id> --repo owner/repo --log-failed
git run rerun <run-id> --repo owner/repo --failed

等待 CI

将下面的等待器作为单个后台 exec 运行(background: true,timeoutSeconds 高于预期的 CI 时间)。当其运行结果说明退出唤醒了此对话时,结束本轮:唤醒携带退出代码和输出尾部。否则,使用 process poll 收集它。不要为相同的检查启动第二个等待器。轮询循环和一次性自动化每次检查消耗一个模型轮次(#199122)。

固定您推送的提交。一个读取 PR 头部实况的等待器在推送后可能立即将旧头部视为已稳定并立即退出;gh pr checks --watch 存在此竞态(#199663)。

# Exit 0: every check passed. 1: a check failed. 11: the PR head moved. 12: no check ran.
# 2: GitHub API reads failed 5 times in a row.
pr=55 repo=owner/repo sha=$(git rev-parse HEAD) # the exact commit you pushed
seen=0 n=0 e=0
while :; do
  head=$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid)
  if [ "$head" = "$sha" ]; then
    seen=1
    if ! runs=$(gh api --paginate "repos/$repo/commits/$sha/check-runs" \
      --jq '.check_runs[] | "\(.status) \(.conclusion) \(.name)"') ||
      ! st=$(gh api "repos/$repo/commits/$sha/status" --jq 'select(.total_count > 0) | .state'); then
      e=$((e + 1)); [ "$e" -ge 5 ] && { echo "API-ERROR $sha"; exit 2; }
      n=$((n + 1)); sleep 30; continue
    fi
    e=0
    bad=$(printf '%s\n' "$runs" | grep -E '^completed (failure|timed_out|action_required|startup_failure) ')
    [ -n "$bad" ] && { echo "FAIL $sha"; echo "$bad"; exit 1; }
    case "$st" in failure | error) echo "FAIL $sha commit status: $st"; exit 1 ;; esac
    if [ "$st" != pending ] && { [ -z "$runs" ] ||
      ! printf '%s\n' "$runs" | grep -Eqv '^completed (success|skipped|neutral|cancelled) '; }; then
      { [ "$st" = success ] || printf '%s\n' "$runs" | grep -q '^completed success '; } &&
        { echo "PASS $sha"; exit 0; }
      [ "$n" -ge 4 ] && { echo "NO-RUN $sha"; exit 12; }
    fi
  elif [ -n "$head" ] && { [ "$seen" = 1 ] || [ "$n" -ge 4 ]; }; then
    echo "HEAD-MOVED expected=$sha actual=$head"; exit 11
  fi
  n=$((n + 1)); sleep 30
done

该循环给 GitHub 大约 2 分钟来显示新头部。它等待已排队、运行中和 stale 的运行,并忽略已取消的运行,因为并发组会取消被取代的运行。它还会读取提交状态,某些聚合门禁会使用这些状态。当没有运行成功时退出 12,例如每个运行都被跳过或没有运行启动,因为草稿 PR 会跳过 CI。对于一个已知的运行,gh run watch <run-id> --repo owner/repo --exit-status 在运行失败时退出非零。

API

git api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'
git api repos/owner/repo/labels --jq '.[].name'
git api --cache 1h repos/owner/repo --jq '{stars: .stargazers_count, forks: .forks_count}'

对于结构化输出,使用 --json + --jq。对于包含反引号、shell 片段、环境名称或用户文本的评论/正文,使用 --body-file。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

acp-router

Route plain-language requests for Claude Code, Cursor, Copilot, OpenClaw ACP, OpenCode, Gemini CLI, Grok Build, Qwen, Kiro, Kimi, iFlow, Factory Droid, Kilocode, or explicit ACP harness work into either OpenClaw ACP runtime sessions or direct acpx-driven sessions ("telephone game" flow). For coding-agent thread requests, read this skill first, then use only `sessions_spawn` for thread creation. Codex chat binding defaults to the native Codex app-server plugin unless ACP is explicit or background spawn needs ACP.

add-model-provider

Add and live-prove a model provider with non-interactive config one-liners, without exposing credentials.

agent-transcript

Requested GitHub PR/issue agent transcripts: redact, trim, preview, and insert safely.

apple-notes

Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.

apple-reminders

List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.

auto-qa

Run OpenClaw-wide autonomous QA and live/stress campaigns across independent subsystem lanes, with verified fixes and a resumable evidence report.

autoreview

Structured code review through the shared OpenClaw agent-skills installation.

bear-notes

Create, search, and manage Bear notes via grizzly CLI.

blacksmith-testbox

Run Blacksmith Testbox for CI-parity checks, secrets, hosted services, migrations, or builds local cannot reproduce.

block-kit

Use proactively for structured or interactive Slack replies, and when asked to author or validate native Slack Block Kit JSON.

blogwatcher

Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.

blucli

BluOS CLI (blu) for discovery, playback, grouping, and volume.

bluebubbles

Send and manage iMessages via BlueBubbles, including attachments, tapbacks, edits, replies, and groups.

browser-automation

Use when controlling web pages with the OpenClaw browser tool, especially multi-step flows, login checks, tab management, or recovery from stale refs/timeouts.

camsnap

Capture frames or clips from RTSP/ONVIF cameras and local webcams, including USB pan/tilt/zoom control.

canvas

Present HTML on connected OpenClaw node canvases, navigate/eval/snapshot, and debug canvas host URLs.

channel-message-flows

Use when running QA Lab channel message flow evidence.

clawdtributor

Clawtributor PRs here, last week or another window: discover conversation refs, recheck GitHub, rank by impact.

clawhub

Search ClawHub for plugins by default, or skills and agent Templates when requested; add Templates; install, verify, update, uninstall, publish, or sync skills.

相关技能