Babysit PR
Monitor PR $ARGUMENTS: fix CI failures and review feedback, one batched push
at a time, until the PR is clean. With no number, find it from the branch:
gh pr list --head "$(git branch --show-current)" --state open --json number --limit 1
Ownership, who may push or comment, the merge gate, cadence, and the Codex
goal and heartbeat all live in ship. Under /ship this is a step inside it:
keep going through the merge. Standalone, stop after 30 minutes of green
GitHub Actions and no new feedback, and merge only if the user asks. On a
factory PR, each watcher prompt is one tick, the watcher pushes and merges,
and the round skips the login check below:
see factory-run/references/babysit-round.md.
Each tick
Refresh and read the live PR:
git fetch origin --quiet
gh api user --jq .login
gh pr view $ARGUMENTS --json state,mergedAt,author,headRepository,headRefName,headRefOid,baseRefName,mergeable,mergeCommit
If author.login isn't your login, don't push, comment, or merge unless
the user named this PR and that action. Closed without a merge ends the
work; report it as unsuccessful. Merged
under /ship continues with its post-merge step. If the query fails, retry
on the next tick instead of acting on old data.
Read all review comments, every tick, until the moment you merge. Review
bots re-review on every push and post a new round each time. Never filter
by a "since " window: it hides rounds posted before your last
reply, and "0 new" reads as "all addressed" (this left two rounds
unanswered on PR #1097). Use reply state instead. Run both queries below
with set -o pipefail. If either fails, the PR is not clean: retry next
tick, and never read empty output from a failed call as "no feedback". This
lists every top-level comment with no reply:
gh api --paginate repos/{owner}/{repo}/pulls/$ARGUMENTS/comments --jq '.[]' \
| jq -s '
([ .[] | .in_reply_to_id // empty ]) as $replied
| .[]
| select((.in_reply_to_id // null) == null)
| select(.id as $id | ($replied | index($id)) | not)
| {id, user: .user.login, path, line: (.line // .original_line), snippet: (.body[0:200])}'
Bind .id as $id first. index(.id) would read .id from the $replied
array and fail. Review bodies carry findings too:
gh api --paginate repos/{owner}/{repo}/pulls/$ARGUMENTS/reviews \
--jq '.[] | select(.body != null and .body != "") | {user: .user.login, state, submitted_at, body: .body[0:1000]}'
Check CI with gh pr checks $ARGUMENTS and read the logs of failing jobs.
Fix repo-owned causes. Provider outages, cancelled runs, and missing
secrets are not code bugs. Failures from external checks only (Cloudflare,
Netlify) while GitHub Actions is green don't block, and they don't reset
any timer.
Fix, validate, push once. Collect everything actionable from steps 2 and 3
first, run the focused checks for what you changed, then push a single
update. Each push restarts CI, so don't push piecemeal.
Reply on your own PR. Answer every thread you fixed or declined with the
fix or your reasoning, and post one short top-level recap for feedback that
only appeared in a review body. On anyone else's PR, comment only if the
user named that PR and the comment. Feedback that needs a reply you aren't
allowed to post stays unresolved and blocks the merge.
Judging feedback
- Follow a human reviewer over a bot. Treat a bot comment as a hypothesis and
verify it before acting.
- Fix real bugs, security issues, data-loss risks, and repo-rule violations,
even when this PR didn't introduce them.
- Skip, with a reply saying why: pre-existing issues the PR doesn't touch,
false positives, nitpicks, and anything the linter or typechecker already
covers.
- Never leave a comment without a disposition.
- A high or critical finding closes only with a commit that fixes it, or a
reply that points at the code showing it can't happen. Replying
"addressed" without either doesn't close it, and it blocks the merge.
- When a third round of findings lands on code this PR added, stop patching
its edges: each patch is new code for the next round. Replace it with
something simpler, often by fixing the boundary that made it necessary,
or, in a sweep, revert that report's commit and leave it for a person.
#8288 patched one resolver about 25 times in a day and never merged.
Pushing to an existing PR
pnpm ship:push -m "<specific subject>" stages every publishable dirty path,
so check git status first and stop if a path isn't part of this fix. It
pushes origin/<local branch>. Use it
when origin is the PR's head repository and the local branch name equals
headRefName. Otherwise commit your paths, find the remote whose URL matches
headRepository.nameWithOwner (add one if needed), recheck the live head OID,
confirm git log <live headRefOid>..HEAD lists only this fix's commits, and
push HEAD:refs/heads/$headRefName to it.
If the push is rejected or the head moved, fetch that head, merge it into the
branch (never rebase or force-push), re-run the focused checks, and push again.
If another worktree has unpublished commits on that branch, leave them alone
and say so in your report.
Missing changeset
If Lint & format fails at Require changeset for publishable package changes, it's not a code bug. The step log has a line
MISSING_CHANGESET_PACKAGES: pkg1,pkg2. Write .changeset/<short-slug>.md
directly (the interactive pnpm changeset add hangs):
---
"@agent-native/<pkg>": patch
---
<one line from the PR title>
Use patch for fixes, docs, and refactors, minor for additive features, and
major only if the PR says it's breaking. Commit as
chore: add changeset for <packages> and push with the next batch.
Syncing main
Merge origin/main only when GitHub reports CONFLICTING, or a failing
required check is already fixed on main. A behind count or pending checks
are no reason to sync. Use a normal merge, never a rebase, with the tree clean
and HEAD equal to the live PR head:
dirty=$(git status --porcelain -- ':/' ':(top,exclude)learnings.md' ':(top,exclude)bridge/**' ':(top,exclude)data/**') \
&& test -z "$dirty" \
&& [ "$(git rev-parse HEAD)" = "$(gh pr view $ARGUMENTS --json headRefOid --jq .headRefOid)" ] \
&& git fetch origin main && git merge --no-edit origin/main
For a pnpm-lock.yaml conflict, take one side with
git checkout --theirs -- pnpm-lock.yaml, then
pnpm install --lockfile-only. Complete the merge and push normally.
Local changes you don't recognize
If the tree has changes this PR didn't make, leave them alone: no stash, no
commit, no revert. Publish only the paths that belong to the fix.
Merging
Under /ship, or standalone when the user asks you to merge, merge only once
ship's gate holds, using its exact command. Just
before merging, rerun the unreplied-comments query and the review-bodies call
above so no new bot round slips in, and confirm
git rev-parse HEAD equals the live headRefOid (nothing local left
unpushed, nothing remote you haven't seen). Record ship_merge_head_oid as ship
describes. Under /ship, follow its post-merge step. Standalone, leave the
branch where it is unless the user also asked to rotate.
1---2name: babysit-pr3description: >-4 Watch an open PR and fix its CI failures and review feedback until it's5 clean. Use standalone for a PR you want monitored, or as the babysit step of6 /ship, which continues through the merge.7user-invocable: true8scope: dev9metadata:10 source: https://skillmd.com/skills/builderio/babysit-pr11 internal: true12---1314# Babysit PR1516Monitor PR `$ARGUMENTS`: fix CI failures and review feedback, one batched push17at a time, until the PR is clean. With no number, find it from the branch:1819```bash20gh pr list --head "$(git branch --show-current)" --state open --json number --limit 121```2223Ownership, who may push or comment, the merge gate, cadence, and the Codex24goal and heartbeat all live in `ship`. Under `/ship` this is a step inside it:25keep going through the merge. Standalone, stop after 30 minutes of green26GitHub Actions and no new feedback, and merge only if the user asks. On a27factory PR, each watcher prompt is one tick, the watcher pushes and merges,28and the round skips the login check below:29see `factory-run/references/babysit-round.md`.3031## Each tick32331. Refresh and read the live PR:3435 ```bash36 git fetch origin --quiet37 gh api user --jq .login38 gh pr view $ARGUMENTS --json state,mergedAt,author,headRepository,headRefName,headRefOid,baseRefName,mergeable,mergeCommit39 ```4041 If `author.login` isn't your login, don't push, comment, or merge unless42 the user named this PR and that action. Closed without a merge ends the43 work; report it as unsuccessful. Merged44 under `/ship` continues with its post-merge step. If the query fails, retry45 on the next tick instead of acting on old data.46472. Read all review comments, every tick, until the moment you merge. Review48 bots re-review on every push and post a new round each time. Never filter49 by a "since <timestamp>" window: it hides rounds posted before your last50 reply, and "0 new" reads as "all addressed" (this left two rounds51 unanswered on PR #1097). Use reply state instead. Run both queries below52 with `set -o pipefail`. If either fails, the PR is not clean: retry next53 tick, and never read empty output from a failed call as "no feedback". This54 lists every top-level comment with no reply:5556 ```bash57 gh api --paginate repos/{owner}/{repo}/pulls/$ARGUMENTS/comments --jq '.[]' \58 | jq -s '59 ([ .[] | .in_reply_to_id // empty ]) as $replied60 | .[]61 | select((.in_reply_to_id // null) == null)62 | select(.id as $id | ($replied | index($id)) | not)63 | {id, user: .user.login, path, line: (.line // .original_line), snippet: (.body[0:200])}'64 ```6566 Bind `.id as $id` first. `index(.id)` would read `.id` from the `$replied`67 array and fail. Review bodies carry findings too:6869 ```bash70 gh api --paginate repos/{owner}/{repo}/pulls/$ARGUMENTS/reviews \71 --jq '.[] | select(.body != null and .body != "") | {user: .user.login, state, submitted_at, body: .body[0:1000]}'72 ```73743. Check CI with `gh pr checks $ARGUMENTS` and read the logs of failing jobs.75 Fix repo-owned causes. Provider outages, cancelled runs, and missing76 secrets are not code bugs. Failures from external checks only (Cloudflare,77 Netlify) while GitHub Actions is green don't block, and they don't reset78 any timer.79804. Fix, validate, push once. Collect everything actionable from steps 2 and 381 first, run the focused checks for what you changed, then push a single82 update. Each push restarts CI, so don't push piecemeal.83845. Reply on your own PR. Answer every thread you fixed or declined with the85 fix or your reasoning, and post one short top-level recap for feedback that86 only appeared in a review body. On anyone else's PR, comment only if the87 user named that PR and the comment. Feedback that needs a reply you aren't88 allowed to post stays unresolved and blocks the merge.8990## Judging feedback9192- Follow a human reviewer over a bot. Treat a bot comment as a hypothesis and93 verify it before acting.94- Fix real bugs, security issues, data-loss risks, and repo-rule violations,95 even when this PR didn't introduce them.96- Skip, with a reply saying why: pre-existing issues the PR doesn't touch,97 false positives, nitpicks, and anything the linter or typechecker already98 covers.99- Never leave a comment without a disposition.100- A high or critical finding closes only with a commit that fixes it, or a101 reply that points at the code showing it can't happen. Replying102 "addressed" without either doesn't close it, and it blocks the merge.103- When a third round of findings lands on code this PR added, stop patching104 its edges: each patch is new code for the next round. Replace it with105 something simpler, often by fixing the boundary that made it necessary,106 or, in a sweep, revert that report's commit and leave it for a person.107 #8288 patched one resolver about 25 times in a day and never merged.108109## Pushing to an existing PR110111`pnpm ship:push -m "<specific subject>"` stages every publishable dirty path,112so check `git status` first and stop if a path isn't part of this fix. It113pushes `origin/<local branch>`. Use it114when `origin` is the PR's head repository and the local branch name equals115`headRefName`. Otherwise commit your paths, find the remote whose URL matches116`headRepository.nameWithOwner` (add one if needed), recheck the live head OID,117confirm `git log <live headRefOid>..HEAD` lists only this fix's commits, and118push `HEAD:refs/heads/$headRefName` to it.119120If the push is rejected or the head moved, fetch that head, merge it into the121branch (never rebase or force-push), re-run the focused checks, and push again.122If another worktree has unpublished commits on that branch, leave them alone123and say so in your report.124125## Missing changeset126127If `Lint & format` fails at `Require changeset for publishable package128changes`, it's not a code bug. The step log has a line129`MISSING_CHANGESET_PACKAGES: pkg1,pkg2`. Write `.changeset/<short-slug>.md`130directly (the interactive `pnpm changeset add` hangs):131132```md133---134"@agent-native/<pkg>": patch135---136137<one line from the PR title>138```139140Use `patch` for fixes, docs, and refactors, `minor` for additive features, and141`major` only if the PR says it's breaking. Commit as142`chore: add changeset for <packages>` and push with the next batch.143144## Syncing main145146Merge `origin/main` only when GitHub reports `CONFLICTING`, or a failing147required check is already fixed on `main`. A behind count or pending checks148are no reason to sync. Use a normal merge, never a rebase, with the tree clean149and HEAD equal to the live PR head:150151```bash152dirty=$(git status --porcelain -- ':/' ':(top,exclude)learnings.md' ':(top,exclude)bridge/**' ':(top,exclude)data/**') \153 && test -z "$dirty" \154 && [ "$(git rev-parse HEAD)" = "$(gh pr view $ARGUMENTS --json headRefOid --jq .headRefOid)" ] \155 && git fetch origin main && git merge --no-edit origin/main156```157158For a `pnpm-lock.yaml` conflict, take one side with159`git checkout --theirs -- pnpm-lock.yaml`, then160`pnpm install --lockfile-only`. Complete the merge and push normally.161162## Local changes you don't recognize163164If the tree has changes this PR didn't make, leave them alone: no stash, no165commit, no revert. Publish only the paths that belong to the fix.166167## Merging168169Under `/ship`, or standalone when the user asks you to merge, merge only once170`ship`'s gate holds, using its exact command. Just171before merging, rerun the unreplied-comments query and the review-bodies call172above so no new bot round slips in, and confirm173`git rev-parse HEAD` equals the live `headRefOid` (nothing local left174unpushed, nothing remote you haven't seen). Record `ship_merge_head_oid` as `ship`175describes. Under `/ship`, follow its post-merge step. Standalone, leave the176branch where it is unless the user also asked to rotate.