Files
codex/.codex/skills/babysit-pr/references/github-api-notes.md
Eric Traut 7e569f1162 Add PR babysitting skill for this repo (#12513)
## PR Notes

This PR adds a project-scoped `babysit-pr` skill for ongoing PR
monitoring (CI, reviews, mergeability).

Simply invoke this skill after creating a PR, and codex will do its best
to get it to a mergeable state:

### What the skill does
* Fixes CI failures related to the PR
* Retries CI failures due to flaky tests
* Addresses code review comments if it agrees with them
* Addresses merge conflicts on main branch

### How the skill works
- Polls PR status on a loop (CI checks, workflow runs, review activity,
mergeability, and review decision).
- Detects new review feedback (including inline comments and automated
Codex review comments) and prompts/handles follow-up work.
- Distinguishes pending vs failed vs passed CI and identifies likely
flaky failures.
- Can retry failed checks/workflows when appropriate.
- Prioritizes actionable code review feedback over flaky CI retries (to
avoid rerunning CI on a SHA that is about to be replaced).
- Continues monitoring after fixes are applied and pushed, rather than
stopping after a progress update.
- Uses a slower backoff polling cadence once CI is green, while still
watching for new review feedback or state changes.
- Treats required review/approval as a blocking condition and keeps
watching until the PR is actually merge-ready (or merged/closed, or
human intervention is needed).

### Intended outcome

Keep the PR moving with minimal manual babysitting by continuously
watching for CI failures, reviewer feedback, and merge blockers, and
responding in the right order until the PR is ready to merge.
2026-02-22 15:36:28 -08:00

1.7 KiB

GitHub CLI / API Notes For babysit-pr

Primary commands used

PR metadata

  • gh pr view --json number,url,state,mergedAt,closedAt,headRefName,headRefOid,headRepository,headRepositoryOwner

Used to resolve PR number, URL, branch, head SHA, and closed/merged state.

PR checks summary

  • gh pr checks --json name,state,bucket,link,workflow,event,startedAt,completedAt

Used to compute pending/failed/passed counts and whether the current CI round is terminal.

Workflow runs for head SHA

  • gh api repos/{owner}/{repo}/actions/runs -X GET -f head_sha=<sha> -f per_page=100

Used to discover failed workflow runs and rerunnable run IDs.

Failed log inspection

  • gh run view <run-id> --json jobs,name,workflowName,conclusion,status,url,headSha
  • gh run view <run-id> --log-failed

Used by Codex to classify branch-related vs flaky/unrelated failures.

Retry failed jobs only

  • gh run rerun <run-id> --failed

Reruns only failed jobs (and dependencies) for a workflow run.

  • Issue comments on PR:
    • gh api repos/{owner}/{repo}/issues/<pr_number>/comments?per_page=100
  • Inline PR review comments:
    • gh api repos/{owner}/{repo}/pulls/<pr_number>/comments?per_page=100
  • Review submissions:
    • gh api repos/{owner}/{repo}/pulls/<pr_number>/reviews?per_page=100

JSON fields consumed by the watcher

gh pr view

  • number
  • url
  • state
  • mergedAt
  • closedAt
  • headRefName
  • headRefOid

gh pr checks

  • bucket (pass, fail, pending, skipping)
  • state
  • name
  • workflow
  • link

Actions runs API (workflow_runs[])

  • id
  • name
  • status
  • conclusion
  • html_url
  • head_sha