Summary
Claude Code に PR レビューコメントへの返信と resolve を任せたい。
人間のコメントには絶対に触らせず、AI/bot コメントのみを対象にする。
スクリプト側に bot チェックを内蔵して、ルール違反を構造的に防ぐ。
Background
gh ネイティブ CLI では review thread への返信や resolve ができない
GraphQL API (addPullRequestReviewThreadReply, resolveReviewThread) を使う必要がある
__typename フィールドで Bot/User を判別可能(PR Add PreToolUse hook to block cd chaining #124 で動作確認済み)
現状 gh api * -f * が ask リストにあるため、GraphQL は全て都度確認が出る
Plan
1. スクリプト群 (bin/)
gh-pr-review-threads <owner/repo> <pr-number>
Read-only: PR の review thread 一覧を JSON で出力
各 thread の ID, isResolved, comments (author login, __typename, body) を含む
Permission: allow
gh-pr-thread-reply <owner/repo> <pr-number> <thread-id> <body>
Bot チェック内蔵: thread の最初のコメントが bot でなければ拒否 (exit 1)
Bot 判定: __typename == "Bot" OR login が known list に含まれる
Known list: github-actions[bot], dependabot[bot], copilot-pull-request-reviewer, renovate[bot] 等
GraphQL addPullRequestReviewThreadReply mutation で返信
Permission: allow (bot チェック済みのため)
gh-pr-thread-resolve <owner/repo> <pr-number> <thread-id>
Bot チェック内蔵: reply と同じロジック
GraphQL resolveReviewThread mutation で resolve
Permission: allow (bot チェック済みのため)
共通仕様
bot チェックロジックは関数として共有
set -eu, shellcheck pass
エラー時は理由を stderr に出力
2. ルールファイル (claude/rules/pr-review-response.md)
Bot コメント: gh-pr-thread-reply で返信 → gh-pr-thread-resolve で resolve
人間コメント: 内容をユーザーにサマリー報告するのみ。返信・resolve 禁止
gh api graphql を直接使って返信・resolve しない(スクリプト経由を強制)
3. claude/settings.json 変更
allow に追加:
Bash(gh-pr-review-threads *)
Bash(gh-pr-thread-reply *)
Bash(gh-pr-thread-resolve *)
ask に追加:
Bash(gh pr comment *) (top-level PR comment)
Verification
gh-pr-review-threads ikuwow/dotfiles 124 で JSON が返る
gh-pr-thread-reply に人間 thread ID → 拒否される
gh-pr-thread-reply に bot thread ID → 返信できる
shellcheck pass
settings.json valid JSON
Summary
Claude Code に PR レビューコメントへの返信と resolve を任せたい。
人間のコメントには絶対に触らせず、AI/bot コメントのみを対象にする。
スクリプト側に bot チェックを内蔵して、ルール違反を構造的に防ぐ。
Background
ghネイティブ CLI では review thread への返信や resolve ができないaddPullRequestReviewThreadReply,resolveReviewThread) を使う必要がある__typenameフィールドで Bot/User を判別可能(PR Add PreToolUse hook to block cd chaining #124 で動作確認済み)gh api * -f *が ask リストにあるため、GraphQL は全て都度確認が出るPlan
1. スクリプト群 (
bin/)gh-pr-review-threads <owner/repo> <pr-number>__typename, body) を含むgh-pr-thread-reply <owner/repo> <pr-number> <thread-id> <body>__typename == "Bot"OR login が known list に含まれるgithub-actions[bot],dependabot[bot],copilot-pull-request-reviewer,renovate[bot]等addPullRequestReviewThreadReplymutation で返信gh-pr-thread-resolve <owner/repo> <pr-number> <thread-id>resolveReviewThreadmutation で resolve共通仕様
set -eu, shellcheck pass2. ルールファイル (
claude/rules/pr-review-response.md)gh-pr-thread-replyで返信 →gh-pr-thread-resolveで resolvegh api graphqlを直接使って返信・resolve しない(スクリプト経由を強制)3.
claude/settings.json変更allow に追加:
Bash(gh-pr-review-threads *)Bash(gh-pr-thread-reply *)Bash(gh-pr-thread-resolve *)ask に追加:
Bash(gh pr comment *)(top-level PR comment)Verification
gh-pr-review-threads ikuwow/dotfiles 124で JSON が返るgh-pr-thread-replyに人間 thread ID → 拒否されるgh-pr-thread-replyに bot thread ID → 返信できる