How do I monitor a PR until green?
Table of Contents
This is the outer loop the PR Shepherd skill drives. The two
inner branches are addressing review comments and fixing failing
CI checks.
Question
How do I keep watching a PR after it has been opened, react to review comments and CI failures as they arrive, and stop when everything is green and resolved?
Answer
The preferred path is the pr-watch.sh background script, which
polls cheaply via gh and only invokes Claude when there is
actionable work. Fall back to the manual loop when the script is
not suitable.
Preferred: pr-watch.sh
Start the watcher immediately after the PR is opened. The script self-backgrounds, writes logs under
tmp/, and exits when CI is green and every review thread is resolved../build/scripts/pr-watch.sh <PR_NUMBER> ./build/scripts/pr-watch.sh <PR_NUMBER> --interval 10 # poll every 10 minutes
Follow progress:
tail -f tmp/pr-watch-<PR_NUMBER>.log
The script invokes
claude -pwith structured context when a CI check fails (logs included) or a new unresolved thread appears.
Manual fallback
When the script is unavailable, run the loop yourself:
Check CI immediately — never sleep through a known-broken build:
./compass.sh pr checks --watch
- All green or pending → step 2.
- Any failure → jump to fix CI failures first.
Wait the chosen interval (default 10 minutes is sensible — long enough for CI and reviewers, short enough to be responsive):
sleep 600
Fetch comments and act on each:
./compass.sh review list <PR_NUMBER>
For each open thread, follow address review comments.
Check CI again. The terminal states:
Outcome Action All green Loop exits — PR ready for review/merge. Pending Sleep, return to step 3. Any red Jump to fix CI failures, then return to step 2.
Script
./build/scripts/pr-watch.sh is the recommended driver. The manual
loop is bare gh + sleep.
Tested by
Manual. pr-watch.sh is exercised in normal day-to-day PR work.
See also
- How do I address PR review comments?
- How do I fix a failing CI check?
- How do I merge a PR?
PR Shepherd— the skill that drives this recipe autonomously.