pr-babysitter
Monitors or repairs an open GitHub PR: CI failures, conflicts, review threads, and merge readiness, reporting state changes. Use when asked to \"watch this PR\", \"fix CI\", \"resolve conflicts\", or \"address review comments\". For PR metadata use pr-creator; for npm release PRs use autoship.
mblode · AI review on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add mblode/agent-skills --skill pr-babysitterAbout this skill
name: pr-babysitter description: "Monitors or repairs an open GitHub PR: CI failures, conflicts, review threads, and merge readiness, reporting state changes. Use when asked to "watch this PR", "fix CI", "resolve conflicts", or "address review comments". For PR metadata use pr-creator; for npm release PRs use autoship." compatibility: Requires a Git checkout, authenticated GitHub CLI, and jq. Continuous monitoring also needs a supported scheduler or event subscription.
PR Babysitter
- IS: keeping one open PR moving: conflicts, CI across GitHub Actions/Buildkite/Vercel/Fly.io, inbound review comments, and merge readiness, as a background monitor or as one-shot fixes.
- IS NOT: opening or editing the PR (
pr-creator), reviewing the diff for bugs (pr-reviewer), applying a localpr-reviewerreport (tidy), or npm release PRs (autoshipwatches its own release CI; never babysit a release or Version Packages PR it drives).
Mode Selection
| Invocation | Mode |
|---|---|
| "babysit", "watch this PR", "monitor", "keep it green" | Monitor: Phase 1 once, then phases 2-5 on every event or tick |
| "fix CI", "why is CI red", "loop on CI" | One-shot Phase 3 loop |
| "resolve conflicts", "rebase onto main", "update the branch" | One-shot Phase 2 |
| "address the comments", "reply to the reviewers", "triage review comments" | One-shot Comment Triage Workflow |
| "is it ready", "what is blocking the merge" | One-shot Phase 5 report |
Standing rules, every mode:
-
Monitoring or fixing code does not by itself authorize posting replies. Post, resolve threads, or request reviews only when the user authorized that communication; otherwise prepare replies and report them.
-
Resolve
scripts/fetch-comments.shrelative to this installed SKILL.md.${CLAUDE_SKILL_DIR}below is a Claude Code adapter, not a portable environment variable. -
No setup questions. Auto-detect the PR, the CI platforms, and the defaults (poll every 2 minutes, auto-resolve noise, no auto-merge), then start. Overrides arrive inline: "poll every 5 minutes", "enable auto-merge".
-
Skip closed or merged PRs. Skip drafts (
isDraft) unless asked. -
Comment triage runs autonomously; the plan file is an audit trail, not an approval gate.
-
Speak only on transitions. A quiet poll says nothing.
Reference Files
| File | Read when |
|---|---|
references/monitoring-setup.md | Phase 1: watch ladder detail, Monitor watch script, cron fallback, state file format, defaults |
references/merge-conflicts.md | Phase 2: mergeStateStatus table, rebase workflow, lockfile and generated-file resolution, abort criteria |
references/ci-platforms.md | Phase 3: gh pr checks fields and exit codes, per-platform log and retry commands, Buildkite auth chain, failure classification |
scripts/fetch-comments.sh | Comment triage: run ${CLAUDE_SKILL_DIR}/scripts/fetch-comments.sh {N} first. One JSON document of every review, thread, and issue comment; --help prints the output shape |
references/github-api.md | Comment triage: script output contract, manual GraphQL/REST fallback, thread accounting, anchor ladder, awaiting-reply rule, reply and resolve |
references/bot-patterns.md | Comment triage: reviewer detection, severity mapping, merge gates, noise markers, dedup, false positives |
references/fix-plan-template.md | Comment triage: plan file format and the legal ignore reasons |
references/verification-gate.md | Before any commit: lint, type-check, test, knip, stray-artifact sweep |
references/git-resilience.md | A git command hangs or fails transiently (fsmonitor wedge, stale index.lock, network blip) |
evals/evals.json | Only when changing this skill; never during a PR task |
Monitor Loop
Phase 1 runs once in the foreground and starts the watch. Every event or tick then runs phases 2-5, diffs against the state file, and speaks only when something changed.
Copy this checklist to track progress:
PR babysit progress:
- [ ] Phase 1: Initialize (detect PR, pick watch mechanism, snapshot state)
- [ ] Phase 2: Conflict check
- [ ] Phase 3: CI check (diagnose, fix, gate, push)
- [ ] Phase 4: Comment check (triage new comments)
- [ ] Phase 5: Readiness check (report transitions, write state file)
Phase 1: Initialize
gh pr view [N] --json number,url,title,state,isDraft,headRefName,baseRefName,headRefOid,mergeable,mergeStateStatus,reviewDecision. No PR for the branch: say so and stop.gh repo view --json owner,namefor the calls that needowner/repo.- Detect CI platforms from
gh pr checks --json name,link(dispatch table in Phase 3). - Pick the watch mechanism: first rung that applies.
| Rung | Available when | Behaviour |
|---|---|---|
| Harness PR subscription | A PR-subscription tool is exposed (cloud sessions: Claude_Code_Remote:subscribe_pr_activity; GitHub MCP server: github:subscribe_pr_activity), or the web session's Auto-fix toggle is on | GitHub pushes review comments, CI failures, and check-suite success into the session. GitHub sends nothing when the base branch advances, so pair it with a slow Monitor poll (10 minutes) on mergeStateStatus. If the tool reports a PR Steward already watching, this session gets no events: say the PR is already covered and offer the one-shot modes instead of double-fixing |
| Monitor tool | Monitor is in the tool list | Start the watch script from the monitoring reference with persistent: true. Quiet polls never wake the agent; each emitted line runs phases 2-5 |
| Cron | CronCreate is in the tool list | */2 * * * * running phases 2-5; every tick wakes the agent. Recurring tasks expire after 7 days |
| None | Neither | Do not claim monitor mode. Run the matching one-shot mode, or say this runtime cannot keep polling |
- Snapshot state to
.claude/pr-babysitter/babysit-pr-{N}.md: mechanism and ID, head SHA, mergeability, check states, op