---
name: reply-comments
description: Reply to PR review comments after addressing them. Resolves conversations where changes were made. Uses polite tone for humans, terse factual responses for AI bots. IMPORTANT - Always use this skill (not raw gh api calls) when replying to PR comments, including after manually addressing review feedback.
allowed-tools: "Read,Bash(~/.agents/skills/pr-status/scripts/gh-pr-feedback.py:*),Bash(~/.agents/skills/reply-comments/scripts/gh-pr-current-info.sh:*),Bash(~/.agents/skills/reply-comments/scripts/gh-pr-comments.sh:*),Bash(~/.agents/skills/reply-comments/scripts/gh-pr-review-threads.sh:*),Bash(~/.agents/skills/reply-comments/scripts/gh-pr-reply-comment.sh:*),Bash(~/.agents/skills/reply-comments/scripts/gh-pr-resolve-thread.sh:*),Bash(gh pr view:*),Bash(gh api:*),Bash(git:*)"
model-tier: standard
model: sonnet
effort: medium
version: "1.1.0"
author: "flurdy"
---

# Reply to Review Comments

Reply to PR review comments after addressing the feedback. Use this after `/review-comments` to close the feedback loop.

## Usage

```
/reply-comments
/reply-comments 123    # Specific PR number
```

## Instructions

### 1. Find the PR

If no PR number provided, get it from the current branch:

```bash
~/.agents/skills/reply-comments/scripts/gh-pr-current-info.sh
```

If the script is unavailable, fall back to:

```bash
gh pr view --json number,url,title,headRepositoryOwner,headRepository \
  --jq '{number, url, title, owner: .headRepositoryOwner.login, repo: .headRepository.name}'
```

### 2. Fetch the normalized feedback inventory

Use the shared bounded read-only collector:

```bash
~/.agents/skills/pr-status/scripts/gh-pr-feedback.py {owner} {repo} {pr_number}
```

Select records by stable `identity`, not body text or count. For the existing inline reply flow, use
only `source: inline_review` records whose lifecycle is `unresolved` and whose author is not self.
Retain `updatedAt` and `targets`: `targets.reply.commentId` is the REST reply target and
`targets.resolveThreadId` is the GraphQL thread target. This mapping keeps every item on the correct
reply or resolution endpoint. Never send conversation comments, review summaries, or CI annotations
to an inline-review endpoint; report those surfaces separately.

If `partial` is true, name the failed source and do not infer that a missing item was addressed. If
the inventory helper is unavailable, `gh-pr-comments.sh` plus `gh-pr-review-threads.sh` remains the
compatibility fallback.

### 3. Get Recent Commits

Check what was recently committed to understand which comments were addressed:

```bash
# Get recent commit messages and changed files
git log --oneline -10
git diff HEAD~1 --name-only
```

### 4. Identify Addressed Comments

For each review comment, determine if it was addressed by:
- Checking if the file/line was modified in recent commits
- Matching commit messages to comment content (e.g., "address review feedback")
- Looking for code changes that match suggested fixes

### 5. Compose Replies

Use different tones based on the reviewer:

**AI Bots** (amazon-q-developer[bot], copilot[bot], github-actions[bot], etc.):
- Terse, factual responses
- Just state what was done
- Examples:
  - "Fixed."
  - "Done."
  - "Changed to use `const`."
  - "Added null check."
  - "Not applicable - already handled by X."

**Human Reviewers** (anyone without [bot] suffix):
- Short but polite responses
- Acknowledge their feedback
- Examples:
  - "Good catch, fixed!"
  - "Thanks - updated."
  - "Done, good suggestion."
  - "Makes sense, changed it."
  - "Addressed in latest commit."

For comments NOT addressed (intentionally skipped):
- "Keeping as-is because {brief reason}."
- "Intentional - {brief explanation}."

### 6. Post Replies

Reply to each selected inline record using `targets.reply.commentId` as `{comment_id}`:

```bash
~/.agents/skills/reply-comments/scripts/gh-pr-reply-comment.sh {owner} {repo} {pr_number} {comment_id} "{reply_text}"
```

If the script is unavailable, fall back to:

```bash
gh api "repos/{owner}/{repo}/pulls/{pr_number}/comments/{comment_id}/replies" \
  -f body="{reply_text}"
```

### 7. Resolve Threads (if addressed)

Use each selected inventory record's `targets.resolveThreadId`. Only inline review threads have a
resolvable target. In compatibility fallback mode, get the thread IDs with:

```bash
~/.agents/skills/reply-comments/scripts/gh-pr-review-threads.sh {owner} {repo} {pr_number}
```

If that script is unavailable, fall back to:

```bash
gh api graphql -f query='
  query($owner: String!, $repo: String!, $pr: Int!) {
    repository(owner: $owner, name: $repo) {
      pullRequest(number: $pr) {
        reviewThreads(first: 100) {
          nodes {
            id
            isResolved
            comments(first: 1) { nodes { databaseId body } }
          }
        }
      }
    }
  }
' -f owner="{owner}" -f repo="{repo}" -F pr={pr_number}
```

Then resolve each thread that was addressed:

```bash
~/.agents/skills/reply-comments/scripts/gh-pr-resolve-thread.sh {thread_id}
```

If the script is unavailable, fall back to:

```bash
gh api graphql -f query='
  mutation($threadId: ID!) {
    resolveReviewThread(input: {threadId: $threadId}) {
      thread { isResolved }
    }
  }
' -f threadId="{thread_id}"
```

### 8. Summary

Report what was done:

```
Replied to 6 comments:
- amazon-q-developer[bot]: 3 (all resolved)
- @username: 2 (2 resolved, 1 kept as-is)
- copilot[bot]: 1 (resolved)
```
