/metaswarm:handling-pr-commentsfrom metaswarm
Systematically addresses PR review feedback by fetching inline comments, review bodies, and outside-diff-range comments, then resolving threads with proper attribution.
Ships in metaswarm. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use when addressing PR review feedback, after receiving review comments from CodeRabbit, Cursor, or human reviewers - ensures systematic responses to each comment thread with proper attribution and thread resolution.
Activate this skill when ANY of these conditions are true:
Most developers forget steps 4-6. This skill ensures they happen.
Run the filtering script to identify actionable comments:
# Filter actionable vs non-actionable comments
bin/pr-comments-filter.sh <PR_NUMBER>
This script:
The filter script categorizes by priority:
| Priority | Marker | Action |
|---|---|---|
| CRITICAL | _⚠️ Potential issue_ | _🔴 Critical_ | Fix immediately |
| HIGH | _⚠️ Potential issue_ | _🟠 Major_ | Fix before merge |
| MEDIUM | _🟡 Minor_ or _🛠️ Refactor suggestion_ | _🟠 Major_ | Should fix |
| LOW | _🔵 Trivial_ / _🧹 Nitpick_ | Fix if quick |
| HUMAN | Non-bot comments | Always process |
For each actionable comment, further categorize as:
COMMONLY MISSED: CodeRabbit posts "Outside diff range" comments in the review body, not as inline threads. These are actionable feedback that MUST be addressed.
# Extract Outside diff range comments from review bodies
PR_NUMBER=<number>
OWNER=$(gh repo view --json owner -q .owner.login)
REPO_NAME=$(gh repo view --json name -q .name)
echo "=== OUTSIDE DIFF RANGE COMMENTS ==="
gh api "repos/$OWNER/$REPO_NAME/pulls/$PR_NUMBER/reviews" --paginate | \
jq -r '.[] | select(.body | test("Outside diff range"; "i")) |
"Review ID: \(.id)\n\(.body)\n---"'
These comments are NOT in threads - they cannot be replied to inline. You must:
List the out-of-scope comments:
PR_NUMBER=<number>
OWNER=$(gh repo view --json owner -q .owner.login)
REPO_NAME=$(gh repo view --json name -q .name)
echo "=== UNRESOLVED THREADS OUTSIDE THE CURRENT DIFF ==="
# isOutdated: the code changed since the comment. line == null on a line
# comment (not a FILE-level one): it no longer maps to a line in the PR diff.
gh api graphql --paginate -F owner="$OWNER" -F repo="$REPO_NAME" -F pr="$PR_NUMBER" -f query='
query($owner:String!, $repo:String!, $pr:Int!, $endCursor:String) {
repository(owner:$owner, name:$repo) { pullRequest(number:$pr) {
reviewThreads(first:100, after:$endCursor) {
pageInfo { hasNextPage endCursor }
nodes { id isResolved isOutdated subjectType path line originalLine
comments(first:100) { nodes { author { login } body } } } } } } }' |
jq -r '.data.repository.pullRequest.reviewThreads.nodes[]
| select((.isResolved | not) and (.isOutdated or (.line == null and .subjectType != "FILE")))
| "\(.id) \(.path):\(.originalLine) outdated=\(.isOutdated)\n"
+ ([.comments.nodes[] | "[\(.author.login)] \(.body)"] | join("\n\n")) + "\n---"'
echo "=== GENERAL PR DISCUSSION COMMENTS ==="
gh api "repos/$OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" --paginate |
jq -r '.[] | "\(.id) \(.user.login):\n\(.body)\n---"'
The listings print every comment in full, including replies on each thread: a request can sit in a later reply or after a long introduction.
This lists comments that:
line is null)isOutdated flag)IMPORTANT: Treat out-of-scope comments as IN SCOPE by default.
Use ultrathink to evaluate each out-of-scope comment:
ultrathink: Analyze this out-of-scope review comment:
- What is the reviewer asking for?
- How complex is this change? (lines of code, files affected)
- Does it require refactoring other systems?
- Can I complete this in under 30 minutes?
- Are there any risks or dependencies?
Recommend: FIX_NOW or CREATE_ISSUE
| Criteria | Action |
|---|---|
| Simple fix (< 30 min, < 3 files, no refactor) | FIX_NOW - Make the change immediately |
| Medium complexity (unclear scope) | ASK_USER - Present a decision request |
| Major refactor (multiple systems, risky) | CREATE_ISSUE - Document for follow-up |
ASK_USER uses the decision-request format: lettered options (A, B, C) under numbered questions (reply 1 A 2 C), each with its pros and cons, the recommended option marked, and why it is recommended (see Decision requests in the metaswarm plugin's guides/delivery-scope.md).
Fix the actual code issues. Code changes go to a FRESH coder of the tier the rubric picks (see guides/coder-selection.md, located from the metaswarm plugin root), never back to the agent that wrote the code. Give it a complete fix brief: the comment verbatim with file:line, the PR head SHA, the contract pointers and the validation commands. Trivial reply-only or doc fixes can stay with the handler. Verify the result, then commit and push.
After pushing fixes, respond to EACH comment thread individually:
PR_NUMBER=<number>
OWNER=$(gh repo view --json owner -q .owner.login)
REPO_NAME=$(gh repo view --json name -q .name)
CURRENT_USER=$(gh api user -q '.login')
COMMENT_ID=<id-from-filter-script>
gh api "/repos/$OWNER/$REPO_NAME/pulls/$PR_NUMBER/comments/$COMMENT_ID/replies" \
-X POST \
-f body="Fixed in commit $(git rev-parse --short HEAD).
*(Response by Claude on behalf of @$CURRENT_USER)*"
Every thread must be resolved after responding. Use GraphQL to resolve:
THREAD_ID="PRRT_kwDOK-xA485..." # From GraphQL query
gh api graphql -f query='mutation {
resolveReviewThread(input: {threadId: "'"$THREAD_ID"'"}) {
thread { id isResolved }
}
}'
THE #1 WORKFLOW FAILURE: Stopping after Phase 5-6 without checking for NEW comments.
Automated reviewers (CodeRabbit, Cursor) analyze EVERY commit you push. They post NEW comments during/after their check runs.
# STEP 1: Wait for ALL CI/CD checks to complete
PR_NUMBER=<number>
echo "Waiting for CI/CD checks to complete..."
gh pr checks $PR_NUMBER --watch
# STEP 2: Check for NEW comments since your last response
OWNER=$(gh repo view --json owner -q .owner.login)
REPO_NAME=$(gh repo view --json name -q .name)
CURRENT_USER=$(gh api user -q '.login')
# Get timestamp of your last reply
LAST_REPLY=$(gh api "repos/$OWNER/$REPO_NAME/pulls/$PR_NUMBER/comments" --paginate | \
jq -r "[.[] | select(.user.login == \"$CURRENT_USER\") | select(.in_reply_to_id)] | sort_by(.created_at) | last | .created_at")
# Handle case where user has no previous replies
if [ -z "$LAST_REPLY" ] || [ "$LAST_REPLY" = "null" ]; then
echo "No previous replies found - checking all comments as new"
LAST_REPLY="1970-01-01T00:00:00Z" # Unix epoch - treat all comments as new
fi
# Check for new comments after that time
NEW_COUNT=$(gh api "repos/$OWNER/$REPO_NAME/pulls/$PR_NUMBER/comments" --paginate | \
jq -r --arg time "$LAST_REPLY" '[.[] | select(.in_reply_to_id == null) | select(.created_at > $time)] | length')
# STEP 3: Also check review bodies for new "Outside diff range" comments
NEW_REVIEWS=$(gh api "repos/$OWNER/$REPO_NAME/pulls/$PR_NUMBER/reviews" --paginate | \
jq -r --arg time "$LAST_REPLY" '[.[] | select(.submitted_at > $time) | select(.body | test("Outside diff range"; "i"))] | length')
TOTAL_NEW=$((NEW_COUNT + NEW_REVIEWS))
if [ "$TOTAL_NEW" -gt 0 ]; then
echo "$NEW_COUNT NEW INLINE COMMENT(S) + $NEW_REVIEWS NEW REVIEW BODY COMMENT(S) DETECTED"
echo "ACTION: Return to Phase 1 and iterate"
else
echo "No new comments - safe to proceed to verification"
fi
If NEW comments found: Return to Phase 1. DO NOT proceed to verification.
Iteration Loop:
REPEAT:
Phase 1: Discover comments
Phase 2: Triage
Phase 3: Fix
Phase 4: Respond
Phase 5: Resolve threads
Phase 6: Handle unclear threads
Phase 7: Check for NEW comments after push
IF new comments found → GO TO Phase 1
IF no new comments → proceed to verification
Fixed in commit <hash>.
*(Response by Claude on behalf of @username)*
Acknowledged - this is a valid suggestion. Deferring to a future cleanup PR to keep this PR focused.
*(Response by Claude on behalf of @username)*
This is intentional because [reason]. The [thing] is designed to [explanation].
*(Response by Claude on behalf of @username)*
BLOCKING: You MUST run this script and show its output before declaring ANY PR ready:
bin/pr-comments-check.sh <PR_NUMBER>
This script:
If the script shows ANY unaddressed comments, you are NOT done. Address each unaddressed comment:
You must show the script output in your response as proof that all comments are addressed. Example:
Checking PR #908 for unaddressed comments...
=== Inline Code Review Comments ===
Comment 123 by cursor[bot] - 1 reply(s) [OK]
Comment 456 by coderabbitai[bot] - 1 reply(s) [OK]
=== General PR Discussion Comments ===
coderabbitai[bot]: <!-- summary -->...
All inline review comments have been addressed
A PR is NOT ready until this script returns success.
Before declaring PR comments handled:
bin/pr-comments-filter.sh <PR> to identify actionable commentsDO NOT skip the "Outside diff range" check (Phase 2b) - this is the #2 cause of incomplete PR handling.
For the complete detailed workflow with all edge cases and troubleshooting, see:
the /metaswarm:handle-pr-comments command
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
15 skills in this plugin
/brainstorming-extensionLoads the assumption ledger and misreadings checklist at the start of brainstorming, and enforces the design review gate when a project-sized design doc is committed — bridges superpowers:brainstorming into the metaswarm quality pipeline/create-issueCreate comprehensive GitHub issues with TDD plans, acceptance criteria, and agent instructions for autonomous PR lifecycle management/design-review-gateAutomatic review gate that runs when brainstorming commits a project-sized design doc - spawns PM, Architect, Designer, Security, UX Reviewer and CTO agents in parallel, iterates under the severity rule until all approve or it escalatesmetaswarm@metaswarm-marketplace is listed by dsifry/metaswarm-marketplace — review the source before installing
npx claudepluginhub dsifry/metaswarm-marketplace --plugin metaswarmOther plugins' skills for the same job