Fetch PR comments using the gh CLI
The "fix this with copilot" button on GitHub is great, but when you're already working on a branch locally sometimes you want to pass the review feedback to your agent directly.
If you use the gh CLI, you can install this by running gh extension install mheap/gh-pr-comments.
Once it's installed, run gh pr-comments <PR number> | pbcopy to get all of the comments ready to paste in to your agent.
Here's what it does under the hood:
bash#!/usr/bin/env bashset -euo pipefailif (( $# < 1 || $# > 2 )) || [[ ! ${1:-} =~ ^[0-9]+$ ]]; thenecho "Usage: gh pr-comments <PR number> [owner/repo]" >&2exit 1fipr="$1"repo="${2:-}"if [[ -z "$repo" ]]; thenrepo="$(gh repo view --json nameWithOwner --jq '.nameWithOwner')"figh api --paginate "repos/$repo/pulls/$pr/comments" | jq -c '.[] | {path, line, body}'