Review all open PRs (not drafts) for merge readiness, make all necessary changes from nitpick to critical, address reviewer comments, merge methodically, verify deployment, and clean up branches
Automate the complete PR review, fix, merge, and cleanup workflow.
Review all open PRs (excluding drafts) for merge readiness. Make all necessary changes from nitpick to critical, then merge them methodically ensuring that at the end of the process, the code is all pushed to main and the workflow to build and deploy succeeds. This includes reading reviewer comments and addressing any unresolved issues that need to be fixed. Clean up local and remote PR branches after merging.
List all open PRs (exclude drafts):
gh pr list --state open --json number,title,isDraft,author,updatedAt,reviewDecision,statusCheckRollup
Filter out draft PRs - Only work with ready-for-review PRs
If $ARGUMENTS provided - Focus only on that specific PR number
Prioritize PRs by:
For each PR in priority order:
Fetch PR details:
gh pr view [NUMBER] --json title,body,number,headRefName,baseRefName,mergeable,reviews,comments,commits,statusCheckRollup
Check out the PR branch:
gh pr checkout [NUMBER]
Review the code changes:
gh pr diff [NUMBER]
Read all reviewer comments:
gh pr view [NUMBER] --comments
Check CI/CD status:
gh pr checks [NUMBER]
For each issue identified:
Make necessary changes:
Commit fixes:
git add [files]
git commit -m "Address review feedback: [specific issue]
- Fix: [specific change 1]
- Fix: [specific change 2]
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>"
Push changes:
git push origin [branch-name]
Verify checks pass after pushing:
gh pr checks [NUMBER] --watch
Respond to review comments (mark as resolved):
gh pr comment [NUMBER] --body "✅ Addressed: [summary of fix]"
Before merging each PR:
Verify ALL criteria met:
Update from main (if behind):
git fetch origin main
git merge origin/main
# Resolve any conflicts
git push origin [branch-name]
Final check:
gh pr view [NUMBER] --json mergeable,statusCheckRollup
Merge the PR (using squash merge for clean history):
gh pr merge [NUMBER] --squash --delete-branch --auto
If auto-merge fails, use:
gh pr merge [NUMBER] --squash --delete-branch
Verify merge succeeded:
gh pr view [NUMBER] --json state,merged,mergedAt
Clean up local branch:
git checkout main
git pull origin main
git branch -D [branch-name]
Verify remote branch deleted:
gh pr view [NUMBER] --json headRefName
git ls-remote --heads origin [branch-name] # Should return empty
After ALL PRs are merged:
Ensure on main branch:
git checkout main
git pull origin main
Verify build and deploy workflow:
gh run list --workflow=.github/workflows/deploy.yml --limit 1 --json status,conclusion,url
gh run watch # Watch the latest workflow run
If workflow fails:
Final verification:
gh pr list --state open # Should show fewer PRs (or none if all merged)
git branch --list # Verify no leftover PR branches locally
From CLAUDE.md:
/* eslint-disable */, @ts-ignore, etc.)gh pr merge --delete-branchgit branch -DFor each PR, provide:
At the end, provide:
# 1. Discover PRs
gh pr list --state open --json number,title,isDraft
# Result: PR #347, #348, #349 (0 drafts)
# 2. Review PR #347
gh pr checkout 347
gh pr diff 347
# Found: 2 lint errors, 1 reviewer comment
# 3. Fix issues
# ... edit files ...
git add .
git commit -m "Address review: fix lint errors in BudgetCalendar"
git push
# 4. Verify and merge
gh pr checks 347 --watch
gh pr merge 347 --squash --delete-branch
# 5. Repeat for #348, #349
# 6. Final verification
git checkout main
gh run watch
# ✅ Deploy workflow succeeded
gh CLI configured and authenticated