iterate-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIterate on PR Until CI Passes
迭代PR直至CI检查通过
Goal: fix actionable CI failures and high/medium review feedback. Stop and report human approval, draft-readiness, and merge-readiness gates.
Requires:
- authenticated
gh uv- target repository root as cwd
- skill-root-relative script paths, for example
scripts/fetch_pr_checks.py
目标:修复可执行的CI失败问题,处理高/中优先级的评审反馈。遇到人工批准、草稿就绪和合并就绪闸门时,需停止并上报。
前置要求:
- 已认证的
gh uv- 当前工作目录为目标仓库的根目录
- 脚本路径相对于技能根目录,例如
scripts/fetch_pr_checks.py
Bundled Scripts
内置脚本
| Script | Run | Output |
|---|---|---|
| | JSON: |
| | JSON buckets: |
| | terminal marker plus tab-separated checks |
| | JSON reply results |
Check summary fields include , , , and .
failedpendingactionable_pendinghuman_gate_pendingMonitor markers:
ALL_CHECKS_PASSEDCHECKS_DONE_WITH_FAILURESNO_CHECKS_REGISTEREDDRAFT_PR_WITH_NO_CHECKSCHECKS_BLOCKED_BY_REVIEW_GATE
| 脚本 | 运行命令 | 输出 |
|---|---|---|
| | JSON格式数据:包含 |
| | JSON分类数据: |
| | 终端标记符加制表符分隔的检查任务信息 |
| | JSON格式的回复结果 |
检查摘要字段包含、、和。
failedpendingactionable_pendinghuman_gate_pending监控标记符:
ALL_CHECKS_PASSEDCHECKS_DONE_WITH_FAILURESNO_CHECKS_REGISTEREDDRAFT_PR_WITH_NO_CHECKSCHECKS_BLOCKED_BY_REVIEW_GATE
Workflow
工作流程
1. Identify PR
1. 确定目标PR
Run:
bash
gh pr view --json number,url,headRefName,isDraft,reviewDecisionStop when:
- no PR exists
- draft PR has no checks after monitor grace period: report
DRAFT_PR_WITH_NO_CHECKS
Draft rule: inspect existing checks/feedback only. Do not mark ready for review unless asked.
运行命令:
bash
gh pr view --json number,url,headRefName,isDraft,reviewDecision在以下情况时停止:
- 不存在对应PR
- 草稿PR在监控宽限期后仍无检查任务:上报
DRAFT_PR_WITH_NO_CHECKS
草稿规则:仅检查现有任务/反馈。除非被要求,否则不要标记为可评审状态。
2. Handle Feedback
2. 处理评审反馈
Run .
uv run scripts/fetch_pr_feedback.py [--pr NUMBER]| Bucket | Action |
|---|---|
| fix |
| fix |
| ask user which to address |
| skip informational comments |
| skip |
Feedback fix checklist:
- verify root cause
- search related code
- fix all instances
- for : fix real issues, explain false positives
review_bot: true
Low-priority prompt format:
text
Found 3 low-priority suggestions:
1. [l] "Consider renaming this variable" - @reviewer in api.py:42
2. [nit] "Could use a list comprehension" - @reviewer in utils.py:18
3. [style] "Add a docstring" - @reviewer in models.py:55
Which should I address? ("1,3", "all", or "none")运行。
uv run scripts/fetch_pr_feedback.py [--pr NUMBER]| 分类 | 操作 |
|---|---|
| 修复 |
| 修复 |
| 询问用户需要处理哪些 |
| 跳过信息性评论 |
| 跳过 |
反馈修复检查清单:
- 验证根本原因
- 搜索相关代码
- 修复所有相关实例
- 若为:修复真实问题,解释误报情况
review_bot: true
低优先级建议提示格式:
text
发现3条低优先级建议:
1. [l] "考虑重命名此变量" - @reviewer 在 api.py:42
2. [nit] "可使用列表推导式" - @reviewer 在 utils.py:18
3. [style] "添加文档字符串" - @reviewer 在 models.py:55
需要处理哪些?(输入"1,3"、"all"或"none")3. Check CI Status
3. 检查CI状态
Run .
uv run scripts/fetch_pr_checks.py [--pr NUMBER]| State | Action |
|---|---|
| fix failures |
| wait; poll feedback while waiting |
| report |
| no checks after grace period | report |
| all actionable checks passed | run post-CI feedback check |
Wait for actionable review bots: sentry, warden, cursor, bugbot, seer, codeql.
Do not wait for approval, , , Codecov, or informational bots.
isDraftREVIEW_REQUIRED运行。
uv run scripts/fetch_pr_checks.py [--pr NUMBER]| 状态 | 操作 |
|---|---|
| 修复失败问题 |
| 等待;等待期间轮询反馈 |
| 上报 |
| 宽限期后仍无检查任务 | 上报 |
| 所有可执行检查通过 | 执行CI后反馈检查 |
等待可自动处理的评审机器人:sentry、warden、cursor、bugbot、seer、codeql。
无需等待人工批准、状态、、Codecov或信息类机器人。
isDraftREVIEW_REQUIRED4. Fix CI Failures
4. 修复CI失败问题
For each failure:
- read full log:
gh run view <run-id> --log-failed - trace from assertion/exception/lint rule to source
- state the cause before editing: "fails because X, affected by Y"
- search related call sites/patterns
- fix root cause, not symptom
- add focused test coverage when needed
针对每个失败问题:
- 查看完整日志:
gh run view <run-id> --log-failed - 从断言/异常/lint规则追踪到源代码
- 在编辑前说明原因:"失败原因是X,受Y影响"
- 搜索相关调用位置/模式
- 修复根本原因,而非表面症状
- 必要时添加针对性测试覆盖
5. Verify Locally, Then Commit and Push
5. 本地验证后提交并推送
Before commit:
- test fix: rerun specific test
- lint/type fix: rerun affected checker
- code fix: rerun covering tests
- local failure: fix before pushing
bash
git add <files>
git commit -m "fix: <descriptive message>"
git push提交前:
- 测试修复:重新运行特定测试
- 代码规范/类型修复:重新运行相关检查工具
- 代码修复:重新运行覆盖性测试
- 本地失败:推送前修复
bash
git add <files>
git commit -m "fix: <描述性信息>"
git push6. Monitor CI and Address Feedback
6. 监控CI并处理新反馈
Loop:
- run
uv run scripts/fetch_pr_checks.py - handle table in step 3
- while , run
actionable_pending > 0uv run scripts/fetch_pr_feedback.py - fix new high/medium feedback immediately
- if changed, verify, commit, push, restart loop
- otherwise sleep 30 seconds and repeat
- after checks pass, wait 10 seconds, fetch feedback once more
- if new high/medium feedback exists, return to step 4
Claude Code optional: run through with ; set timeout to normal repo CI duration. Restart the monitor after every push.
uv run scripts/monitor_pr_checks.pyMonitorToolpersistent: false循环执行:
- 运行
uv run scripts/fetch_pr_checks.py - 按照步骤3的表格处理状态
- 当时,运行
actionable_pending > 0uv run scripts/fetch_pr_feedback.py - 立即处理新的高/中优先级反馈
- 若有修改,验证后提交、推送,重启循环
- 否则等待30秒后重复执行
- 检查通过后,等待10秒,再次获取反馈
- 若存在新的高/中优先级反馈,返回步骤4
可选使用Claude Code:通过运行,设置;超时时间设为仓库常规CI时长。每次推送后重启监控。
MonitorTooluv run scripts/monitor_pr_checks.pypersistent: falseExit Conditions
退出条件
| Exit | Conditions |
|---|---|
| Success | actionable CI passed; post-CI feedback clean; low-priority choice handled |
| Ask user | same failure after 2 attempts; feedback unclear; infrastructure issue |
| Stop | no PR; branch needs rebase; no checks; draft no-checks; only human gates remain |
| 退出状态 | 条件 |
|---|---|
| 成功 | 可执行的CI检查通过;CI后反馈无问题;低优先级选项已处理 |
| 询问用户 | 同一失败问题尝试2次后仍未解决;反馈不明确;基础设施问题 |
| 停止 | 无PR;分支需要变基;无检查任务;草稿PR无检查任务;仅剩余人工闸门 |
Fallback
备选方案
If scripts fail, use CLI directly:
ghgh pr view --json number,url,headRefName,isDraft,reviewDecisiongh pr checks --json name,state,bucket,description,linkgh run view <run-id> --log-failedgh api repos/{owner}/{repo}/pulls/{number}/comments
如果脚本执行失败,直接使用 CLI:
ghgh pr view --json number,url,headRefName,isDraft,reviewDecisiongh pr checks --json name,state,bucket,description,linkgh run view <run-id> --log-failedgh api repos/{owner}/{repo}/pulls/{number}/comments