一键导入
pr-review-response
Teaches agents to reply to PR review comment threads after fixing issues, making resolutions traceable
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Teaches agents to reply to PR review comment threads after fixing issues, making resolutions traceable
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
{what this skill teaches agents}
{what this skill teaches agents}
{what this skill teaches agents}
{what this skill teaches agents}
Checklist and patterns for wiring new CLI commands into cli-entry.ts
Team initialization flow (Phase 1 proposal + Phase 2 creation)
| name | pr-review-response |
| description | Teaches agents to reply to PR review comment threads after fixing issues, making resolutions traceable |
| domain | pull-requests, code-review, traceability |
| confidence | low |
| source | observed (agents fix review feedback silently — reviewers can't tell which comments were addressed) |
| tools | [{"name":"github-mcp-server-pull_request_read","description":"Read PR review threads and comments","when":"Step 1 — fetching review comments to understand what needs fixing"},{"name":"gh api (REST)","description":"Reply to review comment threads and resolve threads via GraphQL","when":"Step 3 — posting reply to each comment thread after fixing"}] |
When an agent fixes code in response to PR review comments (from Copilot, a human reviewer, or any GitHub reviewer), the fix alone is not enough. The reviewer needs to see — on the PR thread itself — which comments were addressed and how. Without replies, comments stay visually unresolved, reviewers must re-read the entire diff to verify fixes, and there's no traceable link between feedback and resolution.
Use this skill whenever:
✅ THIS SKILL PRODUCES:
❌ THIS SKILL DOES NOT PRODUCE:
Using MCP tools (preferred when available):
github-mcp-server-pull_request_read
method: "get_review_comments"
owner: "{owner}"
repo: "{repo}"
pullNumber: {pr_number}
This returns review threads with metadata: isResolved, isOutdated, isCollapsed, and their associated comments. Each comment has an id you'll need for replies.
Using gh CLI (fallback):
gh api repos/{owner}/{repo}/pulls/{pr_number}/comments --paginate
Each comment object contains id, body, path, line, and in_reply_to_id. Top-level comments have no in_reply_to_id — those are the ones you reply to.
Make the actual code changes. This is your normal domain work — the skill doesn't prescribe how to fix, only how to communicate the fix.
Track what you changed. For each review comment, note:
id (top-level, not a reply)After fixing and committing, reply to each review comment thread individually.
REST API call (via gh CLI):
gh api repos/{owner}/{repo}/pulls/{pr_number}/comments/{comment_id}/replies \
-f body="Fixed in {sha_short} — {brief description of what was changed}"
Important: {comment_id} must be the ID of the top-level comment in the thread. You cannot reply to a reply — only to the original review comment.
Example replies:
# Specific and traceable
gh api repos/bradygaster/squad/pulls/42/comments/18234/replies \
-f body="Fixed in a1b2c3d — switched to path.dirname(squadDirInfo.path) for worktree consistency"
# When applying a suggested code change
gh api repos/bradygaster/squad/pulls/42/comments/18235/replies \
-f body="Applied suggestion — updated error message to include the file path for debuggability"
# When pushing back on a suggestion
gh api repos/bradygaster/squad/pulls/42/comments/18236/replies \
-f body="Considered but not applied — this path needs to stay absolute because worktree resolution depends on it. See detectSquadDir() in detect-squad-dir.ts."
Thread resolution is only available via the GitHub GraphQL API. Use this when your fix fully addresses the comment and no further discussion is needed.
First, get the thread IDs (they're different from comment IDs):
gh api graphql -f query='
query {
repository(owner: "{owner}", name: "{repo}") {
pullRequest(number: {pr_number}) {
reviewThreads(first: 100) {
nodes {
id
isResolved
comments(first: 1) {
nodes { body databaseId }
}
}
}
}
}
}
'
Match thread IDs to comment IDs using databaseId, then resolve:
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "{thread_node_id}"}) {
thread { id isResolved }
}
}
'
When to resolve vs. leave open:
Rule of thumb: Agent-to-agent threads (e.g., Copilot review → agent fix) can be resolved by the fixer. Human reviewer threads should be left for the human to resolve.
Commit messages should reference the PR context:
fix: address review feedback on PR #{pr_number}
- Switched to path.dirname() for worktree path resolution (comment #18234)
- Updated error message to include file path (comment #18235)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
For single-comment fixes, a shorter format works:
fix: use path.dirname() for worktree consistency (PR #{pr_number} review)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gh apigh api .../repliesReview comment (id: 55123):
squadDircould be undefined here. Consider adding a null check.
Agent workflow:
get_review_commentssrc/cli/core/detect-squad-dir.tsfix: add null check for squadDir (PR #99 review)gh api repos/bradygaster/squad/pulls/99/comments/55123/replies \
-f body="Fixed in f4e5d6c — added early return when squadDir is undefined, matching the pattern in loadConfig()"
Comments:
detect-squad-dir.ts:42detect-squad-dir.ts:58output.ts:15Agent handles each individually:
# Fix all three, commit
git add packages/squad-cli/src/cli/core/detect-squad-dir.ts packages/squad-cli/src/cli/core/output.ts
git commit -m "fix: address 3 review comments on PR #99
- Added null check for squadDir (comment #55123)
- Switched to path.join() for cross-platform paths (comment #55124)
- Reduced log verbosity to debug level (comment #55125)"
git push
# Reply to each thread individually
gh api repos/bradygaster/squad/pulls/99/comments/55123/replies \
-f body="Fixed — added early return when squadDir is undefined"
gh api repos/bradygaster/squad/pulls/99/comments/55124/replies \
-f body="Fixed — switched to path.join(squadDir, 'config.json') for cross-platform consistency"
gh api repos/bradygaster/squad/pulls/99/comments/55125/replies \
-f body="Fixed — changed from console.log to debug() so it only shows with --verbose flag"
Copilot sometimes provides suggestion blocks with exact code to apply:
Review comment (id: 55130):
Consider using optional chaining:
```suggestion
const name = config?.agent?.name ?? 'default';
```
Reply format when applying:
gh api repos/bradygaster/squad/pulls/99/comments/55130/replies \
-f body="Applied suggestion — using optional chaining with nullish coalescing"
Reply format when not applying:
gh api repos/bradygaster/squad/pulls/99/comments/55130/replies \
-f body="Not applied — config is guaranteed non-null at this point (validated on line 12). Optional chaining would mask errors."
Not every review comment should be accepted. When a suggestion is incorrect or doesn't apply:
gh api repos/bradygaster/squad/pulls/99/comments/55140/replies \
-f body="Considered but not applied — this file is in the zero-dependency bootstrap set (see copilot-instructions.md § Protected Files). Adding path.join() would require importing from the SDK, which breaks the bootstrap constraint."
Do NOT resolve the thread when pushing back. Leave it open for the reviewer to confirm.