/desplega:babysit-pr runs instead · from desplega
Automates a GitHub PR through CI fixes, review handling, rebasing, and reviewer re-triggers until clean. Loops in the background, merging only on user request.
This skill never runs in Claude Code
It ships in desplega at skills/, but /desplega:babysit-pr (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
This skill is a loop around desplega:tackle-gh-comments. Each round does these steps:
The loop stops when the PR is clean on its head commit, at the round limit, or when a decision belongs to the user.
A turn in a babysit run ends in exactly one of two ways:
wait command runs in the background.Do not end a turn in a different way. When wait exits, start the next round at once. The
next field in the wait output repeats this instruction. This keeps the loop alive after a
context compaction.
To stop and ask, use AskUserQuestion (see Guardrails). The prompt pauses the round. It does
not end the round. After the answer, continue the round.
STATE="${CLAUDE_PLUGIN_ROOT}/skills/babysit-pr/scripts/pr-state.ts"
COMMENTS="${CLAUDE_PLUGIN_ROOT}/skills/tackle-gh-comments/scripts/gh-pr-comments.ts"
bun $STATE snapshot # one compact JSON object for the round
bun $STATE wait --since <head-oid> --round 2/6 # blocks, prints one JSON line on the next event
bun $STATE rerequest --reviewer <login> # formal re-request (--dry-run prints the command)
bun $COMMENTS list # full text of threads and findings on head
bun $COMMENTS list --all # also older findings and resolved threads
The scripts infer the repo and the PR from the current checkout. --repo owner/name and
--pr N override them.
snapshot gives state, head, base, checks, threads, findings (bodies cut to 300
characters), reviewers, and gates. The script reports facts only. You make these judgment
calls:
gh pr view --json number,url,headRefName). Work in the PR's checkout. If the current branch
(git branch --show-current) is not headRefName, stop and ask.--max-rounds N. The default is 6.--merge. Without it, never merge.snapshot and read the output.state is MERGED or CLOSED, write the final report.gates.upToDate is false.
git fetch origin <base.ref>.git rev-parse HEAD) and the old fork point
(git merge-base HEAD origin/<base.ref>).git rebase origin/<base.ref>. If a conflict needs a judgment call, stop and ask.git range-diff <old-fork-point>..<old-head> origin/<base.ref>..HEAD. Make sure that
no change of the PR is gone, and that no change from the base returned.gh pr checks <N> --repo <owner/name>.
For a GitHub Actions run, the link holds the run id. Read the logs
(gh run view <run-id> --log-failed).
Fix a real failure. An infrastructure flake is a failure that the code did not cause.
Examples: a lost runner, a network timeout, a registry error. For a flake, run
gh run rerun <run-id> --failed one time. If the same check fails again, treat the failure
as real.threads.unresolved is above 0 or findings is not empty, follow
desplega:tackle-gh-comments: verify, fix, reply, and resolve. Do not push yet.
findings holds only findings on the head commit. Some are approvals or status notes.
Read each one. Act only on real requests.findings until the next push.
Do not answer it again.latest.onHead is then
false. Read that review with list --all and handle it too.git push --force-with-lease=<branch>:<old-head>. If the lease fails, the remote branch has
commits that you do not have. Fetch, then stop and ask. Do not overwrite those commits.
Never force-push without a lease.wait in the background with the new head oid. Pass --round N/M: N is the
number of counted rounds so far, and M is the round limit. End the turn.A round counts toward the limit when it pushes a commit or posts a trigger. A round that only
reads the state and starts wait again does not count.
When wait exits, read its event:
| Event | Next step |
|---|---|
merged, closed | Write the final report. |
head-moved | Pull the new head. Start the next round. |
check-failed, checks-done, review-activity, merge-state | Start the next round. |
timeout | Start the next round. After two timeout events in a row, stop and ask. |
Reviewer names differ per company and per repo. Do not classify a reviewer from its name.
Classify each entry in snapshot.reviewers from its evidence:
Not a reviewer. These are deploy bots, CI bots, and dependency bots. They post deploy previews, CI timing tables, or dependency updates. Read their checks. Ignore their comments.
Runs on push. It has activity on several heads, triggeredBy is null, and nobody
requested it. Do not trigger it. Wait for it.
Formally requested. requestedNow or everRequested is true, and no comment triggers
it. Re-request it with rerequest --reviewer <login>. Humans and some bots use this path.
Comment-triggered. It ran after a comment that mentions it. Find the trigger in this order:
triggeredBy.excerpt: reuse the exact trigger that worked earlier on this PR.bodyTail: many bots state their trigger in a footer.CLAUDE.md, AGENTS.md, CONTRIBUTING.md, .github/.AskUserQuestion. Reuse the answer for the rest of the run.Post the trigger with gh pr comment <N> --repo <owner/name> --body "<trigger>".
A relevant reviewer is a reviewer in one of the last three classes. Do not send comment triggers to humans.
isAuthor is true when the PR author also posts reviews from the same account. The activity of
that account mixes code work and reviews. Read the bodies to find the reviews.
Examples from desplega-ai PRs (examples only, not rules):
desplega-bot takes a comment trigger and gives a formal APPROVED.chatgpt-codex-connector) takes @codex review. Its footer states this trigger.copilot-pull-request-reviewer) takes a formal re-request.All of these conditions are true on head.oid:
gates.requiredChecksGreen is true.
checks.requiredCount is 0, requiredChecksGreen uses all checks.checks.required also lists the required checks of the base branch rules that have not
started yet. Their status is EXPECTED, and they count as pending. The script reads
rulesets, and classic branch protection when your account can read it.requiredChecksGreen is also true when no check exists. If checks.required and
checks.optional are both empty right after a push, wait for one more event. GitHub may not
have registered the checks yet.gates.noUnresolvedThreads is true, and each finding on head has an answer.gates.upToDate is true.gates.reviewDecisionOk is true.approvedOnHead is true, or
latest.onHead is true and its latest activity has no new finding. Read the body of that
activity. Machine-readable markers in bot comments are hints, not rules.Claude Code: run wait with Bash run_in_background: true. Then end the turn with one
short status line. The harness starts your next turn when wait exits. Read the JSON line
of wait from the task output.
Unattended Claude Code runs (-p, SDK, CI) stop background tasks after 30 minutes by
default. Use --timeout 1500 there.
Harnesses without background re-invocation (for example Codex CLI): run wait in the
foreground. Set --timeout at least two intervals below the time limit of the tool. On
timeout, run wait again in the same turn.
Use wait for all waiting. Do not use sleep loops or other polling.
Only one wait runs per PR. A second wait exits at once with an error that gives the pid
of the first. Then end the turn. The first wait starts the next round when it exits. If you
cannot find that background task, run kill <pid> and start wait again.
Optional /goal. In Claude Code, give the user this line to paste. /goal is a user
command, so you cannot set it yourself.
/goal The babysit-pr run for <PR url> wrote its final report: the PR is clean on its head commit, merged, or closed, or the user told it to stop.
Stop and ask when one of these conditions occurs:
gates.reviewDecisionOk is the only false gate, and each relevant reviewer is clean on head.
An old CHANGES_REQUESTED review then blocks the PR. Find its author with
gh pr view <N> --repo <owner/name> --json latestReviews. Only that author can clear it.To stop and ask, use AskUserQuestion. A question in a normal message looks like a finished
run, and the user can miss it. Put the PR url, the blocker, and the options in the question. Put
your recommendation first. If no question tool exists, or the prompt returns no answer, write
the final report and start it with the question. Leave the PR open and unmerged.
Always obey these rules:
--merge. With --merge, merge only when the PR is done. Use the merge
method of the repo. If you cannot find the method, ask.git fetch and a new snapshot. Merge only when that snapshot
meets the definition of done on the same head.oid.--admin or another bypass of branch protection.PushNotification each time you stop and ask, and each time you write the final
report.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub desplega-ai/ai-toolbox --plugin desplega26 skills in this plugin
/ask-userConventions for asking the user questions during a workflow via the AskUserQuestion tool. Other skills reference this to keep prompts consistent and structured./brainstormingInteractive exploration of ideas through Socratic Q&A. Produces progressive documents that serve as lightweight pre-PRDs feeding into research./code-reviewingTwo-axis code review of a diff — Standards (is the code well built?) and Spec (does it actually solve the stated problem?) — run as parallel sub-agents and reported separately, never merged. Use when reviewing implementation output (a phase, a wave, a branch, a PR), when the user says "review the code", "review the diff", "review this phase", or when another desplega skill (implementing, v-implementing, verifying, delegate-work) calls for a per-phase or final code review. For reviewing DOCUMENTS (plans, research, brainstorms), use desplega:reviewing instead./commsRe-express something so it lands — re-explain your last reply in plain casual language, show the current topic visually (diagram, code-shape sketch, HTML artifact), do both at once, or rewrite artifact text into unambiguous ASD-STE100 English. Use when the user runs /desplega:comms, types /bro, says 'say it simpler', 'bro what', 'I don't follow', 'show me', 'draw this', 'visualize', 'disambiguate this', or 'STE100 rewrite'. Not for creative or marketing copy./delegate-workExecutor routing policy for ALL delegated work — pick the right model for every sub-agent and the right Codex variant for every implementation slice. Use whenever you are about to spawn a sub-agent/Task (research, review, QA, UI, search), whenever a desplega skill (implement-plan, v-implement, run-phase, run-step, research) is choosing executors for phases/steps, or when the user says "implement with codex", "delegate this", "which model should do this", or similar. Supersedes codex-implement (its worktree/exec mechanics live here)./design-docsCreate and maintain living per-system design docs at thoughts/*/design-docs/<system-slug>.md — Purpose, Glossary, numbered testable Invariants (normative for the code-reviewing Spec axis), Boundaries & Non-goals, Interfaces, Decision log, Amendment log. Use when the user says "create a design doc", "write down the invariants", "document the design/contract of X", or when researching/planning/one-shot finds a design doc for the touched system and needs the read-and-abide rules.Other plugins' skills for the same job