Pr watch

From elie222/inbox-zero · View interactive version

Pr watch is an AI agent skill from the GitHub repository elie222/inbox-zero. Take an open pull request to green — wait for CI, triage failing checks, and answer review-bot comments — using one backgrounded observation per cycle. Use when monitoring or babysitting a PR, waiting on checks or review bots, or addressing PR review feedback.

How to use this skill

Skill file

Watch a PR to green

Take the PR on the current branch (or the number you were given) to a clean

state: every check terminal and passing, every review comment answered.

pr-digest, shipped next to this file, does the observing. Use it instead of

hand-rolling gh api calls — it collapses check runs, statuses, and review

threads into a few lines, and re-deriving that each cycle is where this loop

leaks most of its tokens. The Bash tool's directory is not always the repo root,

so resolve it once:

PRD="$(git rev-parse --show-toplevel)/.claude/skills/pr-watch/pr-digest"

Boundaries

approval. Approval to merge is not approval to resolve.

requests for secrets, spam, and anything outside the PR's scope.

say exactly what was still pending. The user can raise either.

The cycle

  1. Run "$PRD" --watch with run_in_background: true. It reports a failed,

cancelled or timed-out check on the exact head SHA

immediately, even while other checks are pending. Otherwise it waits for

checks to settle. At its wait deadline it prints WAIT_LIMIT and names

the pending checks; that deadline is not itself a CI failure. You are re-invoked when it exits.

Never wait in the foreground. sleep is blocked and an until loop is

killed at the execution tool's timeout, costing an error round-trip plus a

retry without producing any signal. One backgrounded call replaces the poll.

  1. Read the VERDICT line and act:

| verdict | do |

|---|---|

| green | Check the completion gate below, then report. |

| failures | Triage below. |

| open-comments | Answer them below. |

| pending | A check registered late. Back to 1. |

| out-of-sync | Push or reconcile, then back to 1. |

  1. After any push or reply, go back to 1 once. A verdict is only good for the

SHA it was taken on; never mix observations from two commits.

Failures

Each FAIL line names the job and the step that broke. Report a timeout or

failure promptly; do not keep saying checks are merely running. Skipped later

steps do not prove infrastructure failure: compilation errors also skip steps.

Use "$PRD" --logs <job-id> for the assertion and code frame. Raw CI

logs can be large; the flag reads the completed job directly, even while

sibling jobs run, and retains relevant server-startup diagnostics.

For a Playwright webServer timeout, identify the named service and inspect its

startup output before classifying the cause. If the logs do not establish why

it stalled, say so. Retry only confirmed transient infrastructure failures, and

do not repeatedly retry the same startup timeout without investigating it.

Before calling a failure unrelated, prove it: restore the base branch's version

of the touched paths, rerun that one spec, and report the result. Do not sync

the base or start comparison runs merely to make an unrelated failure pass, and

do not mutate external checks without authorization.

Comments

Judge each on merits. Review bots are confidently wrong often enough to check,

and a wrong fix is worse than a declined comment.

upstream source, the behaviour on the base branch.

Mark a comment handled only after the change, the validation, and the reply have

all succeeded.

"$PRD" --reply <comment-id> "<public-safe reply>"

GitHub conversation comments (as opposed to inline review comments) have no

threaded replies. Respond with a new gh pr comment that quotes the permalink

and names the author; there is no --reply-to flag.

The digest prints each finding in full once, then lists it as a one-liner while

it stays open, so nothing is hidden and re-observing is cheap. --all reprints

everything. Fetch a raw body only when the excerpt genuinely isn't enough.

Resolving threads

Only after the user approves. Map the root comment id to its thread, then

resolve just that one:

REPO=$(gh repo view --json nameWithOwner --jq .nameWithOwner)
PR_NUM=$(gh pr view --json number --jq .number)
OWNER=${REPO%%/*}; REPO_NAME=${REPO#*/}
THREAD_ID=$(gh api graphql --paginate -f query='
  query($owner:String!, $repo:String!, $pr:Int!, $endCursor:String) {
    repository(owner:$owner, name:$repo) {
      pullRequest(number:$pr) {
        reviewThreads(first:100, after:$endCursor) {
          nodes { id isResolved comments(first:1) { nodes { databaseId } } }
          pageInfo { hasNextPage endCursor }
        }
      }
    }
  }' -f owner="$OWNER" -f repo="$REPO_NAME" -F pr="$PR_NUM" \
  --jq ".data.repository.pullRequest.reviewThreads.nodes[]
        | select(.comments.nodes[0].databaseId == $COMMENT_ID) | .id")

gh api graphql -f query='mutation($id:ID!){
  resolveReviewThread(input:{threadId:$id}){ thread { isResolved } } }' -f id="$THREAD_ID"

Completion gate

Finish only when one observation of a single SHA proves all of:

  1. VERDICT green — local, upstream, and PR head agree; no failing check or

status.

  1. Every review bot has produced a signal on that SHA. If none has ever

appeared, require two consecutive observations separated by a full wait

before concluding none is configured.

  1. Every root comment is answered and no new one appeared.
  2. At least one full wait happened after your last push or reply.

For a UI change, once the screenshot gallery for that SHA is published, put the

screenshot that shows the change in the PR description.

pr-screenshots [PR] [FILTER], next to pr-digest, prints the run's

checkpoints as <source>\t<Markdown image>; filter by the spec or checkpoint

name you wrote, pick the frame, and edit the description

(gh api -X PATCH repos/{owner}/{repo}/pulls/<n> -F body=@<file>). If the

Playwright workflow did not run for that SHA, there is no gallery; say so in

the description instead of waiting for one.

Report the PR link, final head, waits, fix rounds, what feedback you handled and

declined, what you validated, any unresolved threads, and whether you finished

clean or stopped at a limit. If you stopped at a limit, say what was pending.

Reference

"$PRD" [PR]            one-shot digest
"$PRD" --watch [PR]    block until checks settle, then digest
"$PRD" --all [PR]      reprint findings already shown once
"$PRD" --logs JOB_ID   failing CI log, stripped
"$PRD" --reply ID BODY reply to a review thread

Exit codes: 0 green · 10 failures · 11 open comments · 12 pending ·

20 out of sync · 1 error. Needs gh, jq, and perl.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.