Agent skill

github-pr-review-operation

GitHub Pull Requestのレビュー操作を行うスキル。PR情報取得、差分確認、コメント取得・投稿、インラインコメント、コメント返信をghコマンドで実行する。PRレビュー、コードレビュー、PR操作が必要な時に使用。

Stars 15
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/sushichan044/dotfiles/tree/main/.agents/skills/github-pr-review-operation

SKILL.md

GitHub PR Review Operation

GitHub CLI (gh) を使ったPRレビュー操作。

前提条件

  • gh インストール済み
  • gh auth login で認証済み

PR URLのパース

PR URL https://github.com/OWNER/REPO/pull/NUMBER から以下を抽出して使用:

  • OWNER: リポジトリオーナー
  • REPO: リポジトリ名
  • NUMBER: PR番号

特に PR が指示されなかった場合や、この PR などの指示語が与えられた場合

gh pr view --json url --jq .url 2>/dev/null || echo "No PR found for current branch" を実行して、現在のブランチに関連するPR URLを取得し、パースして使用する。

操作一覧

1. PR情報取得

bash
gh pr view NUMBER --repo OWNER/REPO --json title,body,author,state,baseRefName,headRefName,url

2. 差分取得(行番号付き)

bash
gh pr diff NUMBER --repo OWNER/REPO | awk '
/^@@/ {
  match($0, /-([0-9]+)/, old)
  match($0, /\+([0-9]+)/, new)
  old_line = old[1]
  new_line = new[1]
  print $0
  next
}
/^-/ { printf "L%-4d     | %s\n", old_line++, $0; next }
/^\+/ { printf "     R%-4d| %s\n", new_line++, $0; next }
/^ / { printf "L%-4d R%-4d| %s\n", old_line++, new_line++, $0; next }
{ print }
'

出力例:

@@ -46,15 +46,25 @@ jobs:
L46   R46  |            prompt: |
L49       | -            (削除行)
     R49  | +            (追加行)
L50   R50  |              # レビューガイドライン
  • L数字: LEFT(base)側の行番号 → インラインコメントでside=LEFTに使用
  • R数字: RIGHT(head)側の行番号 → インラインコメントでside=RIGHTに使用

3. コメント取得

Issue Comments(PR全体へのコメント):

bash
gh api repos/OWNER/REPO/issues/NUMBER/comments --jq '.[] | {id, user: .user.login, created_at, body}'

Review Comments(コード行へのコメント):

bash
gh api repos/OWNER/REPO/pulls/NUMBER/comments --jq '.[] | {id, user: .user.login, path, line, created_at, body, in_reply_to_id}'

4. PRにコメント

bash
gh pr comment NUMBER --repo OWNER/REPO --body "コメント内容"

5. インラインコメント(コード行指定)

まずhead commit SHAを取得:

bash
gh api repos/OWNER/REPO/pulls/NUMBER --jq '.head.sha'

単一行コメント:

bash
gh api repos/OWNER/REPO/pulls/NUMBER/comments \
  --method POST \
  -f body="コメント内容" \
  -f commit_id="COMMIT_SHA" \
  -f path="src/example.py" \
  -F line=15 \
  -f side=RIGHT

複数行コメント(10〜15行目):

bash
gh api repos/OWNER/REPO/pulls/NUMBER/comments \
  --method POST \
  -f body="コメント内容" \
  -f commit_id="COMMIT_SHA" \
  -f path="src/example.py" \
  -F line=15 \
  -f side=RIGHT \
  -F start_line=10 \
  -f start_side=RIGHT

注意点:

  • -F (大文字): 数値パラメータ(line, start_line)に使用。-fだと文字列になりエラーになる
  • side: RIGHT(追加行)または LEFT(削除行)

6. コメントへ返信

bash
gh api repos/OWNER/REPO/pulls/NUMBER/comments/COMMENT_ID/replies \
  --method POST \
  -f body="返信内容"

COMMENT_IDはコメント取得で得たidを使用。

Expand your agent's capabilities with these related and highly-rated skills.

sushichan044/dotfiles

terraform-style-guide

Generate Terraform HCL code following HashiCorp's official style conventions and best practices. Use when writing, reviewing, or generating Terraform configurations.

15 0
Explore
sushichan044/dotfiles

fix-github-actions-ci

GitHub Actions CI の失敗を調査して修正するためのスキルです。CI ログを分析して失敗箇所・原因を特定し、そのまま修正作業まで行います。

15 0
Explore
sushichan044/dotfiles

dd-logs

Log management - search, pipelines, archives, and cost control.

15 0
Explore
sushichan044/dotfiles

golang-safety

Defensive Golang coding to prevent panics, silent data corruption, and subtle runtime bugs. Use whenever writing or reviewing Go code that involves nil-prone types (pointers, interfaces, maps, slices, channels), numeric conversions, resource lifecycle (defer in loops), or defensive copying. Also triggers on questions about nil panics, append aliasing, map concurrent access, float comparison, or zero-value design.

15 0
Explore
sushichan044/dotfiles

resolve-merge-conflict

現在の branch を分岐元の最新に rebase するときに使う。まず rebase を実行し、止まった conflict を順番に解消して前に進める。長い事前調査を避けて、必要な file だけ見て片付けたいときに使う。

15 0
Explore
sushichan044/dotfiles

golang-data-structures

Golang data structures — slices (internals, capacity growth, preallocation, slices package), maps (internals, hash buckets, maps package), arrays, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections, pointers (unsafe.Pointer, weak.Pointer), and copy semantics. Use when choosing or optimizing Go data structures, implementing generic containers, using container/ packages, unsafe or weak pointers, or questioning slice/map internals.

15 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results