ralph-wiggum-loop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRalph 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
前置条件
- CLI (required)
gh - extension (recommended — see
gh-copilot-review)references/gh-copilot-review-guide.mdFallback if not installed:bashgh extension install ChrisCarini/gh-copilot-reviewgh pr review --request copilot - skill (optional — if installed, the inner loop is delegated to it)
pr-review-loop - The PR branch must be checked out locally
- CLI(必填)
gh - 扩展(推荐——详见
gh-copilot-review)references/gh-copilot-review-guide.md未安装时的替代方案:bashgh extension install ChrisCarini/gh-copilot-reviewgh pr review --request copilot - skill(可选——若已安装,内部循环将委托给该技能处理)
pr-review-loop - 已在本地检出PR分支
Process
流程
Step 1 — Pre-flight
步骤1 — 预检
Inspect the project for safeguard conventions by checking these files (if they exist):
- ,
CLAUDE.mdAGENTS.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.mdAGENTS.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 extension is installed:
gh-copilot-reviewbash
gh extension list | grep copilot-reviewIf installed (preferred):
bash
gh copilot-review [<number> | <url>]If not installed (fallback):
bash
gh pr review --request copilot检查是否已安装扩展:
gh-copilot-reviewbash
gh extension list | grep copilot-review若已安装(优先使用):
bash
gh copilot-review [<number> | <url>]若未安装(替代方案):
bash
gh pr review --request copilot2b. Wait for Copilot to complete
2b. 等待Copilot完成审查
Read for the polling approach.
references/gh-copilot-review-guide.mdRecord the current count of unresolved 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.
copilot[bot]查阅了解轮询方法。
references/gh-copilot-review-guide.md在触发审查前记录未解决的评论数量。每15秒轮询一次,直至出现新评论。若3分钟后仍无新评论,停止执行并上报超时——不得继续。
copilot[bot]2c. Collect unresolved Copilot comments
2c. 收集未解决的Copilot评论
Fetch all unresolved comments authored by . Ignore comments from
human reviewers (those are handled by the skill).
copilot[bot]pr-review-loopbash
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.
获取所有由发布的未解决评论。忽略人类评审者的评论(此类评论由 skill处理)。
copilot[bot]pr-review-loopbash
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 skill is available:
Invoke the skill, passing only the Copilot comments collected
in step 2c as the scope. It will handle triage, one-at-a-time fixes, and replies.
pr-review-looppr-review-loopIf skill is NOT available:
Follow this process for each comment, one at a time (MUST_FIX first, then SHOULD_FIX):
pr-review-loopTriage 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:
-
Assess complexity:
- Trivial (rename, small fix): fix directly
- Non-trivial: write plan to first
.pr-review/plan-<comment-id>.md
-
Run safeguards — all must pass before touching code
-
Fix or park the comment
-
Run safeguards again — all must pass
-
Commit and push:bash
git add <changed files> git commit -m "<conventional commit describing the fix>" git push -
Reply to the comment — explain fix, deferral, or rejection
-
Resolve the comment on GitHub
-
Delete plan file if one was created:bash
rm .pr-review/plan-<comment-id>.md
若 skill可用:
调用 skill,仅将步骤2c中收集的Copilot评论作为范围传入。该技能将负责分类、逐条修复及回复。
pr-review-looppr-review-loop若 skill不可用:
逐条处理每条评论(优先处理MUST_FIX,再处理SHOULD_FIX):
pr-review-loop分类类别(详见下文):
- MUST_FIX:阻碍正确性的问题、安全漏洞或构建失败
- SHOULD_FIX:非阻塞性的优化建议,值得处理
- PARK:有效但超出当前PR范围——回复说明理由,开启后续跟进Issue
- OUT_OF_SCOPE:不适用——回复拒绝理由
对于每条MUST_FIX和SHOULD_FIX评论:
-
评估复杂度:
- 简单(重命名、小修复):直接修复
- 复杂:先将修复方案写入
.pr-review/plan-<comment-id>.md
-
执行防护检查——在修改代码前必须全部通过
-
修复或搁置该评论
-
再次执行防护检查——必须全部通过
-
提交并推送:bash
git add <changed files> git commit -m "<符合约定式提交规范的修复描述>" git push -
回复评论——说明修复内容、延期处理或拒绝理由
-
在GitHub上标记该评论为已解决
-
若已创建方案文件则删除: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中发布最终评论:
undefinedRalph 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- <描述> — <理由>
- ...
undefinedResumability
可恢复性
This skill can be interrupted and restarted in a fresh context at any point.
On restart:
- Run pre-flight (Step 1)
- Check for an existing — if found, continue mid-fix from step 2d
.pr-review/plan-*.md - Re-fetch unresolved Copilot comments — already-resolved ones won't appear
- Continue the outer loop from the current state
该技能可在任意节点中断,并在全新上下文环境中重启。
重启时:
- 执行预检(步骤1)
- 检查是否存在文件——若存在,从步骤2d的修复中途继续
.pr-review/plan-*.md - 重新获取未解决的Copilot评论——已解决的评论不会显示
- 从当前状态继续执行外部循环
State Directory
状态目录
.pr-review/- — plan for the comment currently in progress (deleted after resolution)
plan-<comment-id>.md
仓库根目录下的(项目应将其加入git忽略规则)。
.pr-review/- — 当前处理中评论的修复方案(解决后删除)
plan-<comment-id>.md