fusion-github-review-resolution
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseResolve GitHub Review Comments
处理GitHub评审评论
When to use
适用场景
Use this skill when a pull request has unresolved inline review comments and you need a repeatable, auditable closure workflow.
Typical triggers (skill should activate on all of these):
URL patterns — activate immediately:
https://github.com/<owner>/<repo>/pull/<number>#pullrequestreview-<id>- (when context implies review work)
https://github.com/<owner>/<repo>/pull/<number>
Explicit user requests:
- "Fix the review comments"
- "Address the review feedback on this PR"
- "There are unresolved review comments — fix them"
- "Resolve the conversations on this PR"
- "Handle all unresolved comments on this PR"
- "For each review comment: fix, test, commit, reply, resolve"
- "Close the open review threads"
- "Check this review and resolve the conversation when fixed"
- "Resolve outstanding review feedback"
- "The PR has changes requested — fix it"
Implicit / agent-detected:
- A PR is in "changes requested" state and the agent is asked to work on it
- A PR has unresolved review threads and the user asks to improve or merge the PR
- An agent working on a PR detects open review conversations
当拉取请求(PR)存在未处理的内联评审评论,且你需要一个可重复、可审计的闭环工作流时,可使用此技能。
典型触发条件(满足任意一个即可激活技能):
URL模式 — 立即触发:
https://github.com/<owner>/<repo>/pull/<number>#pullrequestreview-<id>- (上下文涉及评审工作时)
https://github.com/<owner>/<repo>/pull/<number>
用户明确请求:
- "修复评审评论"
- "处理此PR的评审反馈"
- "存在未处理的评审评论 — 修复它们"
- "解决此PR上的对话"
- "处理此PR上所有未处理的评论"
- "针对每条评审评论:修复、测试、提交、回复、标记为已处理"
- "关闭未处理的评审线程"
- "检查此评审,修复后标记对话为已处理"
- "解决未处理的评审反馈"
- "此PR被标记为需要修改 — 修复它"
隐式/Agent自动检测:
- PR处于“需要修改”状态,且Agent被要求处理该PR
- PR存在未处理的评审线程,且用户要求改进或合并该PR
- 处理PR的Agent检测到未关闭的评审对话
When not to use
不适用场景
Do not use this skill when:
- no unresolved review comments exist,
- the request is only to summarize or describe feedback without making code changes,
- all targeted threads are already resolved or outdated and acknowledged,
- the branch/worktree is intentionally read-only.
在以下场景请勿使用此技能:
- 不存在未处理的评审评论时
- 请求仅为汇总或描述反馈,无需修改代码时
- 目标线程已全部处理或已过时且得到确认时
- 分支/工作树为只读状态时
Required inputs
必要输入项
Collect before execution:
- repository owner/name,
- pull request number or URL,
- optional review id to scope comments (for example ),
pullrequestreview-<id> - branch/worktree decision,
- required validation commands for the repository.
When a review URL is provided (), auto-extract owner, repo, PR number, and review id from it. Only branch/worktree choice and validation commands still need confirming.github.com/<owner>/<repo>/pull/<number>#pullrequestreview-<id>
Optional context:
- linked issue reference (for example ),
equinor/fusion-core-tasks#432 - commit granularity preference when comments overlap the same file.
执行前需收集:
- 仓库所有者/名称,
- PR编号或URL,
- 可选的评审ID(用于限定评论范围,例如),
pullrequestreview-<id> - 分支/工作树选择,
- 仓库所需的验证命令。
若提供评审URL(), 自动从中提取所有者、仓库、PR编号和评审ID。 仅需确认分支/工作树选择和验证命令即可。github.com/<owner>/<repo>/pull/<number>#pullrequestreview-<id>
可选上下文:
- 关联的问题引用(例如),
equinor/fusion-core-tasks#432 - 当评论涉及同一文件时的提交粒度偏好。
Instructions
操作步骤
Follow this phase order unless the user explicitly asks for a different sequence: fetch → analyze → fix → validate → push → reply → resolve → verify. Do not interleave GitHub thread mutations with code-editing retries.
-
Ask whether to use a dedicated git worktree
- Ask this before any other workflow questions.
- If yes, use/create the worktree and continue there.
-
Gather unresolved comments and create working tracker
- If a review URL with was provided, parse owner, repo, PR number, and review id from it before fetching.
#pullrequestreview-<id> - Copy or open —this becomes your working document. Fill in the context section and update the comment tracking table as you work through each thread.
assets/review-resolution-checklist.md - Fetch review threads for the PR and filter unresolved threads.
- If a specific review id or review URL is provided, limit to comments from that review.
- Within the targeted review, collect all comments associated with that review id (do not include replies from other reviews unless explicitly requested).
- Build a working list with: thread id, comment id, parent review id, file path, original comment body, and all subsequent replies in that thread (including contributor replies).
- Read the full reply chain for each thread — contributors may have added clarifications, constraints, or additional context that must be taken into account when deciding how to resolve the comment.
- Capture a baseline list of targeted thread ids and unresolved-thread count before any GitHub mutation.
- If a review URL with
-
Understand, research, and judge each comment
- Read the referenced file(s) and nearby logic.
- Decide whether the feedback is correct, partially correct, outdated, or incorrect against the current code, requirements, and surrounding context.
- Reviewers are not automatically correct; do not make code churn just to satisfy a comment that is stale or wrong.
- If the feedback is correct, verify root cause and identify the smallest safe fix.
- If the feedback is clearly incorrect or outdated, prepare a concise evidence-based reply instead of changing code unnecessarily.
- If uncertain, inspect adjacent tests/usages before editing.
- If doubt remains after local research, ask the user before making code changes or mutating that review thread.
-
Fix, check, commit (per comment)
- Apply focused code/doc changes only for comments you judged valid or partially valid.
- Run targeted checks first, then required repo checks.
- Create one commit per comment when practical.
- If two comments require one inseparable change, use one commit and map both comments to that commit in replies.
- For comments you decline, record the reasoning in the tracker so the eventual reply is explicit and auditable.
-
Push once after all fixes
- After all comment-related commits are created, push branch updates once.
-
Reply and resolve each review comment
- Before any thread mutation, prefer structured tooling in this order:
- dedicated GitHub MCP review-thread reply/resolve tools exposed in the current client session,
- the bundled GraphQL assets or bundled ,
scripts/resolve-review-comments.sh - never ad hoc temporary Python scripts, one-off batch helpers, or blind retry loops.
gh api
- Prepare exactly one planned reply per targeted thread from the checklist/tracker before posting anything.
- Re-fetch the current thread state before retrying if a reply/resolve attempt errors, times out, or returns an uncertain result.
- For each thread, these two steps are mandatory and must happen together in order unless the thread is still uncertain and waiting for user input:
- Post a reply on the thread: either describe what changed and include the commit hash(es), or explain why no code change was made because the comment is incorrect/outdated.
- Resolve the thread immediately after the reply is posted — never before.
- Post at most one reply attempt per thread per run.
- If an equivalent agent-authored reply already exists, do not post another reply; reuse it and only resolve if the thread is still unresolved.
- If a different agent-authored reply already exists, stop and inspect manually rather than stacking another comment.
- Do not resolve a thread that is still uncertain; escalate it to the user first.
- Never resolve a thread without a reply. Never post a reply without then resolving the thread.
- Keep replies specific: name the file/line changed and the commit, not just "fixed".
- Before any thread mutation, prefer structured tooling in this order:
-
Verify closure state
- Re-check review threads and confirm no targeted unresolved threads remain.
- Confirm the targeted unresolved-thread count dropped to zero and no duplicate agent replies were created during this run.
- Re-check latest CI status if the workflow expects green checks.
-
Ask whether to request a new review from the original review author
- After fixes are pushed and threads are resolved, ask if the user wants to request a new review from the author of the review comments.
- If yes, request review from that reviewer username and report that the request was sent.
-
Optional scripted execution
- Use to fetch matching review comments (including sub-comments associated with the review id).
scripts/get-review-comments.sh - Results are limited to the first 100 review threads and first 100 comments per thread.
- Example test:
skills/.experimental/fusion-github-review-resolution/scripts/get-review-comments.sh --owner equinor --repo fusion-skills --pr 27 --review-id 3837647674
- Use when you need comments from outdated matching threads.
--include-outdated - Use to reply+resolve matching threads with a dry-run-first duplicate-reply guard.
scripts/resolve-review-comments.sh - Keep default dry-run behavior; use only after fixes are committed and pushed.
--apply - By default the script refuses to add another authenticated-user reply to a thread that already contains one; use only after manual inspection.
--allow-additional-reply - Example dry-run:
skills/.experimental/fusion-github-review-resolution/scripts/resolve-review-comments.sh --owner equinor --repo fusion-skills --pr 27 --review-id 3837647674 --include-resolved
- Example apply:
skills/.experimental/fusion-github-review-resolution/scripts/resolve-review-comments.sh --owner equinor --repo fusion-skills --pr 27 --review-id 3837647674 --apply --message "Addressed in <commit>: <what changed>."
- Use
除非用户明确要求变更顺序,否则请遵循以下阶段顺序:获取→分析→修复→验证→推送→回复→标记为已处理→验证。请勿将GitHub线程操作与代码编辑重试交叉进行。
-
询问是否使用专用的git worktree
- 此问题需在其他工作流问题之前提出。
- 若为是,则创建或使用该worktree并继续后续操作。
-
收集未处理评论并创建工作跟踪表
- 若提供带的评审URL,先从中解析所有者、仓库、PR编号和评审ID,再获取评论。
#pullrequestreview-<id> - 复制或打开——此文件将作为你的工作文档。 填写上下文部分,并在处理每个线程时更新评论跟踪表。
assets/review-resolution-checklist.md - 获取PR的评审线程并筛选未处理的线程。
- 若提供特定评审ID或评审URL,仅处理该评审中的评论。
- 在目标评审中,收集所有与该评审ID关联的评论(除非明确要求,否则不包含其他评审的回复)。
- 创建工作列表,包含:线程ID、评论ID、父评审ID、文件路径、原始评论内容以及该线程中的所有后续回复(包括贡献者的回复)。
- 阅读每个线程的完整回复链——贡献者可能添加了澄清、约束或其他上下文,这些内容在决定如何处理评论时必须考虑。
- 在执行任何GitHub操作前,记录目标线程ID和未处理线程的初始数量。
- 若提供带
-
理解、调研并判断每条评论
- 阅读引用的文件及相关逻辑。
- 根据当前代码、需求和相关上下文,判断反馈是否合理、部分合理、已过时或不合理。
- 评审者的意见并非绝对正确;请勿仅为满足已过时或错误的评论而修改代码。
- 若反馈合理,验证根本原因并确定最小的安全修复方案。
- 若反馈明显不合理或已过时,准备简洁的、有依据的回复,无需修改代码。
- 若不确定,先检查相关测试/用法再进行编辑。
- 若本地调研后仍有疑问,在修改代码或操作评审线程前先询问用户。
-
修复、检查、提交(逐条评论处理)
- 仅对判断为合理或部分合理的评论进行针对性代码/文档修改。
- 先运行针对性检查,再运行仓库要求的检查。
- 若可行,为每条评论创建一个提交。
- 若两条评论需要不可分割的修改,则创建一个提交,并在回复中关联这两条评论。
- 对于拒绝处理的评论,在跟踪表中记录理由,最终的回复需明确且可审计。
-
所有修复完成后一次性推送
- 完成所有与评论相关的提交后,一次性推送分支更新。
-
回复并标记每条评审评论为已处理
- 在执行任何线程操作前,优先按以下顺序使用结构化工具:
- 当前客户端会话中提供的专用GitHub MCP评审线程回复/标记工具,
- 内置的GraphQL资源或内置的,
scripts/resolve-review-comments.sh - 禁止使用临时Python脚本、一次性批量工具或盲目重试循环。
gh api
- 在发布任何内容前,根据检查清单/跟踪表为每个目标线程准备好确切的回复内容。
- 若回复/标记尝试出错、超时或返回不确定结果,重新获取当前线程状态后再重试。
- 对于每个线程,以下两个步骤是必须的,且需按顺序执行(除非线程仍存在疑问,需等待用户输入):
- 在线程中发布回复:要么说明修改内容并附上提交哈希,要么解释为何未修改代码(因为评论不合理/已过时)。
- 回复发布后立即标记线程为已处理——切勿提前标记。
- 每次运行时,每个线程最多尝试发布一次回复。
- 若Agent已发布过等效回复,请勿重复发布;直接复用该回复,若线程仍未处理则标记为已处理。
- 若存在其他Agent发布的不同回复,请停止操作并手动检查,切勿叠加新评论。
- 请勿标记仍存在疑问的线程为已处理;需先将其升级给用户处理。
- 切勿不回复就标记线程为已处理。切勿回复后不标记线程为已处理。
- 回复需具体:说明修改的文件/行和提交哈希,而非仅说“已修复”。
- 在执行任何线程操作前,优先按以下顺序使用结构化工具:
-
验证闭环状态
- 重新检查评审线程,确认所有目标未处理线程已处理完毕。
- 确认目标未处理线程数量已降至零,且本次运行未创建重复的Agent回复。
- 若工作流要求CI检查通过,重新检查最新CI状态。
-
询问是否向原评审作者请求重新评审
- 修复推送且线程标记为已处理后,询问用户是否需要向评审评论的作者请求重新评审。
- 若为是,则向该评审者发送评审请求并告知用户。
-
可选的脚本执行模式
- 使用获取匹配的评审评论(包括与评审ID关联的子评论)。
scripts/get-review-comments.sh - 结果限制为前100条评审线程和每条线程前100条评论。
- 测试示例:
skills/.experimental/fusion-github-review-resolution/scripts/get-review-comments.sh --owner equinor --repo fusion-skills --pr 27 --review-id 3837647674
- 若需获取已过时的匹配线程评论,使用参数。
--include-outdated - 使用回复并标记匹配线程,默认启用 dry-run 模式以避免重复回复。
scripts/resolve-review-comments.sh - 保持默认dry-run行为;仅在修复提交并推送后使用参数。
--apply - 默认情况下,若线程中已存在当前认证用户的回复,脚本会拒绝添加新回复;仅在手动检查后使用参数。
--allow-additional-reply - Dry-run示例:
skills/.experimental/fusion-github-review-resolution/scripts/resolve-review-comments.sh --owner equinor --repo fusion-skills --pr 27 --review-id 3837647674 --include-resolved
- 执行示例:
skills/.experimental/fusion-github-review-resolution/scripts/resolve-review-comments.sh --owner equinor --repo fusion-skills --pr 27 --review-id 3837647674 --apply --message "Addressed in <commit>: <what changed>."
- 使用
Tooling map (MCP vs GraphQL)
工具映射(MCP vs GraphQL)
Use GitHub MCP tools for high-level PR operations and any dedicated review-thread mutations the current client exposes. Use GraphQL for thread-level review operations when MCP coverage is missing.
| Workflow action | Preferred tool | Notes |
|---|---|---|
| Request reviewer / update PR metadata | | Works for collaborator reviewers and standard PR updates. |
| Create or submit PR review | | Handles pending review lifecycle actions. |
| Add general PR comment | | Adds issue-style comment to PR conversation, not inline thread reply. |
| List review threads and comments | | Use with |
| Count unresolved threads for specific review id | | Post-process response (for example with |
| Reply to a review thread | | Prefer the MCP tool when available; otherwise use the bundled thread-scoped mutation instead of ad hoc scripts. |
| Resolve a review thread | | Use the matching structured tool for the current client/session. ⚠️ GraphQL note: |
| List PR reviews (review URL/id lookup support) | | Useful when starting from review URL context. |
Pro tip: See eachfile in assets for complete mutation/query syntax and parameter names..graphql
使用GitHub MCP工具处理高层PR操作和当前客户端提供的任何专用评审线程操作。当MCP未覆盖线程级评审操作时,使用GraphQL。
| 工作流操作 | 首选工具 | 说明 |
|---|---|---|
| 请求评审者 / 更新PR元数据 | | 适用于协作者评审者和标准PR更新。 |
| 创建或提交PR评审 | | 处理待处理评审的生命周期操作。 |
| 添加通用PR评论 | | 向PR对话添加议题式评论,而非内联线程回复。 |
| 列出评审线程和评论 | | 使用 |
| 统计特定评审ID的未处理线程数量 | | 对响应进行后处理(例如使用 |
| 回复评审线程 | | 优先使用MCP工具(若可用);否则使用内置的线程范围操作,而非临时脚本。 |
| 标记评审线程为已处理 | | 使用当前客户端/会话对应的结构化工具。⚠️ GraphQL注意事项: |
| 列出PR评审(支持评审URL/ID查找) | | 从评审URL上下文开始处理时非常有用。 |
小贴士: 查看目录下的每个assets文件,获取完整的操作语法和参数名称。.graphql
GraphQL cost awareness
GraphQL成本注意事项
Review-resolution workflows make multiple GraphQL mutation calls (reply + resolve per thread). Be conservative:
- Mutations cost 5 secondary-limit points each (vs 1 for read queries). Budget accordingly when processing many threads.
- Pause at least 1 second between consecutive mutation calls to avoid secondary rate limits.
- Keep /
firstconnection arguments small (preferlastonly when you need all threads in a single page).first: 100 - If a secondary rate-limit error or header is returned, stop processing and respect the indicated wait before retrying.
retry-after - Always prefer a dedicated MCP review-thread tool over raw GraphQL when the client exposes one.
评审处理工作流会发起多个GraphQL操作(每条线程回复+标记各一次)。请谨慎使用:
- 每个操作消耗5个二级限制点数(查询仅消耗1个)。处理多个线程时请合理预算。
- 连续操作之间至少暂停1秒,避免触发二级速率限制。
- 保持/
first连接参数较小(仅当需要一次性获取所有线程时才使用last)。first: 100 - 若收到二级速率限制错误或头,停止处理并在指定时间后重试。
retry-after - 若客户端提供专用MCP评审线程工具,始终优先使用该工具而非原生GraphQL。
Token budget guidance
Token预算指南
- Fetch the full thread list once and reuse it for all per-thread work; do not re-fetch threads between reply and resolve.
- Budget estimate: for N unresolved threads expect ~1 list call + N reply mutations + N resolve mutations = 1 + 2N calls. A 10-thread review costs ~21 calls.
- If the thread count exceeds 15, warn the user about rate-limit risk before starting mutations and offer to batch in smaller groups.
- Cache PR metadata (title, branch, CI status, changed files) from the first fetch and reuse it for commit messages and replies.
- Avoid redundant PR-level reads between steps; the data does not change within a single resolution run.
- 一次性获取完整线程列表并复用,无需在回复和标记之间重新获取线程。
- 预算估算:处理N条未处理线程需要约1次列表查询 + N次回复操作 + N次标记操作 = 1 + 2N次调用。处理10条线程的评审约需21次调用。
- 若线程数量超过15条,在开始操作前警告用户存在速率限制风险,并提供分批处理选项。
- 从首次获取中缓存PR元数据(标题、分支、CI状态、变更文件),并在提交消息和回复中复用。
- 避免在步骤之间重复读取PR级数据;在单次处理运行中数据不会发生变化。
Expected output
预期输出
Return a concise report containing:
- comments processed count,
- disposition summary (fixed, declined with rationale, escalated to user),
- files changed,
- commit list (hash + message),
- validation commands run and outcomes,
- confirmation of push,
- reply/resolve confirmation per thread,
- completed checklist location,
- any remaining unresolved threads or blockers.
返回简洁的报告,包含:
- 处理的评论数量,
- 处理结果汇总(已修复、附理由拒绝、升级给用户),
- 修改的文件,
- 提交列表(哈希 + 消息),
- 运行的验证命令及结果,
- 推送确认,
- 每条线程的回复/标记确认,
- 已完成的检查清单位置,
- 剩余的未处理线程或障碍。
Linked issue usage
关联问题用法
When an issue is provided (for example ):
equinor/fusion-core-tasks#432- mention the issue in progress/final summaries,
- keep implementation aligned with issue scope,
- avoid expanding to unrelated PR automation.
当提供关联问题(例如):
equinor/fusion-core-tasks#432- 在进度/最终汇总中提及该问题,
- 确保实现与问题范围一致,
- 避免扩展到无关的PR自动化操作。
Safety & constraints
安全与约束
- Never expose secrets or tokens in logs/replies.
- Prefer argv-based process execution over shell-interpolated command strings.
- Keep diffs minimal and scoped to review feedback.
- Do not assume review feedback is correct; reason about it against the code and requirements first.
- If a comment remains ambiguous after research, ask the user instead of guessing.
- Do not resolve a thread without posting a concrete fix reply.
- Do not claim checks passed unless commands were actually run.
- Do not force-push; use regular commits and a single push after all fixes.
- If a comment is outdated but still unresolved, either:
- resolve with a clear explanation and commit reference, or
- leave unresolved and report why.
- In scripted mode, keep default dry-run behavior and require explicit for mutations.
--apply
- 切勿在日志/回复中暴露密钥或令牌。
- 优先使用基于参数的进程执行而非shell插值命令字符串。
- 保持代码差异最小化,仅针对评审反馈进行修改。
- 请勿默认认为评审反馈合理;需先结合代码和需求进行判断。
- 若调研后评论仍不明确,询问用户而非猜测。
- 切勿不发布具体修复回复就标记线程为已处理。
- 除非实际运行了命令,否则请勿声称检查已通过。
- 请勿强制推送;使用常规提交并在所有修复完成后一次性推送。
- 若评论已过时但仍未处理,可选择:
- 标记为已处理并附上清晰的解释和提交引用,或
- 保持未处理并说明原因。
- 在脚本模式下,保持默认dry-run行为,需显式使用参数执行操作。
--apply