|
| 1 | +--- |
| 2 | +name: check-pr |
| 3 | +description: > |
| 4 | + Check a single PR's CI status, review comments, and requested changes. |
| 5 | + Fix actionable failures and address feedback. "check PR 1234", "what's |
| 6 | + the status of my PR", "address review comments on #500". |
| 7 | +argument-hint: "<pr-number>" |
| 8 | +context: fork |
| 9 | +--- |
| 10 | + |
| 11 | +# Check PR |
| 12 | + |
| 13 | +Do one pass over PR **$ARGUMENTS**: check CI, read reviews, fix what's |
| 14 | +actionable, report status. |
| 15 | + |
| 16 | +## 1. Gather PR state |
| 17 | + |
| 18 | +```bash |
| 19 | +# Overall state |
| 20 | +gh pr view $ARGUMENTS --repo docker/docs --json state,title,url,headRefName |
| 21 | + |
| 22 | +# CI checks |
| 23 | +gh pr checks $ARGUMENTS --repo docker/docs --json name,state,detailsUrl |
| 24 | + |
| 25 | +# Top-level reviews |
| 26 | +gh pr view $ARGUMENTS --repo docker/docs --json reviews,reviewDecision |
| 27 | + |
| 28 | +# Inline (line-level) comments — NOT included in the above |
| 29 | +gh api repos/docker/docs/pulls/$ARGUMENTS/comments \ |
| 30 | + --jq '[.[] | {id: .id, author: .user.login, body: .body, path: .path, line: .line}]' |
| 31 | +``` |
| 32 | + |
| 33 | +Always check both the reviews endpoint and the inline comments endpoint. |
| 34 | +A review with an empty body may still have line-level comments requiring |
| 35 | +action. |
| 36 | + |
| 37 | +## 2. If merged |
| 38 | + |
| 39 | +Report the final state. Then check for any unanswered review comments (both |
| 40 | +top-level and inline) and reply to each one explaining what was done or that |
| 41 | +the issue was addressed in a follow-up. Skip to step 6 after. |
| 42 | + |
| 43 | +## 3. If closed without merge |
| 44 | + |
| 45 | +Read the closing context to understand why: |
| 46 | + |
| 47 | +```bash |
| 48 | +gh pr view $ARGUMENTS --repo docker/docs --json closedAt,comments \ |
| 49 | + --jq '{closedAt, lastComment: .comments[-1].body}' |
| 50 | +``` |
| 51 | + |
| 52 | +Report the reason. Common causes: rejected by maintainers, superseded by |
| 53 | +another PR, closed by automation. |
| 54 | + |
| 55 | +## 4. If CI is failing |
| 56 | + |
| 57 | +- Read the failure details (follow `detailsUrl` if needed) |
| 58 | +- Determine if the failure is in the PR's changed files or pre-existing |
| 59 | +- **Actionable:** check out the branch, fix, commit, push |
| 60 | + ```bash |
| 61 | + git checkout <branch> |
| 62 | + # fix the issue |
| 63 | + git add <files> |
| 64 | + git commit -m "fix: <description>" |
| 65 | + git push |
| 66 | + ``` |
| 67 | +- **Pre-existing / upstream:** note it, do not block |
| 68 | + |
| 69 | +## 5. If review comments or changes requested |
| 70 | + |
| 71 | +- Read each unresolved comment |
| 72 | +- Address feedback in a follow-up commit |
| 73 | +- Push, then reply to each comment explaining what was done: |
| 74 | + ```bash |
| 75 | + gh api repos/docker/docs/pulls/$ARGUMENTS/comments \ |
| 76 | + --method POST \ |
| 77 | + --field in_reply_to=<comment-id> \ |
| 78 | + --field body="<response>" |
| 79 | + ``` |
| 80 | +- End every comment reply with a `Generated by [Claude Code](https://claude.com/claude-code)` footer |
| 81 | +- Resolve each thread via GraphQL after replying: |
| 82 | + ```bash |
| 83 | + # Get thread IDs |
| 84 | + gh api graphql -f query=' |
| 85 | + query($owner:String!, $repo:String!, $pr:Int!) { |
| 86 | + repository(owner:$owner, name:$repo) { |
| 87 | + pullRequest(number:$pr) { |
| 88 | + reviewThreads(first:50) { |
| 89 | + nodes { id isResolved comments(first:1) { nodes { path } } } |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + }' -f owner=docker -f repo=docs -F pr=$ARGUMENTS \ |
| 94 | + --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | {id, path: .comments.nodes[0].path}' |
| 95 | + |
| 96 | + # Resolve a thread |
| 97 | + gh api graphql -f query=' |
| 98 | + mutation($id:ID!) { resolveReviewThread(input:{threadId:$id}) { thread { isResolved } } } |
| 99 | + ' -f id=<thread-id> |
| 100 | + ``` |
| 101 | +- Re-request review if changes were requested |
| 102 | + |
| 103 | +## 6. Report |
| 104 | + |
| 105 | +``` |
| 106 | +## PR #$ARGUMENTS: <title> |
| 107 | +
|
| 108 | +**State:** <open|merged|closed> |
| 109 | +**CI:** <passing|failing|pending> |
| 110 | +**Review:** <approved|changes requested|pending> |
| 111 | +**Action taken:** <what was done, or "none needed"> |
| 112 | +``` |
0 commit comments