fusion-github-review-resolution
equinor/fusion-skills
端到端解决未解决的 GitHub PR 审查线程:评估每条审查评论是否正确,若有效则应用针对性修复,若无效则附上理由进行回复,提交代码,并关闭该线程。 适用场景:未解决的评审线程、PR 评审反馈、需要修改的 PR、PR 评审链接(#pullrequestreview-...)、修正评审评论、关闭未解决的线程、处理 PR 反馈。不适用场景:仅总结反馈而不修改代码、创建新 PR 或只读分支。
...展开全部关于“fusion-github-review-resolution”
这项实验性技能提供了一个可重复、可审计的工作流,用于端到端地解决未解决的 GitHub 拉取请求审查线程。 针对每条评审评论,该技能会评估反馈是否确实正确;若反馈有效,则应用针对性的代码修复;若反馈无效,则附上理由进行回复;随后提交更改并关闭该讨论线程——从而将零散的“请求修改”反馈转化为一个确定性的闭环流程。 它解决了审查修复过程中临时性、易出错的问题——在传统方式中,操作人员会将 GitHub 操作与代码编辑混杂在一起,从而难以追踪哪些线程已处理。
该技能强制执行严格的阶段顺序(获取、分析、修复、验证、推送、回复、解决、核查),能从评审 URL 中自动提取所有者/仓库/PR/评审 ID,并使用一份有效的检查清单文档来跟踪每个线程。 在可用时,它优先使用 GitHub MCP 服务器提供的结构化代码审查线程工具;否则,将回退到捆绑的按操作划分的 GraphQL 资源,或基于 `gh` 的 shell 辅助脚本(get-review-comments.sh 和 resolve-review-comments.sh),这些脚本支持按代码审查 ID 范围进行数据收集以及“先干跑后解决”的处理方式。 该工具具备 GraphQL 成本意识——控制变异操作的频率、遵守 retry-after 请求头,并防止重复回复——并将提交、验证及 PR 策略的处理交由仓库本地规则决定。
目标用户是希望对 PR 评审反馈进行自动化、受控处理的工程团队(最初源自 Equinor 的 Fusion Core 团队)。 该工具确实会执行写入操作——提交代码、推送分支、发布回复以及解决讨论线程——但这些操作均通过官方 GitHub 工具和 git 实现,并受分支/工作树确认、验证命令以及判断反馈正确性的规则约束,而非盲目应用反馈。 不存在破坏性或数据外泄行为;其风险特征与标准认证仓库自动化一致。
常见问题
该技能运行需要什么?
根据其兼容性元数据,该技能需要 GitHub MCP 服务器或 gh CLI,以及 git。它优先使用支持结构化审查线程的 MCP 工具,若不可用则回退到捆绑的 GraphQL 资源或基于 gh 的 shell 辅助工具。
它会自动推送代码并解决讨论线程吗?
是的,在受管控的工作流中。它会按照固定的“拉取-验证”阶段顺序,应用针对性修复、提交、推送、附带理由的回复,并解决讨论线程。它首先确认分支/工作树上下文,并将提交、验证和 PR 规则交由仓库本地策略处理。
它会盲目应用每一条代码审查评论吗?
不会。其核心规则是:必须判断每条评论是否确实正确,仅在反馈有效时才应用修复;若不同意则附理由回复;若评论含糊不清则征询用户意见。
何时不应使用它?
当没有未解决的审阅评论时;仅需汇总反馈而不希望修改代码时;讨论串已解决时;或者分支/工作树被有意设置为只读时,请勿使用该功能。
它如何避免触发 GitHub 的速率限制?
该工具具备 GraphQL 成本意识:记录每次变异和每次查询的点成本,在连续变异之间暂停至少一秒,遵守 retry-after 请求头,并保护 resolve 脚本免受已认证用户重复回复的影响。
所有文件
10 个文件assets/add-pull-request-review-thread-reply.graphql0.2 KB查看assets/resolve-review-thread.graphql0.2 KB查看CHANGELOG.md5.6 KB查看SKILL.md14.4 KB 查看assets/pull-request-reviews.graphql 0.3 KB 查看assets/unresolved-thread-count-for-review.graphql 0.4 KB 查看scripts/resolve-review-comments.sh 11.8 KB 查看 assets/pull-request-review-threads.graphql 0.7 KB 查看 assets/review-resolution-checklist.md 2.8 KB 查看 scripts/get-review-comments.sh 5.5 KB 查看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>https://github.com/<owner>/<repo>/pull/<number>(when context implies review work)
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
When not to use
- No unresolved review comments exist
- Request is only to summarize or describe feedback without code changes
- All targeted threads are already resolved or outdated and acknowledged
- 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 (e.g.
pullrequestreview-<id>) - branch/worktree decision (skip asking if the current checkout is already on the PR's head branch — see step 1)
- required validation commands for the repository
When a review URL is provided (
github.com/<owner>/<repo>/pull/<number>#pullrequestreview-<id>),auto-extract owner, repo, PR number, and review id from it.Only branch/worktree choice and validation commands still need confirming.
Optional:
- linked issue reference (e.g.
equinor/fusion-core-tasks#432) - commit granularity preference when comments overlap the same file
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.
Determine branch/worktree context
- Check the current checkout's branch against the PR's head branch first.
- If the current branch already matches the PR's head branch, proceed directly there — do not ask about a worktree.
- Otherwise (current branch differs, or the workspace is on a shared/long-lived branch like
main/master), ask whether to use a dedicated git worktree 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
#pullrequestreview-<id>was provided, parse owner, repo, PR number, and review id from it before fetching. - Copy or open
assets/review-resolution-checklist.md—this becomes your working document. Fill in the context section and update the comment tracking table as you work through each thread. - 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
gh apiretry loops.
- 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
scripts/get-review-comments.shto fetch matching review comments (including sub-comments associated with the review id). - 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
--include-outdatedwhen you need comments from outdated matching threads. - Use
scripts/resolve-review-comments.shto reply+resolve matching threads with a dry-run-first duplicate-reply guard. - Keep default dry-run behavior; use
--applyonly after fixes are committed and pushed. - By default the script refuses to add another authenticated-user reply to a thread that already contains one; use
--allow-additional-replyonly after manual inspection. - 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
Tooling map (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 | mcp_github_update_pull_request | Works for collaborator reviewers and standard PR updates. |
| Create or submit PR review | mcp_github_pull_request_review_write | Handles pending review lifecycle actions. |
| Add general PR comment | mcp_github_add_issue_comment | Adds issue-style comment to PR conversation, not inline thread reply. |
| List review threads and comments | assets/pull-request-review-threads.graphql | Use with gh api graphql -f query=@assets/pull-request-review-threads.graphql for thread-level context. |
| Count unresolved threads for specific review id | assets/unresolved-thread-count-for-review.graphql | Post-process response (for example with jq) to filter by review id and unresolved state. |
| Reply to a review thread | Dedicated MCP review-thread reply tool, otherwise assets/add-pull-request-review-thread-reply.graphql | Prefer the MCP tool when available; otherwise use the bundled thread-scoped mutation instead of ad hoc scripts. |
| Resolve a review thread | Dedicated MCP review-thread resolve tool, otherwise assets/resolve-review-thread.graphql | Use the matching structured tool for the current client/session. resolveReviewThread uses threadId, not pullRequestReviewThreadId. |
| List PR reviews (review URL/id lookup support) | assets/pull-request-reviews.graphql | Useful when starting from review URL context. |
Pro tip: See each
.graphqlfile in assets for complete mutation/query syntax and parameter names.
GraphQL cost awareness
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
first/lastconnection arguments small (preferfirst: 100only when you need all threads in a single page). - If a secondary rate-limit error or
retry-afterheader is returned, stop processing and respect the indicated wait before retrying. - Always prefer a dedicated MCP review-thread tool over raw GraphQL when the client exposes one.
Token budget guidance
- 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.
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.
Safety & constraints
- This skill is mutation-capable. Repository-local workflow instructions take precedence over inline guidance when they conflict.
- 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
--applyfor mutations.
所有文件
0 个文件安装 fusion-github-review-resolution
下载技能文件并将其解压到 .claude/skills/ 目录中。
下载ZIP克隆仓库并复制技能文件到您的项目中。
git clone https://github.com/equinor/fusion-skills/blob/main/skills/.experimental/fusion-github-review-resolution/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
复制





首页
