babysit-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePR Babysitter
PR 保姆工具
Objective
目标
Babysit a PR persistently until one of these terminal outcomes occurs:
- The PR is merged or closed.
- CI is successful, there are no unaddressed review comments surfaced by the watcher, required review approval is not blocking merge, and there are no potential merge conflicts (PR is mergeable / not reporting conflict risk).
- A situation requires user help (for example CI infrastructure issues, repeated flaky failures after retry budget is exhausted, permission problems, or ambiguity that cannot be resolved safely).
Do not stop merely because a single snapshot returns while checks are still pending.
idle持续监控PR,直到出现以下任一终止结果:
- PR已合并或关闭。
- CI执行成功,监控器未发现未处理的评审评论,所需的评审批准未阻塞合并,且不存在潜在的合并冲突(PR处于可合并状态/未报告冲突风险)。
- 出现需要用户介入的情况(例如CI基础设施问题、重试次数耗尽后仍存在重复的不稳定失败、权限问题,或无法安全解决的模糊情况)。
不要仅因为单次快照返回但检查仍在进行中就停止监控。
idleInputs
输入
Accept any of the following:
- No PR argument: infer the PR from the current branch ()
--pr auto - PR number
- PR URL
接受以下任意一种输入:
- 无PR参数:从当前分支推断PR()
--pr auto - PR编号
- PR链接
Core Workflow
核心工作流
- When the user asks to "monitor"/"watch"/"babysit" a PR, start with the watcher's continuous mode () unless you are intentionally doing a one-shot diagnostic snapshot.
--watch - Run the watcher script to snapshot PR/CI/review state (or consume each streamed snapshot from ).
--watch - Inspect the list in the JSON response.
actions - If is present, inspect failed run logs and classify the failure.
diagnose_ci_failure - If the failure is likely caused by the current branch, patch code locally, commit, and push.
- If is present, inspect surfaced review items and decide whether to address them.
process_review_comment - If a review item is actionable and correct, patch code locally, commit, and push.
- If the failure is likely flaky/unrelated and is present, rerun failed jobs with
retry_failed_checks.--retry-failed-now - If both actionable review feedback and are present, prioritize review feedback first; a new commit will retrigger CI, so avoid rerunning flaky checks on the old SHA unless you intentionally defer the review change.
retry_failed_checks - On every loop, verify mergeability / merge-conflict status (for example via ) in addition to CI and review state.
gh pr view - After any push or rerun action, immediately return to step 1 and continue polling on the updated SHA/state.
- If you had been using before pausing to patch/commit/push, relaunch
--watchyourself in the same turn immediately after the push (do not wait for the user to re-invoke the skill).--watch - Repeat polling until the PR is green + review-clean + mergeable, appears, or a user-help-required blocker is reached.
stop_pr_closed - Maintain terminal/session ownership: while babysitting is active, keep consuming watcher output in the same turn; do not leave a detached process running and then end the turn as if monitoring were complete.
--watch
- 当用户要求“监控”/“查看”/“保姆式看护”PR时,启动监控器的持续模式(),除非你有意进行一次性诊断快照。
--watch - 运行监控脚本以获取PR/CI/评审状态的快照(或从接收每个流式快照)。
--watch - 检查JSON响应中的列表。
actions - 如果存在,检查失败运行日志并对失败进行分类。
diagnose_ci_failure - 如果失败可能由当前分支导致,在本地修补代码、提交并推送。
- 如果存在,检查显示的评审项并决定是否处理。
process_review_comment - 如果评审项可操作且正确,在本地修补代码、提交并推送。
- 如果失败疑似不稳定/无关,且存在,使用
retry_failed_checks重新运行失败的任务。--retry-failed-now - 如果同时存在可操作的评审反馈和,优先处理评审反馈;新的提交会重新触发CI,因此除非有意延迟评审变更,否则避免在旧SHA上重新运行不稳定检查。
retry_failed_checks - 在每次循环中,除了CI和评审状态外,还要验证可合并性/合并冲突状态(例如通过)。
gh pr view - 执行任何推送或重新运行操作后,立即回到步骤1,继续轮询更新后的SHA/状态。
- 如果在暂停进行修补/提交/推送前使用的是模式,在推送完成后的同一轮操作中立即重新启动
--watch(不要等待用户重新调用该技能)。--watch - 重复轮询,直到PR状态正常+评审无待处理项+可合并,出现,或遇到需要用户介入的阻塞问题。
stop_pr_closed - 保持终端/会话控制权:在保姆式监控活动期间,在同一轮操作中持续接收监控器的输出;不要让分离的进程运行,然后结束操作,仿佛监控已完成。
--watch
Commands
命令
One-shot snapshot
一次性快照
bash
python3 .codex/skills/babysit-pr/scripts/gh_pr_watch.py --pr auto --oncebash
python3 .codex/skills/babysit-pr/scripts/gh_pr_watch.py --pr auto --onceContinuous watch (JSONL)
持续监控(JSONL格式)
bash
python3 .codex/skills/babysit-pr/scripts/gh_pr_watch.py --pr auto --watchbash
python3 .codex/skills/babysit-pr/scripts/gh_pr_watch.py --pr auto --watchTrigger flaky retry cycle (only when watcher indicates)
触发不稳定重试循环(仅当监控器指示时)
bash
python3 .codex/skills/babysit-pr/scripts/gh_pr_watch.py --pr auto --retry-failed-nowbash
python3 .codex/skills/babysit-pr/scripts/gh_pr_watch.py --pr auto --retry-failed-nowExplicit PR target
指定PR目标
bash
python3 .codex/skills/babysit-pr/scripts/gh_pr_watch.py --pr <number-or-url> --oncebash
python3 .codex/skills/babysit-pr/scripts/gh_pr_watch.py --pr <number-or-url> --onceCI Failure Classification
CI失败分类
Use commands to inspect failed runs before deciding to rerun.
ghgh run view <run-id> --json jobs,name,workflowName,conclusion,status,url,headShagh run view <run-id> --log-failed
Prefer treating failures as branch-related when logs point to changed code (compile/test/lint/typecheck/snapshots/static analysis in touched areas).
Prefer treating failures as flaky/unrelated when logs show transient infra/external issues (timeouts, runner provisioning failures, registry/network outages, GitHub Actions infra errors).
If classification is ambiguous, perform one manual diagnosis attempt before choosing rerun.
Read for a concise checklist.
.codex/skills/babysit-pr/references/heuristics.md在决定重新运行前,使用命令检查失败的运行。
ghgh run view <run-id> --json jobs,name,workflowName,conclusion,status,url,headShagh run view <run-id> --log-failed
当日志指向变更的代码时(例如修改区域的编译/测试/ lint/类型检查/快照/静态分析失败),优先将失败视为分支相关问题。
当日志显示临时的基础设施/外部问题时(例如超时、运行器配置失败、注册表/网络中断、GitHub Actions基础设施错误),优先将失败视为不稳定/无关问题。
如果分类模糊,在选择重新运行前先进行一次手动诊断尝试。
阅读获取简洁的检查清单。
.codex/skills/babysit-pr/references/heuristics.mdReview Comment Handling
评审评论处理
The watcher surfaces review items from:
- PR issue comments
- Inline review comments
- Review submissions (COMMENT / APPROVED / CHANGES_REQUESTED)
It intentionally surfaces Codex reviewer bot feedback (for example comments/reviews from ) in addition to human reviewer feedback. Most unrelated bot noise should still be ignored.
For safety, the watcher only auto-surfaces trusted human review authors (for example repo OWNER/MEMBER/COLLABORATOR, plus the authenticated operator) and approved review bots such as Codex.
On a fresh watcher state file, existing pending review feedback may be surfaced immediately (not only comments that arrive after monitoring starts). This is intentional so already-open review comments are not missed.
chatgpt-codex-connector[bot]When you agree with a comment and it is actionable:
- Patch code locally.
- Commit with .
codex: address PR review feedback (#<n>) - Push to the PR head branch.
- Resume watching on the new SHA immediately (do not stop after reporting the push).
- If monitoring was running in mode, restart
--watchimmediately after the push in the same turn; do not wait for the user to ask again.--watch
If you disagree or the comment is non-actionable/already addressed, record it as handled by continuing the watcher loop (the script de-duplicates surfaced items via state after surfacing them).
If a code review comment/thread is already marked as resolved in GitHub, treat it as non-actionable and safely ignore it unless new unresolved follow-up feedback appears.
监控器从以下来源提取评审项:
- PR议题评论
- 内联评审评论
- 评审提交(COMMENT / APPROVED / CHANGES_REQUESTED)
除了人工评审反馈外,监控器还会特意提取Codex评审机器人的反馈(例如来自的评论/评审)。大多数无关的机器人噪音仍应被忽略。
为确保安全,监控器仅自动提取可信的人工评审作者(例如仓库OWNER/MEMBER/COLLABORATOR,以及已认证的操作者)和已批准的评审机器人(如Codex)的反馈。
在新的监控器状态文件中,现有的待处理评审反馈可能会立即被提取(不仅是监控开始后收到的评论)。这是有意设计的,以避免遗漏已存在的评审评论。
chatgpt-codex-connector[bot]当你同意某条评论且该评论可操作时:
- 在本地修补代码。
- 使用提交信息提交。
codex: address PR review feedback (#<n>) - 推送到PR的头部分支。
- 立即在新的SHA上恢复监控(推送后不要停止)。
- 如果之前使用模式进行监控,推送后在同一轮操作中立即重启
--watch;不要等待用户再次请求。--watch
如果你不同意该评论,或评论不可操作/已处理,通过继续监控循环将其标记为已处理(脚本会通过状态去重已提取的项)。
如果GitHub上的代码评审评论/线程已标记为已解决,将其视为不可操作并安全忽略,除非出现新的未解决后续反馈。
Git Safety Rules
Git安全规则
- Work only on the PR head branch.
- Avoid destructive git commands.
- Do not switch branches unless necessary to recover context.
- Before editing, check for unrelated uncommitted changes. If present, stop and ask the user.
- After each successful fix, commit and , then re-run the watcher.
git push - If you interrupted a live session to make the fix, restart
--watchimmediately after the push in the same turn.--watch - Do not run multiple concurrent processes for the same PR/state file; keep one watcher session active and reuse it until it stops or you intentionally restart it.
--watch - A push is not a terminal outcome; continue the monitoring loop unless a strict stop condition is met.
Commit message defaults:
codex: fix CI failure on PR #<n>codex: address PR review feedback (#<n>)
- 仅在PR的头部分支上工作。
- 避免使用破坏性的git命令。
- 除非需要恢复上下文,否则不要切换分支。
- 编辑前检查是否存在无关的未提交更改。如果存在,停止并询问用户。
- 每次成功修复后,提交并执行,然后重新运行监控器。
git push - 如果你中断了正在运行的会话来进行修复,推送后在同一轮操作中立即重启
--watch。--watch - 不要为同一个PR/状态文件运行多个并发的进程;保持一个监控器会话活跃,直到它停止或你有意重启。
--watch - 推送操作不是终止结果;除非满足严格的停止条件,否则继续监控循环。
提交信息默认格式:
codex: fix CI failure on PR #<n>codex: address PR review feedback (#<n>)
Monitoring Loop Pattern
监控循环模式
Use this loop in a live Codex session:
- Run .
--once - Read .
actions - First check whether the PR is now merged or otherwise closed; if so, report that terminal state and stop polling immediately.
- Check CI summary, new review items, and mergeability/conflict status.
- Diagnose CI failures and classify branch-related vs flaky/unrelated.
- Process actionable review comments before flaky reruns when both are present; if a review fix requires a commit, push it and skip rerunning failed checks on the old SHA.
- Retry failed checks only when is present and you are not about to replace the current SHA with a review/CI fix commit.
retry_failed_checks - If you pushed a commit or triggered a rerun, report the action briefly and continue polling (do not stop).
- After a review-fix push, proactively restart continuous monitoring () in the same turn unless a strict stop condition has already been reached.
--watch - If everything is passing, mergeable, not blocked on required review approval, and there are no unaddressed review items, report success and stop.
- If blocked on a user-help-required issue (infra outage, exhausted flaky retries, unclear reviewer request, permissions), report the blocker and stop.
- Otherwise sleep according to the polling cadence below and repeat.
When the user explicitly asks to monitor/watch/babysit a PR, prefer so polling continues autonomously in one command. Use repeated snapshots only for debugging, local testing, or when the user explicitly asks for a one-shot check.
Do not stop to ask the user whether to continue polling; continue autonomously until a strict stop condition is met or the user explicitly interrupts.
Do not hand control back to the user after a review-fix push just because a new SHA was created; restarting the watcher and re-entering the poll loop is part of the same babysitting task.
If a process is still running and no strict stop condition has been reached, the babysitting task is still in progress; keep streaming/consuming watcher output instead of ending the turn.
--watch--once--watch在Codex实时会话中使用以下循环:
- 运行。
--once - 读取。
actions - 首先检查PR是否已合并或关闭;如果是,报告该终止状态并立即停止轮询。
- 检查CI摘要、新的评审项以及可合并性/冲突状态。
- 诊断CI失败并分类为分支相关或不稳定/无关。
- 当同时存在可操作的评审评论和不稳定重试时,优先处理评审评论;如果评审修复需要提交,推送后跳过在旧SHA上重新运行失败的检查。
- 仅当存在且你不打算用评审/CI修复提交替换当前SHA时,才重试失败的检查。
retry_failed_checks - 如果你推送了提交或触发了重新运行,简要报告操作并继续轮询(不要停止)。
- 推送评审修复后,除非已满足严格的停止条件,否则在同一轮操作中主动重启持续监控()。
--watch - 如果所有检查通过、可合并、未被所需的评审批准阻塞,且没有未处理的评审项,报告成功并停止。
- 如果遇到需要用户介入的阻塞问题(基础设施中断、不稳定重试次数耗尽、不明确的评审请求、权限问题),报告阻塞问题并停止。
- 否则按照以下轮询节奏等待后重复。
当用户明确要求监控/查看/保姆式看护PR时,优先使用模式,以便通过一个命令自主持续轮询。仅在调试、本地测试或用户明确要求一次性检查时,才使用重复的快照。
不要停下来询问用户是否继续轮询;自主继续,直到满足严格的停止条件或用户明确中断。
不要因为创建了新的SHA就将控制权交还给用户;重启监控器并重新进入轮询循环是同一个保姆式监控任务的一部分。
如果进程仍在运行且未满足严格的停止条件,保姆式监控任务仍在进行中;继续流式接收/处理监控器的输出,不要结束当前操作。
--watch--once--watchPolling Cadence
轮询节奏
Use adaptive polling and continue monitoring even after CI turns green:
- While CI is not green (pending/running/queued or failing): poll every 1 minute.
- After CI turns green: start at every 1 minute, then back off exponentially when there is no change (for example 1m, 2m, 4m, 8m, 16m, 32m), capping at every 1 hour.
- Reset the green-state polling interval back to 1 minute whenever anything changes (new commit/SHA, check status changes, new review comments, mergeability changes, review decision changes).
- If CI stops being green again (new commit, rerun, or regression): return to 1-minute polling.
- If any poll shows the PR is merged or otherwise closed: stop polling immediately and report the terminal state.
使用自适应轮询,即使CI变绿后仍继续监控:
- 当CI未变绿时(待处理/运行中/排队中或失败):每分钟轮询一次。
- CI变绿后:从每分钟轮询一次开始,当无变化时指数级增加间隔(例如1分钟、2分钟、4分钟、8分钟、16分钟、32分钟),最大间隔为1小时。
- 每当发生任何变化时(新提交/SHA、检查状态变化、新评审评论、可合并性变化、评审决策变化),将绿态轮询间隔重置为1分钟。
- 如果CI再次变绿失败(新提交、重新运行或回归):恢复为每分钟轮询一次。
- 如果任何一次轮询显示PR已合并或关闭:立即停止轮询并报告终止状态。
Stop Conditions (Strict)
严格停止条件
Stop only when one of the following is true:
- PR merged or closed (stop as soon as a poll/snapshot confirms this).
- PR is ready to merge: CI succeeded, no surfaced unaddressed review comments, not blocked on required review approval, and no merge conflict risk.
- User intervention is required and Codex cannot safely proceed alone.
Keep polling when:
- contains only
actionsbut checks are still pending.idle - CI is still running/queued.
- Review state is quiet but CI is not terminal.
- CI is green but mergeability is unknown/pending.
- CI is green and mergeable, but the PR is still open and you are waiting for possible new review comments or merge-conflict changes per the green-state cadence.
- The PR is green but blocked on review approval (/ similar); continue polling on the green-state cadence and surface any new review comments without asking for confirmation to keep watching.
REVIEW_REQUIRED
仅当满足以下任一条件时才停止:
- PR已合并或关闭(一旦轮询/快照确认,立即停止)。
- PR准备就绪可合并:CI执行成功,无未处理的评审评论,未被所需的评审批准阻塞,且无合并冲突风险。
- 需要用户介入且Codex无法安全独立处理。
以下情况继续轮询:
- 仅包含
actions但检查仍在进行中。idle - CI仍在运行/排队中。
- 评审状态安静但CI未达到终止状态。
- CI已变绿但可合并性未知/待处理。
- CI已变绿且可合并,但PR仍处于开放状态,你需要根据绿态节奏等待可能的新评审评论或合并冲突变化。
- PR已变绿但被评审批准阻塞(/ 类似状态);按照绿态节奏继续轮询,无需确认即可提取新的评审评论。
REVIEW_REQUIRED
Output Expectations
输出期望
Provide concise progress updates while monitoring and a final summary that includes:
-
During long unchanged monitoring periods, avoid emitting a full update on every poll; summarize only status changes plus occasional heartbeat updates.
-
Treat push confirmations, intermediate CI snapshots, and review-action updates as progress updates only; do not emit the final summary or end the babysitting session unless a strict stop condition is met.
-
A user request to "monitor" is not satisfied by a couple of sample polls; remain in the loop until a strict stop condition or an explicit user interruption.
-
A review-fix commit + push is not a completion event; immediately resume live monitoring () in the same turn and continue reporting progress updates.
--watch -
When CI first transitions to all green for the current SHA, emit a one-time celebratory progress update (do not repeat it on every green poll). Preferred style:
🚀 CI is all green! 33/33 passed. Still on watch for review approval. -
Do not send the final summary while a watcher terminal is still running unless the watcher has emitted/confirmed a strict stop condition; otherwise continue with progress updates.
-
Final PR SHA
-
CI status summary
-
Mergeability / conflict status
-
Fixes pushed
-
Flaky retry cycles used
-
Remaining unresolved failures or review comments
监控期间提供简洁的进度更新,最终提供包含以下内容的总结:
-
在长时间无变化的监控期间,避免每次轮询都发出完整更新;仅总结状态变化和偶尔的心跳更新。
-
仅将推送确认、中间CI快照和评审操作更新视为进度更新;除非满足严格的停止条件,否则不要发出最终总结或结束保姆式监控会话。
-
用户的“监控”请求不会通过几次示例轮询就满足;保持循环直到满足严格的停止条件或用户明确中断。
-
评审修复提交+推送不是完成事件;在同一轮操作中立即恢复实时监控()并继续报告进度更新。
--watch -
当当前SHA的CI首次全部变绿时,发出一次性的庆祝性进度更新(不要在每次绿态轮询时重复)推荐格式:
🚀 CI全部通过!33/33项检查通过。仍在监控评审批准状态。 -
除非监控器已发出/确认严格的停止条件,否则不要在监控器终端仍在运行时发送最终总结;否则继续提供进度更新。
-
最终PR SHA
-
CI状态摘要
-
可合并性/冲突状态
-
已推送的修复
-
使用的不稳定重试周期
-
剩余未解决的失败或评审评论
References
参考资料
- Heuristics and decision tree:
.codex/skills/babysit-pr/references/heuristics.md - GitHub CLI/API details used by the watcher:
.codex/skills/babysit-pr/references/github-api-notes.md
- 启发式规则和决策树:
.codex/skills/babysit-pr/references/heuristics.md - 监控器使用的GitHub CLI/API细节:
.codex/skills/babysit-pr/references/github-api-notes.md