ralph-wiggum-loop

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Ralph Wiggum Loop

Ralph Wiggum Loop

Purpose

用途

Automate an iterative Copilot-driven review loop: trigger a GitHub Copilot review, address its feedback one comment at a time, then re-trigger Copilot to review again. Repeat up to 2 cycles until all critical issues are resolved.
Named after Ralph Wiggum: the agent keeps asking Copilot "is this better now?" until it's satisfied — or gives up after 2 tries.
自动化由Copilot驱动的迭代审查循环:触发GitHub Copilot审查,逐条处理其反馈意见,然后重新触发Copilot进行再次审查。最多重复2轮循环,直至所有关键问题得到解决。
该技能以Ralph Wiggum命名:Agent会不断询问Copilot“现在这样更好了吗?”,直到满意为止——或者在尝试2次后放弃。

Prerequisites

前置条件

  • gh
    CLI (required)
  • gh-copilot-review
    extension (recommended — see
    references/gh-copilot-review-guide.md
    )
    bash
    gh extension install ChrisCarini/gh-copilot-review
    Fallback if not installed:
    gh pr review --request copilot
  • pr-review-loop
    skill (optional — if installed, the inner loop is delegated to it)
  • The PR branch must be checked out locally
  • gh
    CLI(必填)
  • gh-copilot-review
    扩展(推荐——详见
    references/gh-copilot-review-guide.md
    bash
    gh extension install ChrisCarini/gh-copilot-review
    未安装时的替代方案:
    gh pr review --request copilot
  • pr-review-loop
    skill(可选——若已安装,内部循环将委托给该技能处理)
  • 已在本地检出PR分支

Process

流程

Step 1 — Pre-flight

步骤1 — 预检

Inspect the project for safeguard conventions by checking these files (if they exist):
  • CLAUDE.md
    ,
    AGENTS.md
  • Makefile
  • .github/workflows/
  • README.md
Identify all required safeguards (tests, compilation, linting, formatting, etc.). Run all of them. If any fail, stop immediately and report — do not proceed.
通过检查以下文件(若存在)来核查项目的防护约定:
  • CLAUDE.md
    AGENTS.md
  • Makefile
  • .github/workflows/
  • README.md
确定所有必需的防护措施(测试、编译、代码检查、格式化等)。执行所有防护检查。若任何检查失败,立即停止并上报——不得继续执行。

Step 2 — Outer loop (max 2 iterations)

步骤2 — 外部循环(最多2次迭代)

Repeat up to 2 times:
最多重复2次:

2a. Request Copilot review

2a. 请求Copilot审查

Check if
gh-copilot-review
extension is installed:
bash
gh extension list | grep copilot-review
If installed (preferred):
bash
gh copilot-review [<number> | <url>]
If not installed (fallback):
bash
gh pr review --request copilot
检查是否已安装
gh-copilot-review
扩展:
bash
gh extension list | grep copilot-review
若已安装(优先使用):
bash
gh copilot-review [<number> | <url>]
若未安装(替代方案):
bash
gh pr review --request copilot

2b. Wait for Copilot to complete

2b. 等待Copilot完成审查

Read
references/gh-copilot-review-guide.md
for the polling approach.
Record the current count of unresolved
copilot[bot]
comments before triggering. Poll every 15 seconds until new comments appear. If no new comments after 3 minutes, stop and report timeout — do not proceed.
查阅
references/gh-copilot-review-guide.md
了解轮询方法。
在触发审查前记录未解决的
copilot[bot]
评论数量。每15秒轮询一次,直至出现新评论。若3分钟后仍无新评论,停止执行并上报超时——不得继续。

2c. Collect unresolved Copilot comments

2c. 收集未解决的Copilot评论

Fetch all unresolved comments authored by
copilot[bot]
. Ignore comments from human reviewers (those are handled by the
pr-review-loop
skill).
bash
gh api repos/{owner}/{repo}/pulls/{pr}/comments \
  --jq '.[] | select(.user.login == "copilot[bot]") | select(.resolved == false)'
If there are no unresolved Copilot comments, stop — nothing to do.
获取所有由
copilot[bot]
发布的未解决评论。忽略人类评审者的评论(此类评论由
pr-review-loop
skill处理)。
bash
gh api repos/{owner}/{repo}/pulls/{pr}/comments \
  --jq '.[] | select(.user.login == "copilot[bot]") | select(.resolved == false)'
若不存在未解决的Copilot评论,停止执行——无需进一步操作。

2d. Address comments — inner loop

2d. 处理评论——内部循环

If
pr-review-loop
skill is available:
Invoke the
pr-review-loop
skill, passing only the Copilot comments collected in step 2c as the scope. It will handle triage, one-at-a-time fixes, and replies.
If
pr-review-loop
skill is NOT available:
Follow this process for each comment, one at a time (MUST_FIX first, then SHOULD_FIX):
Triage categories (see below):
  • MUST_FIX: blocking correctness issue, security flaw, or broken build
  • SHOULD_FIX: non-blocking improvement worth addressing
  • PARK: valid but out of scope for this PR — reply with reasoning, open follow-up issue
  • OUT_OF_SCOPE: does not apply — reply with rejection reasoning
For each MUST_FIX and SHOULD_FIX comment:
  1. Assess complexity:
    • Trivial (rename, small fix): fix directly
    • Non-trivial: write plan to
      .pr-review/plan-<comment-id>.md
      first
  2. Run safeguards — all must pass before touching code
  3. Fix or park the comment
  4. Run safeguards again — all must pass
  5. Commit and push:
    bash
    git add <changed files>
    git commit -m "<conventional commit describing the fix>"
    git push
  6. Reply to the comment — explain fix, deferral, or rejection
  7. Resolve the comment on GitHub
  8. Delete plan file if one was created:
    bash
    rm .pr-review/plan-<comment-id>.md
pr-review-loop
skill可用:
调用
pr-review-loop
skill,仅将步骤2c中收集的Copilot评论作为范围传入。该技能将负责分类、逐条修复及回复。
pr-review-loop
skill不可用:
逐条处理每条评论(优先处理MUST_FIX,再处理SHOULD_FIX):
分类类别(详见下文):
  • MUST_FIX:阻碍正确性的问题、安全漏洞或构建失败
  • SHOULD_FIX:非阻塞性的优化建议,值得处理
  • PARK:有效但超出当前PR范围——回复说明理由,开启后续跟进Issue
  • OUT_OF_SCOPE:不适用——回复拒绝理由
对于每条MUST_FIX和SHOULD_FIX评论:
  1. 评估复杂度:
    • 简单(重命名、小修复):直接修复
    • 复杂:先将修复方案写入
      .pr-review/plan-<comment-id>.md
  2. 执行防护检查——在修改代码前必须全部通过
  3. 修复或搁置该评论
  4. 再次执行防护检查——必须全部通过
  5. 提交并推送:
    bash
    git add <changed files>
    git commit -m "<符合约定式提交规范的修复描述>"
    git push
  6. 回复评论——说明修复内容、延期处理或拒绝理由
  7. 在GitHub上标记该评论为已解决
  8. 若已创建方案文件则删除:
    bash
    rm .pr-review/plan-<comment-id>.md

2e. Check stop conditions

2e. 检查停止条件

Stop iterating if any of:
  • No MUST_FIX Copilot comments remain after this pass
  • Only OUT_OF_SCOPE Copilot comments remain
  • This was the 2nd iteration
Otherwise continue to the next iteration (back to step 2a).
若满足以下任一条件,停止迭代:
  • 本轮处理后无剩余MUST_FIX类型的Copilot评论
  • 仅剩余OUT_OF_SCOPE类型的Copilot评论
  • 已完成第2次迭代
否则继续下一轮迭代(返回步骤2a)。

Step 3 — Summary

步骤3 — 总结

Post a final comment on the PR:
undefined
在PR中发布最终评论:
undefined

Ralph Wiggum Loop — Summary

Ralph Wiggum Loop — 总结

Completed N Copilot review cycle(s).
已完成N轮Copilot审查循环。

Fixed

已修复

  • [commit abc1234] <description> (Copilot comment #<id>)
  • ...
  • [提交 abc1234] <描述>(Copilot评论 #<id>
  • ...

Parked

已搁置

  • <description> — deferred, tracked in #<issue>
  • ...
  • <描述> — 已延期,跟踪于#<Issue编号>
  • ...

Rejected

已拒绝

  • <description><reason>
  • ...
undefined
  • <描述> — <理由>
  • ...
undefined

Resumability

可恢复性

This skill can be interrupted and restarted in a fresh context at any point.
On restart:
  1. Run pre-flight (Step 1)
  2. Check for an existing
    .pr-review/plan-*.md
    — if found, continue mid-fix from step 2d
  3. Re-fetch unresolved Copilot comments — already-resolved ones won't appear
  4. Continue the outer loop from the current state
该技能可在任意节点中断,并在全新上下文环境中重启。
重启时:
  1. 执行预检(步骤1)
  2. 检查是否存在
    .pr-review/plan-*.md
    文件——若存在,从步骤2d的修复中途继续
  3. 重新获取未解决的Copilot评论——已解决的评论不会显示
  4. 从当前状态继续执行外部循环

State Directory

状态目录

.pr-review/
at the repo root (should be gitignored by the project).
  • plan-<comment-id>.md
    — plan for the comment currently in progress (deleted after resolution)
仓库根目录下的
.pr-review/
(项目应将其加入git忽略规则)。
  • plan-<comment-id>.md
    — 当前处理中评论的修复方案(解决后删除)