github-pr-agent-workflows
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub PR Agent Workflows
GitHub PR Agent工作流
Overview
概述
Use this skill for agent-oriented pull request loops: prepare the PR, wait for checks, wait for review activity, inspect feedback, make follow-up changes, and report the final state. Prefer the bundled scripts for repeatable review polling and review-thread summaries.
本技能适用于面向Agent的拉取请求循环:准备PR、等待检查、等待审核活动、查看反馈、进行后续变更并报告最终状态。对于可重复的审核轮询和审核线程汇总,建议使用捆绑的脚本。
Quick Commands
快速命令
Watch checks, then review activity:
bash
scripts/pr-agent-watch.sh 123 -R OWNER/REPO --checks-timeout 30m --review-timeout 2hWait for review activity:
bash
scripts/wait-pr-review.sh 123 -R OWNER/REPO --timeout 30m --interval 60sSummarize current review state:
bash
scripts/pr-review-summary.sh 123 -R OWNER/REPOPrint parseable review state:
bash
scripts/pr-review-summary.sh 123 -R OWNER/REPO --jsonWait for CI checks with :
ghbash
gh pr checks 123 -R OWNER/REPO --watch --interval 10Use the system command when a bounded check wait is required:
timeoutbash
timeout 30m gh pr checks 123 -R OWNER/REPO --watch --interval 10监控检查,然后监控审核活动:
bash
scripts/pr-agent-watch.sh 123 -R OWNER/REPO --checks-timeout 30m --review-timeout 2h等待审核活动:
bash
scripts/wait-pr-review.sh 123 -R OWNER/REPO --timeout 30m --interval 60s汇总当前审核状态:
bash
scripts/pr-review-summary.sh 123 -R OWNER/REPO输出可解析的审核状态:
bash
scripts/pr-review-summary.sh 123 -R OWNER/REPO --json使用等待CI检查:
ghbash
gh pr checks 123 -R OWNER/REPO --watch --interval 10当需要限定检查等待时间时,使用系统命令:
timeoutbash
timeout 30m gh pr checks 123 -R OWNER/REPO --watch --interval 10Agent Loop
Agent循环
- Identify the PR and repository.
Use or accept an explicit PR number and
gh pr view --json number,url,headRefName,baseRefName,reviewDecision,mergeStateStatus,statusCheckRollup.-R OWNER/REPO - Snapshot the PR before waiting.
Run when review feedback may matter.
scripts/pr-review-summary.sh - Wait for CI when validation gates the next action.
Use when the agent should wait for checks and review feedback in one loop. Use
scripts/pr-agent-watch.shfor checks-only waits.gh pr checks --watch - Wait for reviewer activity when the next action depends on feedback.
Use ; prefer
scripts/wait-pr-review.shafter the agent has already handled current feedback.--ignore-existing - Inspect comments before editing.
Use the review summary script, preferably with when automation needs to parse unresolved threads. Use
--jsonorgh pr view --commentswhen bodies or locations need deeper inspection.gh api repos/{owner}/{repo}/pulls/{pull_number}/comments --paginate - Address feedback in a small patch. Do not rewrite unrelated files. Preserve user changes in the worktree.
- Run the relevant checks locally. Keep validation proportional to the changed area.
- Push or report. Push only when that is part of the task. Merge only when the user explicitly asked for merge behavior.
- 确定PR和仓库。
使用命令,或者直接指定PR编号和
gh pr view --json number,url,headRefName,baseRefName,reviewDecision,mergeStateStatus,statusCheckRollup参数。-R OWNER/REPO - 在等待前快照PR状态。
若审核反馈很重要,运行脚本。
scripts/pr-review-summary.sh - 当验证环节会影响下一步操作时,等待CI完成。
若Agent需要在一个循环中同时等待检查和审核反馈,使用脚本。仅需等待检查时,使用
scripts/pr-agent-watch.sh命令。gh pr checks --watch - 当下一步操作依赖反馈时,等待审核者活动。
使用脚本;若Agent已处理当前反馈,建议添加
scripts/wait-pr-review.sh参数。--ignore-existing - 在编辑前查看评论。
使用审核汇总脚本,若自动化需要解析未解决线程,建议添加参数。若需要深入查看评论内容或位置,使用
--json或gh pr view --comments命令。gh api repos/{owner}/{repo}/pulls/{pull_number}/comments --paginate - 以小补丁形式处理反馈。 不要重写无关文件,保留工作区中的用户变更。
- 本地运行相关检查。 验证范围与变更区域相匹配。
- 推送或报告状态。 仅当任务要求时才推送代码。仅当用户明确要求合并操作时才执行合并。
Decision Rules
决策规则
- If checks fail, inspect the failing check logs before changing code.
- If exits
wait-pr-review.sh, inspect review threads and review decisions before editing.0 - If exits
wait-pr-review.sh, report that no matching review activity arrived before the timeout.124 - If exits because checks are still pending or the wrapper timeout fires, report the pending state instead of guessing.
gh pr checks --watch - If the PR is approved and checks pass, stop unless the user asked for merge or follow-up automation.
- If review feedback conflicts with the user request, summarize the conflict and ask before making a risky change.
- 如果检查失败,在修改代码前先查看失败检查的日志。
- 如果脚本返回退出码
wait-pr-review.sh,在编辑前先查看审核线程和审核决策。0 - 如果脚本返回退出码
wait-pr-review.sh,报告在超时前未收到匹配的审核活动。124 - 如果因检查仍在进行或包装超时而退出,报告待处理状态而非猜测结果。
gh pr checks --watch - 如果PR已获批准且检查通过,除非用户要求合并或后续自动化操作,否则停止流程。
- 如果审核反馈与用户请求冲突,汇总冲突情况并在进行风险变更前询问用户。
Bundled Scripts
捆绑脚本
scripts/pr-agent-watch.sh
scripts/pr-agent-watch.shscripts/pr-agent-watch.sh
scripts/pr-agent-watch.shWait for PR checks, then wait for review activity and print a review summary when feedback arrives.
Common options:
--checks-timeout 30m--checks-interval 10s--review-timeout 2h--review-interval 60s--review-mode any|comments|review|approval|changes-requested--ignore-existing-review--skip-checks--skip-review
Exit codes:
- : ready; checks passed and review wait was skipped
0 - : review activity found and summarized
10 - : checks failed or were cancelled
20 - : checks timed out
21 - : review wait timed out
22 - : usage, PR resolution, or GitHub API error
2
等待PR检查完成,然后等待审核活动,当收到反馈时输出审核汇总。
常用选项:
--checks-timeout 30m--checks-interval 10s--review-timeout 2h--review-interval 60s--review-mode any|comments|review|approval|changes-requested--ignore-existing-review--skip-checks--skip-review
退出码:
- : 就绪;检查通过且跳过审核等待
0 - : 发现审核活动并已汇总
10 - : 检查失败或被取消
20 - : 检查超时
21 - : 审核等待超时
22 - : 使用错误、PR解析错误或GitHub API错误
2
scripts/wait-pr-review.sh
scripts/wait-pr-review.shscripts/wait-pr-review.sh
scripts/wait-pr-review.shPoll a pull request until matching review activity appears or the timeout expires.
Common options:
--timeout 30m--interval 60s--mode any|comments|review|approval|changes-requested--ignore-existing
Exit codes:
- : matching review activity found
0 - : timeout
124 - : usage, PR resolution, or GitHub API error
2
轮询拉取请求,直到出现匹配的审核活动或超时。
常用选项:
--timeout 30m--interval 60s--mode any|comments|review|approval|changes-requested--ignore-existing
退出码:
- : 发现匹配的审核活动
0 - : 超时
124 - : 使用错误、PR解析错误或GitHub API错误
2
scripts/pr-review-summary.sh
scripts/pr-review-summary.shscripts/pr-review-summary.sh
scripts/pr-review-summary.shPrint PR state, latest reviews, pending review requests, and unresolved review threads with file locations and comment URLs. Use for parseable output that includes unresolved thread counts, comment URLs, authors, timestamps, and bodies.
--json输出PR状态、最新审核记录、待处理审核请求,以及包含文件位置和评论链接的未解决审核线程。使用参数可输出可解析的结果,其中包含未解决线程数量、评论链接、作者、时间戳和评论内容。
--json