| name | pr-merge-ci-gate |
| description | Use when checking CI status on a GitHub PR and deciding whether to merge โ distinguishes blocking failures (GitHub Actions quality gates) from ignorable failures (Vercel preview deployments, sandbox Vercel builds). Triggers on "CI failing", "Vercel failing on PR", "can I merge", "pr merge blocked", "gh pr merge", or "check before merging". |
PR Merge with CI Gate
Overview
Not all CI failures block a merge. Know the difference between required status checks
(block merge) and optional checks (informational only) before deciding to wait or proceed.
Decision Flow
digraph merge_decision {
"Check PR status" [shape=box];
"Any required check failing?" [shape=diamond];
"Failing check type?" [shape=diamond];
"Wait / fix" [shape=box];
"Safe to merge" [shape=box];
"Vercel preview build" [shape=box];
"GitHub Actions workflow" [shape=box];
"Merge โ preview failures ignorable" [shape=box];
"Fix workflow before merging" [shape=box];
"Check PR status" -> "Any required check failing?";
"Any required check failing?" -> "Failing check type?" [label="yes"];
"Any required check failing?" -> "Safe to merge" [label="no"];
"Failing check type?" -> "Vercel preview build" [label="Vercel"];
"Failing check type?" -> "GitHub Actions workflow" [label="GH Actions"];
"Vercel preview build" -> "Merge โ preview failures ignorable";
"GitHub Actions workflow" -> "Fix workflow before merging";
}
Step 1 โ Check Status
gh pr view <number> --json mergeable,statusCheckRollup
Parse the output:
mergeable: "MERGEABLE" โ no git conflicts
mergeable: "CONFLICTING" โ resolve conflicts first (see conflict resolution below)
statusCheckRollup โ list of check names + state/conclusion
Step 2 โ Classify Failures
| Check name pattern | Type | Block merge? |
|---|
Quality Checks (GitHub Actions) | Required | Yes โ fix first |
Vercel โ <project-name> | Vercel preview | No โ ignorable |
Vercel โ <project-name>-sandbox | Vercel preview | No โ ignorable |
Vercel Preview Comments | Vercel bot | No โ informational |
CodeRabbit | Code review bot | No โ advisory |
| Custom workflow names | Check branch protection rules | Varies |
Why Vercel previews fail on feature branches:
- Environment variables not set for the preview environment
- Preview projects use different configs
- Binary assets (large
.mp4 files) that Vercel doesn't handle in preview
- Pre-existing build errors in the repo unrelated to this PR
When to treat Vercel failures as blocking:
- The same Vercel project builds green on
main but fails here โ investigate
- Failure message mentions a specific file you changed โ investigate
- PR is for a Vercel-deployed feature that needs preview verification
Step 3 โ Merge Command
gh pr merge <number> --squash \
--subject "feat: descriptive title under 70 chars" \
--body "$(cat <<'EOF'
## Summary
- bullet 1
- bullet 2
๐ค Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"
gh pr merge <number> --merge
gh pr merge <number> --squash --auto
Conflict Resolution (when mergeable: "CONFLICTING")
git fetch origin
git merge origin/main --no-edit
git diff --name-only --diff-filter=U
git checkout --theirs <file>
git add <file>
git checkout --ours <file>
git add <file>
git commit -m "merge(main): resolve conflicts"
git push origin <branch>
Key principle: If a file was independently updated on both branches, default to --theirs
(main) for infrastructure files (package.json, pnpm-lock.yaml, prisma/schema.prisma,
config files). Use --ours only for feature files that main didn't touch.
Quick Reference
gh pr view 148 --json mergeable,statusCheckRollup | \
python3 -c "import json,sys; d=json.load(sys.stdin); \
print('Mergeable:', d['mergeable']); \
[print(c.get('context') or c.get('name'), '->', c.get('state') or c.get('conclusion')) \
for c in d['statusCheckRollup']]"
gh pr merge 148 --squash --subject "fix(seo): your title here"
gh pr view 148 --json state,mergedAt
Common Mistakes
| Mistake | Fix |
|---|
| Waiting for Vercel previews to go green | They may never go green on feature branches โ check if they're required |
Merging with CONFLICTING state | Resolve conflicts first โ the merge will fail or produce bad output |
Using --admin to force-merge past required checks | Fix the required checks instead |
| Assuming all checks are equal | Read the branch protection rules or check which checks are listed as "Required" in the PR UI |