tobihagemann/turbo / claude/skills/fetch-pr-comments
fetch-pr-comments
VerifiedFetch and summarize unresolved review threads and conversation on a GitHub PR without changing anything. Use when the user asks to "fetch PR comments" or "show unresolved threads".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.6 KB |
| scripts/fetch-pr-data.shexecutable | script | 4.5 KB |
scripts/fetch-pr-data.sh
View on GitHub#!/usr/bin/env bash
# Fetch all review threads, reviews, issue comments, and metadata for a GitHub PR.
# Emits a single merged JSON document on stdout:
# {
# "meta": { title, url, headRefName, baseRefName },
# "reviewThreads": [ ... ],
# "reviews": [ ... ],
# "issueComments": [ ... ] # PR conversation comments (non-review); author, body, createdAt, url
# }
#
# Paginates reviewThreads, reviews, and issue comments to avoid silent drops on long
# PRs. For any thread whose inner comments exceed the initial page, walks the
# remaining comments via node(id:) and merges them back into the thread.
#
# Fetched values go to jq on stdin, since a long PR overflows an argument.
#
# Usage: fetch-pr-data.sh <owner> <repo> <pr_number>
set -euo pipefail
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <owner> <repo> <pr_number>" >&2
exit 2
fi
owner="$1"
repo="$2"
pr="$3"
meta_query=$(cat <<'GRAPHQL'
query($owner: String!, $repo: String!, $pr: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) { title url headRefName baseRefName }
}
}
GRAPHQL
)
threads_query=$(cat <<'GRAPHQL'
query($owner: String!, $repo: String!, $pr: Int!, $endCursor: String) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
reviewThreads(first: 100, after: $endCursor) {
pageInfo { hasNextPage endCursor }
nodes {
id isResolved isOutdated
comments(first: 100) {
pageInfo { hasNextPage endCursor }
nodes { author { login } body path line originalLine diffHunk }
}
}
}
}
}
}
GRAPHQL
)
reviews_query=$(cat <<'GRAPHQL'
query($owner: String!, $repo: String!, $pr: Int!, $endCursor: String) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
reviews(first: 100, after: $endCursor) {
pageInfo { hasNextPage endCursor }
nodes { author { login } body state }
}
}
}
}
GRAPHQL
)
issue_comments_query=$(cat <<'GRAPHQL'
query($owner: String!, $repo: String!, $pr: Int!, $endCursor: String) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
comments(first: 100, after: $endCursor) {
pageInfo { hasNextPage endCursor }
nodes { author { login } body createdAt url }
}
}
}
}
GRAPHQL
)
thread_tail_query=$(cat <<'GRAPHQL'
query($thread_id: ID!, $cursor: String!) {
node(id: $thread_id) {
... on PullRequestReviewThread {
comments(first: 100, after: $cursor) {
pageInfo { hasNextPage endCursor }
nodes { author { login } body path line originalLine diffHunk }
}
}
}
}
GRAPHQL
)
meta=$(gh api graphql \
-f query="$meta_query" \
-f owner="$owner" -f repo="$repo" -F pr="$pr" \
--jq '.data.repository.pullRequest')
threads=$(gh api graphql --paginate \
-f query="$threads_query" \
-f owner="$owner" -f repo="$repo" -F pr="$pr" \
--jq '.data.repository.pullRequest.reviewThreads.nodes[]' \
| jq -s '.')
threads=$(jq -c '.[]' <<<"$threads" | while IFS= read -r thread; do
has_next=$(jq -r '.comments.pageInfo.hasNextPage' <<<"$thread")
if [ "$has_next" != "true" ]; then
printf '%s\n' "$thread"
continue
fi
thread_id=$(jq -r '.id' <<<"$thread")
cursor=$(jq -r '.comments.pageInfo.endCursor' <<<"$thread")
nodes=$(jq '.comments.nodes' <<<"$thread")
while [ "$has_next" = "true" ]; do
page=$(gh api graphql \
-f query="$thread_tail_query" \
-f thread_id="$thread_id" -f cursor="$cursor" \
--jq '.data.node.comments')
page_nodes=$(jq '.nodes' <<<"$page")
nodes=$(printf '%s\n' "$nodes" "$page_nodes" | jq -s '.[0] + .[1]')
has_next=$(jq -r '.pageInfo.hasNextPage' <<<"$page")
cursor=$(jq -r '.pageInfo.endCursor // ""' <<<"$page")
done
printf '%s\n' "$thread" "$nodes" | jq -s '
.[1] as $nodes
| .[0]
| .comments.nodes = $nodes
| .comments.pageInfo.hasNextPage = false
| .comments.pageInfo.endCursor = null
'
done | jq -s '.')
reviews=$(gh api graphql --paginate \
-f query="$reviews_query" \
-f owner="$owner" -f repo="$repo" -F pr="$pr" \
--jq '.data.repository.pullRequest.reviews.nodes[]' \
| jq -s '.')
issue_comments=$(gh api graphql --paginate \
-f query="$issue_comments_query" \
-f owner="$owner" -f repo="$repo" -F pr="$pr" \
--jq '.data.repository.pullRequest.comments.nodes[]' \
| jq -s '.')
printf '%s\n' "$meta" "$threads" "$reviews" "$issue_comments" \
| jq -s '{meta: .[0], reviewThreads: .[1], reviews: .[2], issueComments: .[3]}'
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| add-product-e2e-evalpaperclipai/paperclipAdd or extend a Paperclip full-stack runner E2E workflow, fixture, matcher, or report evidence path for local or Daytona execution. | Stars: 115k | Updated | Claude CodeCodex | Verified | Install |
| add-runner-evalpaperclipai/paperclipAdd or extend a Paperclip Runner protocol evaluation definition, roster, assertion, or report fixture with provenance and narrow validation. | Stars: 115k | Updated | Claude CodeCodex | Verified | Install |
| diagnose-why-work-stoppedpaperclipai/paperclipCompatibility entry point for failed, stalled, looping, or over-recovered Paperclip work. Use fix-failed-paperclip-run for the full diagnosis, regression, repair, real verification, and green-PR workflow; honor an explicitly requested diagnosis-only scope. | Stars: 115k | Updated | Claude CodeCodex | Verified | Install |
| fix-failed-paperclip-runpaperclipai/paperclipDiagnose and fix failed, stuck, slow, or incorrectly blocked Paperclip tasks and runs. Use with a task/run URL or failure report to trace the root cause, prove a regression red then green, check second-order effects, verify the real workflow, and deliver a PR with passing checks. | Stars: 115k | Updated | Claude CodeCodex | Verified | Install |