Serially land a batch of green PRs as signed web-flow merge commits — migration-aware ordering, GitHub update-branch for stale PRs, wait for prod migrate/release between merges, then run /worktree-cleanup. Invoke as `/merge-train` (discover all green PRs) or `/merge-train <PR#> [<PR#>…]` (explicit batch). Operator-invoked only; complements /pr-iterate, which never merges.
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Low
Low-risk findings worth noting
Parallel worktree agents (ADR-025) produce batches of PRs that each go green in isolation. Landing them is where the manual toil and the risk concentrate: the operator clicks "Create a merge commit" N times, each merge instantly makes the surviving PRs stale against main, and every merge auto-applies Drizzle migrations to prod (migrate-db.yml), so order matters.
This skill is the operator-side merge train (ADR-0077): it merges a batch one PR at a time through GitHub's own API, re-validating between merges. It is the explicit, operator-delegated counterpart to /pr-iterate's hard rule "you never merge" — that rule still stands; /merge-train is a separate skill the operator invokes when they've decided the batch should land.
Everything stays inside branch protection: gh pr merge --merge and the update-branch API both produce GitHub web-flow-signed merge commits, exactly like the UI button (ADR-0044). Nothing is bypassed, rebased, or force-pushed.
--merge (signed merge commit, ADR-0044). Never --rebase (GitHub can't sign it; disabled repo-side anyway). --squash only if the operator explicitly asks for that PR — and then the PR title must be Conventional-Commits-compliant (it becomes the commit subject driving semantic-release).--admin, never touch branch protection, never force-push, never merge locally and push.migrate-db fails on main after a merge, do not merge anything else; escalate immediately.If the operator gave PR numbers, use exactly those (still verify each is green — refuse red ones with a one-line reason). Otherwise discover:
gh pr list --state open --json number,title,isDraft,reviewDecision,mergeable,mergeStateStatus,headRefName
gh pr checks <N> # per candidate — every required check green?Drop: drafts, reviewDecision == "CHANGES_REQUESTED", any red/pending required check, mergeable == "CONFLICTING" (send those to /pr-iterate instead).
gh pr view <N> --json files --jq '.files[].path'packages/db/drizzle/** go first, one at a time — migration files and drizzle/meta/_journal.json are the sharpest cross-PR collision, and landing them early means siblings get updated against the new journal instead of colliding at the end.Before the first merge, show the ordered list (PR, title, why it's positioned there, which are migration-bearing). In auto-discovery mode, wait for the operator's go-ahead. When the operator passed explicit PR numbers, that message is the go-ahead — proceed.
# a. Stale against main? Update via GitHub (web-flow-signed merge commit).
gh pr view "$PR" --json mergeStateStatus --jq .mergeStateStatus # BEHIND?
gh api -X PUT "repos/{owner}/{repo}/pulls/$PR/update-branch"
# b. Wait for checks to re-run and go green.
gh pr checks "$PR" --watch
# c. Merge — API merge commits are web-flow-signed, same as the UI button.
gh pr merge "$PR" --merge
# d. Wait for the post-merge main workflows before the next merge —
# keeps prod migrations strictly ordered (their concurrency groups
# queue, but the train should observe each result, not outrun it).
gh run list --branch main --workflow migrate-db.yml --limit 1 --json status,conclusion,databaseId
gh run list --branch main --workflow release.yml --limit 1 --json status,conclusion,databaseId
gh run watch <databaseId>If checks go red after update-branch (4b): that's a real cross-PR interaction surfaced early — skip the PR, record it as a /pr-iterate candidate, continue the train.
If the merge itself is rejected: re-read state; if it's not a transient (e.g. checks re-queued), stop and report.
If migrate-db fails (4d): hard rule 6 — stop the train, escalate with the run log.
Run /worktree-cleanup — the merged PRs' worktrees are now prunable, and the root checkout's main should fast-forward to include the batch.
merge-train — <date>
Plan: #A (db migration) -> #B -> #C
Landed: #A <merge sha> · #B <merge sha>
Skipped: #C — checks went red after update-branch (-> /pr-iterate #C)
main: <sha before> -> <sha after> · migrate-db ✅ · release ✅ (vX.Y.Z)
Cleanup: <worktrees removed> removed · <kept> keptclaude-code-merge-queue npm tool were rejected.--merge via API is signature-safe and rebase is forbidden./pr-iterate — drives a PR to green; never merges. /merge-train is where merging was deliberately delegated./worktree-cleanup — final step of every train.agranado2k/ai-report-platform
caeb0da
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.