Watch Pr
Monitor the CI status of the current branch's Pull Request. Poll until all checks pass or fail, then report and act.
# /watch-pr
Monitor the CI status of the current branch's Pull Request. Poll until all checks pass or fail, then report and act.
---
## What to do
### Step 1 — Find the PR
```bash
gh pr view --json number,url,state,title,headRefName
If no PR exists for the current branch, tell the user and offer to create one (/create-pr).
Step 1.5 — Check for merge conflicts
gh pr view --json mergeable,mergeStateStatus
If mergeable is CONFLICTING:
git fetch origin main && git merge origin/main- Resolve conflicts:
- For source files:
Edit, keeping the feature branch's change unless main introduced a structural update. - For
pnpm-lock.yaml:git checkout --theirs pnpm-lock.yaml && pnpm install --no-frozen-lockfile
- For source files:
- Commit the merge:
git commit -m "chore(merge): merge main into <branch>" - Push — CI re-triggers.
- Continue to Step 2.
If mergeable is MERGEABLE or UNKNOWN: proceed to Step 2.
Step 2 — Poll CI checks
gh pr checks --watch --interval 30
While waiting, also check mergeability between iterations:
gh pr view --json mergeable,mergeStateStatus
If mergeable becomes CONFLICTING, stop and resolve as in Step 1.5.
Step 3 — Interpret the final result
gh pr checks
gh pr view --json mergeable,mergeStateStatus
If all checks pass AND mergeable is MERGEABLE: proceed to Step 3.5.
If any CI check fails:
- Show which check failed and the error:
gh run view <run-id> --log-failed - Diagnose the root cause from the log.
- Fix it in the code.
- Commit on the same branch — push re-triggers CI.
- Re-run
/watch-pr.
Step 3.5 — Resolve outstanding review comments
gh api repos/OWNER/REPO/pulls/PR_NUMBER/reviews
gh api repos/OWNER/REPO/pulls/PR_NUMBER/comments
For each review with state: CHANGES_REQUESTED (skipping self-reviews):
- For each inline comment, read
pathandline, locate the referenced code, and apply the minimal fix that satisfies the request. If the comment is ambiguous, skip it and flag at the end. - For top-level review bodies, apply any actionable changes; skip if purely informational.
After applying:
git add <changed files>
git commit -m "fix(review): address PR review comments"
Push, then re-run /watch-pr from Step 2.
Step 4 — Done
When CI passes, the branch is mergeable, and there are no outstanding CHANGES_REQUESTED reviews:
"All CI checks passed and all review comments have been addressed — the PR is ready to merge."
Do not merge unless the user explicitly asks. ```
Maintain Watch Pr?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Watch Pr on getagentictools](https://getagentictools.com/loops/luisgrandegg-watch-pr?ref=badge)