babysit
WHEN a pushed branch or open PR must reach green CI without the user watching, or WHEN you are about to hand-write a CI poller, watcher, or re-run loop to escort one pushed branch—monitor checks, fix failures, commit, push, and repeat until success, merge, or a bounded stop; NOT for creating the commit series or the PR itself (ship-pr), NOT for watching many PRs as an agent inbox (github-monitor), and NOT for writing a poller, watcher, or notifier that ships as source code in a product, service, or repository script; works on GitHub with gh and on Forgejo or Gitea with tea, asks once whether the PR needs a label, classifies every red check as branch, infra, or base failure, and reports each transition without posting PR comments.
mintuz · Static checks on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add mintuz/skills --skill babysitAbout this skill
name: babysit description: > WHEN a pushed branch or open PR must reach green CI without the user watching, or WHEN you are about to hand-write a CI poller, watcher, or re-run loop to escort one pushed branch—monitor checks, fix failures, commit, push, and repeat until success, merge, or a bounded stop; NOT for creating the commit series or the PR itself (ship-pr), NOT for watching many PRs as an agent inbox (github-monitor), and NOT for writing a poller, watcher, or notifier that ships as source code in a product, service, or repository script; works on GitHub with gh and on Forgejo or Gitea with tea, asks once whether the PR needs a label, classifies every red check as branch, infra, or base failure, and reports each transition without posting PR comments.
Babysit
Stay with one branch's CI until it is green and its PR merges. The user has walked away; the loop's job is to make their return boring: either "it merged" or one precise blocker that only they can clear.
Prerequisites
- An existing branch pushed to the remote, with or without an open PR. If the
branch is not pushed, stop and tell the user to run
ship-prfirst; do not commit, push, or open the PR under this skill's authority. - Forge access:
- GitHub:
ghauthenticated (gh auth status). - Forgejo or Gitea:
tealogged in (tea logins list).tea api <endpoint>sends an authenticated request and fills{owner}and{repo}from the current repository, so never search the filesystem for the token. Each step below names theghcommand and itsteaequivalent; the loop is the same.
- GitHub:
- Load
core:commit-messagesbefore writing any fix commit.
Authority
Treat invocation as authorization to diagnose failing checks, commit fixes, push to the watched branch, re-run CI runs, and apply the label the user approves. Reserve for explicit user direction: merging the PR yourself, history rewrites or force-pushes, changes to product behavior beyond what the failing check requires, and any push to the base branch or to another lane's branch—a red there is reported, never patched uninvited.
Never post PR or issue comments about the loop's own activity—rounds fixed, retries, status. To the reviewer that is noise; the commit history and this session's reports are the record.
1. Fix the target
Identify the branch, its open PR, the base branch, and the current head SHA:
gh pr view <n> --json number,headRefName,baseRefName,headRefOid, or
tea api '/repos/{owner}/{repo}/pulls/<n>' (read head.sha and base.ref).
Every check result belongs to one head SHA, so record it—after each push the
watch must re-target the new head, or it will report a stale verdict.
When there is no PR, the base is the base branch the user names explicitly; otherwise it is the remote's default branch. The watched branch is never its own base. Skip step 2. The watch in step 3 reads the commit status of the head SHA, which needs no PR.
Anchor the local checkout to that head before any local gate or fix: run
git fetch, then confirm that the watched branch is checked out, the worktree
is clean, and local HEAD equals the observed head SHA. On any mismatch, stop
and report it; do not commit or push from a checkout that does not match the
watched head.
Before you arm the watch, run the repository's cheap local gates (lint, typecheck, unit tests). Do not run slow suites here: arm the watch first, then run every test file this branch adds or changes during the CI wait (step 6). A failure found locally costs seconds; the same failure found by CI costs a full round-trip.
Complete when: branch, base, head SHA, and the PR (when one exists) are explicit, and the cheap gates pass locally or their failures are already being fixed.
2. Settle the label question
Ask once, at the start—not when CI goes green, because a label such as
auto-merge must already be on the PR for the forge to land it the moment
checks pass, without another round-trip through this loop.
Fetch the repository's real labels (gh label list or tea labels ls) and
ask the user whether this PR needs one, offering the labels that plausibly
apply (auto-merge, release, area labels). Apply the choice with
gh pr edit --add-label <label> or tea pr edit <n> --add-labels <label>.
Offer only labels that exist: the forge refuses a label the repository does
not have. If the user declines or does not answer, proceed without one and do
not ask again.
Complete when: the label is applied, or the user has declined, once.
3. Arm the watch
Prefer a watcher that wakes the loop on a state change (a background
gh pr checks --watch, or a Monitor/background task that polls and exits on a
state change) over ad-hoc sleeping. Requirements for whatever mechanism is available:
- Structured status only: read check state for the head SHA from the
forge's structured status. GitHub with a PR:
gh pr checks <n> --json name,state,bucket. GitHub without a PR:gh api repos/{owner}/{repo}/commits/<sha>/check-runs --paginate(read eachcheck_runs[].statusandconclusion) plusgh api repos/{owner}/{repo}/commits/<sha>/status --paginatefor legacy commit statuses. Forgejo or Gitea:tea api '/repos/{owner}/{repo}/commits/<sha>/status?page=<n>&limit=50'(readstateand eachstatuses[].contextwith itsstatus; steppageuntiltotal_countcontexts are read). Never derive a verdict by grepping human-readable output (tea pr <n>, run summaries, log text) for failure words: a check that reports "Failing" passes a grep for "failed", and the loop reports a red run as green. - Cadence: 20–30 seconds while a run is in flight. CI rounds are the bottleneck of this whole loop; a slow poller adds dead minutes to every round. Back off to 15–25 minutes only when waiting on something external (base branch red, merge queue position, a re-run a human must start).
- Exit with names: the watcher mu