.claude/skills/merge-prs/SKILL.md
Merge multiple PRs with conflict resolution and CI failure auto-patching. Analyzes optimal merge order, resolves conflicts, pulls CI logs on failure, and fixes issues. Use when multiple feature branches need merging into the base branch.
npx skillsauth add benjaminshoemaker/ai_coding_project_base merge-prsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Merge multiple pull requests into a single integration branch with intelligent conflict resolution, risk scoring, security pre-flight, automated CI failure diagnosis, flaky test awareness, and bisection-based failure isolation.
gh CLI installed and authenticated (gh auth status works)git status shows no uncommitted changes)| Argument | Required | Default | Description |
|----------|----------|---------|-------------|
| $1...$N | No | all open | Space-separated PR numbers (e.g., 63 64 65 66) |
| --base | No | main | Base branch to integrate against |
| --strategy | No | merge | merge (preserve commits) or rebase (linear history) |
| --dry-run | No | off | Analyze conflicts, risk, and order without merging |
| --no-fix | No | off | Skip auto-fix on CI failures (report only) |
| --no-security | No | off | Skip security pre-flight checks |
| --force | No | off | Proceed even if risk score is RED (>60) |
Copy this checklist and track progress:
Merge PRs Progress:
- [ ] Phase 0: Risk assessment & safety (scoring, tiers, security, dry-run)
- [ ] Phase 1: Discovery & analysis (metadata, CI status, conflicts, merge order)
- [ ] Phase 2: CI triage for RED PRs (log retrieval, flaky check, diagnosis, auto-fix)
- [ ] Phase 3: Integration merge (safety tag, sequential merge, conflict resolution, verify)
- [ ] Phase 4: Finalize (summary, changelog, merge strategy, execute)
- [ ] Phase 5: Cleanup (close PRs, delete branches, prune)
Run this phase BEFORE any git operations. It gates whether the merge should proceed. See RISK_SCORING.md for detailed computation tables and commands.
--force, ask user.never-tier PRs excluded from batching.--no-security): Scan diffs for secrets and audit dependencies for CVEs. BLOCK on secrets, WARN on CVEs.git merge-tree for actual conflict detection (no working tree changes).If --dry-run was specified, STOP after Phase 0 and report the full analysis.
gh pr list --state open --json number,title,headRefName,baseRefName,additions,deletions,files,mergeable,labels,createdAt
If specific PR numbers were given as arguments, filter to only those. If no arguments, use ALL open PRs targeting the base branch.
Report a summary table:
PR │ Branch │ Files │ +/- │ Risk │ Tier │ Mergeable
────┼─────────────────────────────────┼───────┼────────────┼──────┼────────┼──────────
#64 │ codex/run-codex-review-since-feb│ 3 │ +104/-2 │ 12 │ always │ ✓
#65 │ codex/perform-automated-bug-scan│ 2 │ +6/-16 │ 8 │ always │ ✓
#66 │ codex/assess-wizarddemo-flow │ 4 │ +135/-26 │ 34 │ maybe │ ✓
#63 │ codex/run-tech-debt-check │ 24 │ +1149/-742 │ 72 │ never │ ✓
gh pr checks <PR_NUMBER> --json name,state,conclusion
Categorize: GREEN (passed), RED (failed), PENDING (running), NONE (no checks).
If any PR is RED and --no-fix is NOT set, proceed to Phase 2 (CI Triage) for that PR.
If any PR is PENDING, wait up to 5 minutes (polling every 30s) then proceed.
Use git merge-tree results from Phase 0. Build a conflict matrix showing no overlap, file overlap, or confirmed conflicts between PR pairs.
Ordering heuristic (apply in priority):
always → maybe → iffy. never-tier PRs offered separatelyAsk the user to confirm the merge order before proceeding.
For each PR with failing CI checks:
Follow the 3-tier CI log retrieval chain in CI_DIAGNOSIS.md:
Tier 1 (check-run annotations) -> Tier 2 (--log-failed) -> Tier 3 (full log tail).
Prefer Tier 1 -- annotations give structured {file, line, message} triples for direct edit operations.
Before diagnosing a test failure as a real regression, check flaky test indicators (see CI_DIAGNOSIS.md for flaky test management details):
.claude/flaky-tests.json registrygh run rerun <RUN_ID> --failedParse log output to identify the failure category (see CI_DIAGNOSIS.md for failure signatures and fix strategies):
| Category | Auto-fixable? |
|----------|---------------|
| TypeScript error | Yes — read file, fix type |
| ESLint violation | Yes — npm run lint:fix |
| Test failure | Maybe — read test + source |
| Build error | Yes — fix imports |
| Env/secret missing | No — report to user |
| Dependency issue | Maybe — npm ci or fix versions |
| Timeout/infra | No — retry once, then report |
If auto-fixable and --no-fix is NOT set:
gh pr checkout <PR_NUMBER>.workstream/verify.shIf NOT auto-fixable, report to user and ask: "Skip this PR and continue, or abort?"
git checkout <base-branch>
git pull origin <base-branch>
git tag "pre-merge/$(date +%Y%m%d-%H%M%S)" <base-branch>
git checkout -b integrate/<descriptive-name>
For each PR in the planned merge order:
git fetch origin <pr-branch>
git merge origin/<pr-branch> --no-edit
If merge has conflicts, resolve intelligently:
| Conflict Type | Resolution Strategy |
|---------------|---------------------|
| Import additions | Keep both, deduplicate |
| Adjacent line changes | Keep both changes |
| Same line, different changes | Analyze intent — later PR usually incorporates earlier |
| Structural conflicts | Prefer refactoring PR's structure, re-apply other's logic |
| Type definition conflicts | Union the type changes |
| Test file conflicts | Keep all tests from both PRs |
| package-lock.json | git checkout --theirs package-lock.json && npm install && git add package-lock.json |
After resolving, verify file is syntactically valid, mark resolved and commit.
After ALL PRs are merged:
.workstream/verify.sh
If checks pass, proceed to Phase 4. If checks fail and --no-fix is NOT set:
If verification fails after 3 fix attempts, use binary bisection to isolate the culprit PR. See CI_DIAGNOSIS.md for the full bisection protocol.
For N PRs, this requires at most log2(N) verification runs. Once the culprit is identified, ask user: merge passing subset, attempt to fix, or abort.
See MERGE_STRATEGIES.md for detailed templates and commands.
See MERGE_STRATEGIES.md for detailed commands.
After integration succeeds, automatically prompt for cleanup:
gh auth status fails → "Please run gh auth login first"<name> not found"<base>"If aborting mid-process:
git merge --abort 2>/dev/null
git checkout <original-branch>
git branch -D integrate/<name> 2>/dev/null
git branch -D bisect-test 2>/dev/null
Report: "Integration aborted. Cleaned up integration branch. You're back on <original-branch>."
Safety tags are NEVER deleted automatically. Report their names so the user can clean up when ready.
--force or explicit confirmationREMINDER: These guardrails apply throughout all phases. Never force-push, never suppress security findings, and always ask for confirmation before destructive actions.
testing
Audit project alignment with VISION.md, identify SDLC gaps, and generate feature proposals. Use when reviewing strategic direction or planning new features.
development
Run code-verification on a specific task. Use to verify a single task's acceptance criteria after implementation.
testing
Resolve Vercel preview deployment URL for the current git branch. Invoked by browser-verification when deployment.enabled is true, or directly to check deployment status. Use to check deployment status or when browser verification needs a URL.
tools
Discover and sync all toolkit-using projects with the latest skills. Use when skills are modified, after the post-commit hook reminds you, or to batch-sync multiple projects.