Fetch and analyze GitHub PR review comments, verify the validity of each point raised, and output a report.
Workflow
Step 1: Fetching review comments
- Receive the PR URL or repository information and PR number from the user
gh apiUse to fetch the review comments:gh api repos/{owner}/{repo}/pulls/{number}/reviews gh api repos/{owner}/{repo}/pulls/{number}/comments- Parse the list of comments and organize the points raised, target files, and line numbers
Step 2: Verifying each point raised
For each review comment:
- Checking the relevant code: Read the file and line referenced by the comment using the Read tool
- Analyzing the point raised: Verify whether the reviewer's claim is technically correct
- Determining validity:
- ✅ Valid (Valid): The point is correct and a fix is needed
- ❌ Invalid (Invalid): The point is wrong or does not apply
- ⚠️ Partially valid (Partial): Part of the point is correct, but it does not fully apply
Step 3: Checking the scope of impact
Use the Grep tool to check whether the pattern referenced by the comment (bug, anti-pattern, etc.) also exists in other files. If the same pattern exists in multiple places, include those in the report as well.
Step 4: Report output
Output the summary in the following format:
## PR Review Analysis: #{PR番号}
### Summary
- Total comments: {件数}
- Valid: {件数} | Partial: {件数} | Invalid: {件数}
### Details
| # | File | Severity | Validity | Summary | Action |
|---|------|----------|----------|---------|--------|
| 1 | path/to/file.ts:L42 | Major | ✅ Valid | 説明 | 修正必要 |
| 2 | path/to/file.ts:L100 | Minor | ⚠️ Partial | 説明 | 検討 |
### Detailed Analysis
#### Comment 1: [タイトル]
- **File**: `path/to/file.ts:L42`
- **Reviewer's point**: 指摘内容の要約
- **Verification**: 検証結果の説明
- **Verdict**: ✅ Valid
- **Recommended action**: 具体的な修正方針
- **Same pattern found in**: (該当する場合) 他のファイルパス
...
Step 5: Replying to review comments
After outputting the report, if the fix has been completed, propose a reply to the review comments.
- User confirmation: Ask "Would you like to reply to the comments?" Only execute replies if the user approves
- Generating reply content: Generate a reply according to the Verdict for each comment:
- ✅ Valid: Reply in the format "Fixed in {hash}" including the fix commit hash
- ⚠️ Partial: Briefly explain the parts addressed and the reasons for not addressing the rest
- ❌ Invalid: Technically explain why it does not apply (e.g., it is a generated file and cannot be edited directly)
- Executing replies:
gh apiReply to each comment with:gh api repos/{owner}/{repo}/pulls/{number}/comments \ -f body='{返信内容}' \ -F in_reply_to={comment_id} - Handling outside-diff comments: For points that cannot be replied to as inline comments (outside-diff), reply collectively in the thread of a related inline comment
Notes
- Support both bot reviews (CodeRabbit, GitHub Actions, etc.) and human reviews
- Also consider reply threads to review comments
- Estimate the severity of the point from the review comment's label or content
- Output in Japanese (keep technical terms such as code and paths in their original form)