PR Comment Handler with Resolution Tracking
Find the open PR for the current branch and systematically address all review comments with mandatory resolution verification. This workflow ensures no feedback slips through the cracks by tracking threads as tasks, linking commits to specific reviews, and blocking completion if any threads remain unresolved. Run all gh commands with elevated network access.
Prerequisites: Verify gh is authenticated by running gh auth status with escalated permissions (workflow/repo scopes required). If not authenticated, run gh auth login --scopes repo,workflow. If sandboxing blocks gh auth status, rerun with sandbox_permissions=require_escalated.
Workflow
1) Fetch all PR comments
Run python3 $HOME/.claude/skills/gh-address-comments/scripts/fetch_comments.py to fetch all comments and review threads on the PR. Store output for later verification.
Example:
python3 $HOME/.claude/skills/gh-address-comments/scripts/fetch_comments.py > /tmp/pr_comments.json
2) Create tracking checklist
Parse the fetched comments and create a task checklist using TaskCreate for each review thread. Each task should:
- Include the thread number, file path, line number, and comment summary
- Have status
pendinginitially - Store the thread ID in task metadata for later resolution
Task format:
- Subject:
Address comment #N: [file]:[line] - Description: Comment author, body preview, and what needs to be done
- Metadata:
{"thread_id": "PRRT_kwDOABC...", "file": "path/to/file.ts", "line": 42}
3) Ask user which comments to address
Present all numbered review threads with summaries. Ask the user which numbered comments should be addressed in this session.
Display format:
Review Threads:
1. src/api/users.ts:45 (@reviewer): Add input validation for email field...
Thread ID: PRRT_kwDOABCDEF1234567
Status: Unresolved
2. src/utils/auth.ts:128 (@reviewer): Extract this logic into a helper function...
Thread ID: PRRT_kwDOABCDEF7654321
Status: Unresolved
4) Apply fixes with commit linking
For each selected comment:
- Update task status to
in_progressusing TaskUpdate - Apply code changes using standard tools (Edit, Write)
- Commit with message that references the comment number and thread ID:
fix: address PR comment #1 - add email validation Resolves review thread PRRT_kwDOABCDEF1234567 - Added Zod schema validation for email field - Added error handling for invalid formats Co-authored-by: @reviewer - Update task status to
completedusing TaskUpdate
Commit message format:
- First line:
fix: address PR comment #N - [brief description] - Blank line
Resolves review thread [THREAD_ID]- Bullet points explaining the changes
Co-authored-by: @reviewerif substantial changes based on feedback
5) Mark threads as resolved
After committing fixes, mark the corresponding review threads as resolved using:
python3 $HOME/.claude/skills/gh-address-comments/scripts/mark_resolved.py <thread_id_1> [thread_id_2] ...
Example:
python3 $HOME/.claude/skills/gh-address-comments/scripts/mark_resolved.py \
PRRT_kwDOABCDEF1234567 \
PRRT_kwDOABCDEF7654321
6) Verify complete resolution (MANDATORY - BLOCKS IF SKIPPED)
Before declaring the PR review complete, verify all threads are addressed:
python3 $HOME/.claude/skills/gh-address-comments/scripts/fetch_comments.py | \
python3 $HOME/.claude/skills/gh-address-comments/scripts/verify_resolution.py
Exit behavior:
- Exit 0: All threads resolved/outdated → safe to proceed
- Exit 1: Unresolved threads found → BLOCKED until addressed
IMPORTANT: Do NOT skip this verification step. If unresolved threads are found:
- Ask user to explicitly acknowledge which threads to defer
- Create follow-up tasks for deferred threads
- Only proceed after user confirms understanding of what remains unresolved
Error Handling
Authentication issues:
If gh hits auth/rate issues mid-run, prompt the user to re-authenticate with gh auth login, then retry.
Thread resolution failures:
If mark_resolved.py fails for specific threads:
- Check the thread ID is correct (from
fetch_comments.pyoutput) - Verify you have write permissions on the PR
- Ensure the thread still exists (not deleted by reviewer)
Verification failures:
If verify_resolution.py reports unresolved threads:
- Review the listed thread IDs
- Either address remaining threads OR get explicit user approval to defer
- Document deferred threads in follow-up tasks
Notes
- Review threads marked as "outdated" (code changed since comment) are considered addressed
- Conversation comments (non-threaded) don't block completion but should be acknowledged
- Always link commits to thread IDs for traceability
- Use TaskList to track overall progress across all review threads
Additional Resources
For detailed information, see:
- Resolution workflow deep dive:
references/resolution-workflow.md - Command cheatsheet:
references/quick-reference.md - GitHub API details:
references/api-endpoints.md - Common issues:
references/troubleshooting.md