Fix PR Review Comments
Fetch review comments from a GitHub PR and apply fixes to the local codebase.
Current PR context
!
gh pr view --json number,url,headRefName 2>/dev/null || echo "NO_PR_FOUND"
Step 1: Identify the PR
If the user provided a PR number as
, use that instead of the auto-detected PR above.
If no PR is found (output shows NO_PR_FOUND and no argument was given), stop and tell the user:
- There is no open PR for the current branch
- They need to either push and create a PR first, or provide a PR number
Step 2: Verify gh CLI is available
sh
gh --version 2>/dev/null || echo "GH_NOT_FOUND"
If
is not installed, stop and tell the user to install it:
https://cli.github.com
Step 3: Fetch review comments
Fetch all inline review comments on the PR:
sh
gh api repos/{owner}/{repo}/pulls/{number}/comments --paginate
Each comment object has these relevant fields:
- — file path
- (or ) — line number in the new file
- — the comment text
- — surrounding diff context
- — who posted it
Step 4: Parse and classify comments
Bot review comments (structured severity markers)
Look for severity markers in the comment
:
- — Must fix. Production crash, security, data loss.
- — Must fix. Significant bugs, logical flaws.
- — Should fix. Tech debt, best practice deviation.
- — Optional. Nitpick, stylistic.
- — Skip. Positive feedback.
Also extract from the body:
- Category (e.g. , ) — appears after severity on the first line
- Comment text — the main feedback paragraph
- Why it matters — appears in a blockquote starting with
- Code suggestion — appears in a fenced block (GitHub's suggested change format)
Human review comments (no severity markers)
If a comment has no structured severity markers, classify it as a human comment. Do NOT auto-fix these — list them separately for the user to address manually.
Fallback: no bot comments found
If there are zero comments with severity markers, treat ALL comments as potentially actionable:
- Show them to the user in a summary table
- Ask which ones to address
- Only proceed with explicit user confirmation
Step 5: Apply fixes
Sort bot comments by severity: Critical > High > Medium > Low.
For each comment (Critical, High, and Medium severity):
- Read the file at
- Understand the issue described in the comment
- If a block exists, use it as a strong hint — but verify it makes sense in context before applying blindly
- Show the proposed fix to the user and ask for explicit confirmation before applying it.
- If a comment is unclear or the fix would require broader refactoring beyond the scope, note it and skip
For Low severity: skip unless trivially fixable (one-line change).
For Praise: skip entirely.
Step 6: Summary
After applying fixes, provide a summary table:
| Severity | File | Line | Status | Notes |
|---|
| 🔴 Critical | path/to/file.ts | 42 | ✅ Fixed | Brief description |
| 🟠 High | path/to/other.ts | 17 | ⏭️ Skipped | Requires broader refactor |
Then list:
- Skipped comments with reasoning
- Human feedback (non-bot comments) that the user should address manually
Rules
- Do NOT blindly apply suggestions without reading the surrounding code
- Do NOT modify files that weren't mentioned in review comments
- If there are no review comments on the PR, tell the user and stop
- Human review comments should be shown to the user but not auto-fixed — list them separately as "Human feedback to address"
- If CLI is not authenticated, tell the user to run