# 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= -f per_page=100` Used to discover failed workflow runs and rerunnable run IDs. ### Failed log inspection - `gh run view --json jobs,name,workflowName,conclusion,status,url,headSha` - `gh run view --log-failed` Used by Codex to classify branch-related vs flaky/unrelated failures. ### Retry failed jobs only - `gh run rerun --failed` Reruns only failed jobs (and dependencies) for a workflow run. ## Review-related endpoints - Issue comments on PR: - `gh api repos/{owner}/{repo}/issues//comments?per_page=100` - Inline PR review comments: - `gh api repos/{owner}/{repo}/pulls//comments?per_page=100` - Review submissions: - `gh api repos/{owner}/{repo}/pulls//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`