Address PR comments interactively, strictly one at a time with explicit approval for each.
/pr comments- resolve comments on current branch's PR/pr comments 12345- resolve comments on specific PR- Works in worktrees if user previously said "cd worktree"
Read the PR with gh cli. Address all unaddressed comments in this development branch.
--paginate to fetch ALL comments. GitHub API returns max 100 items per page. PRs with many comments require pagination to get the complete list. Without --paginate, you will miss comments beyond the first page.
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
PR_NUMBER=$(gh pr view --json number -q .number)
# file-level comments with thread context - MUST paginate to get all
gh api --paginate repos/$REPO/pulls/$PR_NUMBER/comments --jq '.[] | {id: .id, path: .path, body: .body, line: .line, user: .user.login, in_reply_to_id: .in_reply_to_id}'
# PR-level review comments - MUST paginate to get all
gh api --paginate repos/$REPO/pulls/$PR_NUMBER/reviews --jq '.[] | select(.body != "") | {id: .id, body: .body, user: .user.login, state: .state}'
# Verify you got everything - compare counts
COMMENT_COUNT=$(gh api --paginate repos/$REPO/pulls/$PR_NUMBER/comments --jq 'length' | paste -sd+ | bc)
echo "Total file-level comments fetched: $COMMENT_COUNT"Never assume you have all comments without using --paginate. A PR may have 100+ review comments across many files.
- skip comments where we already replied in that thread
- skip approvals, non-actionable feedback
For each nontrivial comment/resolution:
- Show the comment - text, file, line, author, code context
- Explain the proposed resolution - what reviewer wants, how we'll fix it
- State the reply that will be added (default: "done")
- Get user approval - STOP and wait for one of:
yes/y- approve this fix and reply, then proceed to next commentdo- make the fix now, but WAIT before posting reply (user reviews the change first)skip- skip this comment entirely<custom reply>- use this text instead of the default replyno/n- do not proceed, discuss alternatives
- Make the fix - apply the code change
- Reverify - confirm it perfectly addresses the comment
- If user chose
do: Show the completed fix and STOP again to confirm posting the reply - Add the reply - only after fix is verified AND user confirms
- STOP and wait for input before proceeding to next comment
The do option: Useful when user wants to inspect the code change before the reply is posted. Flow:
- User says
do→ agent makes fix → agent shows result → agent asks "Post reply?" → user confirms → reply posted
gh api repos/$REPO/pulls/$PR_NUMBER/comments/$COMMENT_ID/replies -X POST -f body="done"All lowercase, brief. No explanation needed if done as requested.
done- fix applied as requested (most common)done - <short note>- with minor clarificationgood call, removed- agreed and removedfixed- addressed the issue
Never reply to threads we already replied to. Never add PR-level comments for file-level issues.
Batch related fixes, message format: address pr feedback: <summary>
Before making any fixes, ensure you're in the correct context:
# Look for a worktree on the PR's branch
PR_BRANCH=$(gh pr view $PR_NUMBER --json headRefName -q .headRefName)
git worktree list | grep -E "$PR_BRANCH|review"If a matching worktree exists, cd there first before making any changes.
Check if current branch matches the PR branch:
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "$PR_BRANCH" ]; then
echo "Current branch: $CURRENT_BRANCH"
echo "PR branch: $PR_BRANCH"
# GET USER APPROVAL before switching
fiIf branches differ, get explicit user approval before switching. Never silently switch branches or make fixes in an unrelated branch.
Once in the correct worktree/branch:
- Apply the comments flow above
- All git operations happen in that context