babysit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Babysit a PR

照看PR

Claude Code analog of Cursor's built-in
/babysit
. The implementation is a loop over
gh
CLI plus the Claude Code
loop
skill for pacing.
Platform note. On Codex, the Claude tool names and Claude built-in skills named below (
loop
,
AskUserQuestion
) are Claude defaults. Resolve them via
codex-tools.md
.
Inside poteto-mode, the Babysit playbook (
../poteto-mode/playbooks/babysit.md
) supersedes this skill: it owns mode declaration, the merge frontier, stack safety, and the
watch-pr
watcher. This skill stays the standalone
/babysit
entry point for a single PR outside a poteto-mode run.
这是Cursor内置
/babysit
功能在Claude Code中的对应实现。其实现基于
gh
CLI循环调用,搭配Claude Code的
loop
技能来控制节奏。
平台说明:在Codex上,下文提及的Claude工具名称和Claude内置技能(
loop
AskUserQuestion
)均为Claude默认项。可通过
codex-tools.md
解析它们。
在poteto-mode中,Babysit剧本(
../poteto-mode/playbooks/babysit.md
)会替代本技能:它负责模式声明、合并边界、栈安全以及
watch-pr
监控器。本技能是poteto-mode运行之外,单个PR的独立
/babysit
入口。

When to use

使用场景

  • There's an open PR and the user explicitly wants it kept green, and you are not already inside a poteto-mode run (the playbook owns that case).
  • The user invokes
    /babysit
    directly.
  • A subagent that opens a PR does NOT babysit — return to the parent and let the parent decide.
  • 存在已开启的PR,且用户明确希望保持PR状态正常,同时当前未处于poteto-mode运行中(该场景由剧本接管)。
  • 用户直接调用
    /babysit
  • 创建PR的子Agent不负责照看——需返回至父Agent,由父Agent决定后续操作。

Steps

步骤

  1. Fetch PR state.
    bash
    gh pr view <number> --json number,title,state,mergeable,reviewDecision,statusCheckRollup,mergeStateStatus,comments,reviews
  2. Triage in priority order.
    • Merge conflicts (
      mergeStateStatus == DIRTY
      ): rebase or merge
      main
      ; resolve; force-push only if the branch is yours and not shared.
    • Failing checks (
      statusCheckRollup
      entries with
      conclusion: FAILURE
      ): pull logs with
      gh run view <run-id> --log-failed
      . Root-cause the failure; fix the underlying code or test; commit; push.
    • Review comments (
      gh pr view --json comments,reviews
      ): act only on feedback you actually agree with. When a comment has a single mechanical answer — a rename, a guard clause, a formatting nit — make the edit and quote the comment in the commit message. When it hinges on a judgement call, or you can't tell what's being asked, don't guess: leave it and reply with what you would have done.
    • Review-bot comments (Bugbot and similar automation): classify fix/dismiss/ask before acting, per
      references/bugbot-triage.md
      . Ask by default on security, data, and high-severity findings.
  3. Loop. Use the Claude Code
    loop
    skill to pace re-checks. Pick the interval from what you're watching:
    • Active CI run: poll
      gh pr checks --watch
      (it blocks until checks finish, so no separate loop interval needed).
    • Awaiting reviewer: 20–30 min heartbeat.
    • Idle but want to catch new comments: hourly.
  4. When to stop.
    • Build is green, every comment resolved, branch merges cleanly → call it ready.
    • You've run three rounds of fix → push → recheck and it still isn't fully green → stop, summarise what's still broken, and hand control back.
    • The next fix would force a design choice → pause and put it to the user with
      AskUserQuestion
      .
  5. Report. Summarize fixes applied, comments addressed, comments deferred (with reason), current PR status. Cite each commit by SHA.
  1. 获取PR状态
    bash
    gh pr view <number> --json number,title,state,mergeable,reviewDecision,statusCheckRollup,mergeStateStatus,comments,reviews
  2. 按优先级分类处理
    • 合并冲突(
      mergeStateStatus == DIRTY
      ):变基或合并
      main
      分支;解决冲突;仅当分支为你所有且未共享时,才进行强制推送。
    • 检查失败(
      statusCheckRollup
      conclusion: FAILURE
      的条目):使用
      gh run view <run-id> --log-failed
      拉取日志。定位失败根本原因;修复底层代码或测试;提交;推送。
    • 评审评论(
      gh pr view --json comments,reviews
      ):仅处理你确实认同的反馈。当评论只需机械性修改——重命名、添加守卫子句、格式调整——直接修改,并在提交信息中引用该评论。当涉及判断决策,或你无法理解要求时,不要猜测:保留现状并回复你的处理思路。
    • 评审机器人评论(Bugbot及类似自动化工具):根据
      references/bugbot-triage.md
      ,先分类为修复/驳回/询问再操作。对于安全、数据和高严重性问题,默认选择询问。
  3. 循环监控:使用Claude Code的
    loop
    技能控制重新检查的节奏。根据监控内容选择间隔:
    • 活跃CI运行:轮询
      gh pr checks --watch
      (该命令会阻塞直到检查完成,因此无需单独设置循环间隔)。
    • 等待评审:20–30分钟一次心跳检查。
    • 空闲但需捕获新评论:每小时检查一次。
  4. 停止条件
    • 构建正常、所有评论已解决、分支可干净合并→标记为就绪。
    • 已完成三轮“修复→推送→重新检查”循环但仍未完全正常→停止,总结仍存在的问题,交回控制权。
    • 下一次修复需要做出设计选择→暂停,使用
      AskUserQuestion
      询问用户。
  5. 报告:总结已应用的修复、已处理的评论、已推迟的评论(含原因)、当前PR状态。通过SHA引用每个提交。

Hard rules

硬性规则

  • Don't rewrite history on a branch others may have pulled. If a rebase or force-push looks necessary, clear it with the user first.
  • Don't tweak a test's expected values just to get a pass. Only change an assertion when the behaviour genuinely changed and the assertion was pinned to the old behaviour.
  • Never skip hooks (
    --no-verify
    ).
  • Never bypass a failing check by marking it as not required.
  • gh pr ready
    only when all checks are green and no unresolved review comments remain.
  • 不要重写其他人可能已拉取的分支历史。若需要变基或强制推送,先征得用户同意。
  • 不要仅为了通过检查而修改测试的预期值。仅当行为确实改变且断言仍绑定旧行为时,才修改断言。
  • 绝不跳过钩子(
    --no-verify
    )。
  • 绝不通过标记为非必需来绕过失败的检查。
  • 仅当所有检查正常且无未解决的评审评论时,才使用
    gh pr ready

Cross-refs

交叉引用

  • poteto-mode
    opens here after a PR is opened.
  • Use
    interrogate
    before opening if the diff is contested; once open, babysit takes over.
  • Use
    unslop
    on any prose you write here (PR comments, commit messages, status reports).
  • PR创建后,poteto-mode从此处启动。
  • 若差异存在争议,在创建PR前使用
    interrogate
    ;创建后,由babysit接管。
  • 在此处编写的任何文案(PR评论、提交信息、状态报告)需使用
    unslop
    处理。

Provenance

来源说明

This is a Claude Code analog of Cursor's
/babysit
, not a port — Cursor's implementation is closed source. The skill is independently authored, with its own prose and structure; the workflow is informed by Cursor's public
/babysit
behavior. The only overlap with other PR tools is the
gh
CLI commands it runs, which are functional invocations rather than copied text.
这是Cursor
/babysit
功能在Claude Code中的对应实现,而非移植——Cursor的实现为闭源。本技能为独立开发,拥有自己的文案和结构;工作流参考了Cursor公开的
/babysit
行为。与其他PR工具的唯一重叠是所使用的
gh
CLI命令,这些是功能性调用,而非复制的文本。