From shipshitdev-library
Reviews open PRs targeting the default branch, merges approved ones, and prunes merged branches and stale worktrees. Confirmation-gated with optional review-only and no-prune modes.
How this skill is triggered — by the user, by Claude, or both
Slash command
/shipshitdev-library:merge-open-prsThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Review every open pull request aimed at the default/trunk branch, merge the ones
Review every open pull request aimed at the default/trunk branch, merge the ones
that pass review and CI into the trunk, then tidy up the branches and worktrees
the merges leave behind. This is an orchestrator: it reviews with code-review,
merges with gh, and prunes with release-cleanup. It never bypasses a failing
gate and never deletes work that is not provably merged.
This skill is standalone and manually triggerable (exposed as /merge). It does
not cut a release (use the release skill to tag from trunk) and does not deploy
(use deploy). It lands the open feature/fix PRs onto the trunk and cleans up.
Boundary: use pr-merge-train for non-serial WIP drain work where green PRs
should merge immediately, red PRs should get narrow fixes, and unrelated pending
CI must not block the rest of the queue. This skill remains the confirm-gated
trunk sweep plus optional prune.
Inputs:
review argument (plan only, merge nothing) and/or --no-prune flag
(merge, but skip the prune). With neither, the run is the full sweep: review +
merge + prune.Outputs:
release-cleanupCreates/Modifies:
--delete-branch)release-cleanupExternal Side Effects:
ghConfirmation Required:
release-cleanup, which runs its own dry-run and
confirmation gateDelegates To:
code-review to review each open PR before it is mergedgh-fix-ci when a PR's required checks are failing and the user wants them fixedfix-merge-conflicts when a conflicted PR should be resolved rather than skippedrelease-cleanup to prune merged branches and stale worktrees after merges landrelease to cut a semver tag and GitHub release from the trunk once PRs are mergedDo not use this skill to cut a release or force-merge PRs that fail review or CI.
It only lands PRs that pass their gates. To cut a release, use the release skill
to tag from trunk after the PRs are merged.
Do not use this skill for merge-train or WIP-drain prompts that should avoid
serial full reviews. Route those to pr-merge-train.
Hard rules:
gh repo view --json defaultBranchRef --jq .defaultBranchRef.name. If the
detected branch is absent on the remote, STOP and report. Honor an explicit
base override only after confirming that branch exists on the remote.mergeable is CONFLICTING
is reported and skipped; the author must rebase first. If the user wants to
clear the conflict instead of skipping, hand off to the fix-merge-conflicts
skill (it resolves correctness-first and rebuilds before continuing).code-review before it can enter the merge plan. PRs with unresolved
high-confidence findings are surfaced and excluded unless the user overrides.release-cleanup, which gates it.gh auth status -h github.com
git status -sb
git fetch --all --prune
gh repo view --json nameWithOwner,defaultBranchRef,mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)
git branch -r --list "origin/$DEFAULT_BRANCH"
If the detected trunk branch is absent on the remote, STOP and report the available remote branches. If the user passed an explicit base, confirm it exists before continuing.
Snapshot every open PR targeting the trunk in one query — this drives the rest of the run. Do not include PR titles or bodies in the machine snapshot; those are outsider-authored free text and are not needed for merge gating:
gh pr list --base "$DEFAULT_BRANCH" --state open --limit 200 \
--json number,headRefName,isDraft,mergeable,mergeStateStatus,reviewDecision,statusCheckRollup,url \
> /tmp/mop_prs.json
Raise --limit if there are more than 200 open PRs into the trunk.
Pick the merge method once from the repository's allowed modes (prefer squash so cleanup's squash-aware oracle stays consistent):
squashMergeAllowed -> --squashmergeCommitAllowed -> --mergerebaseMergeAllowed -> --rebaseHonor an explicit user preference if one is given and allowed by the repo.
For each PR in the snapshot, classify before reviewing:
jq -r '.[] | "\(.number)\t\(.isDraft)\t\(.mergeable)\t\(.mergeStateStatus)\t\(.reviewDecision)\t\(.headRefName)"' \
/tmp/mop_prs.json
Buckets:
DRAFT — isDraft == true. Skip, report.CONFLICTING — mergeable == "CONFLICTING". Skip, report (author must rebase).CHECKS_FAILING / CHECKS_PENDING — derive from statusCheckRollup (any
conclusion of FAILURE/TIMED_OUT/CANCELLED => failing; any status not
COMPLETED => pending). Exclude from the default plan, report.CANDIDATE — non-draft, mergeable == "MERGEABLE", all required checks green.Confirm CI per candidate when the rollup is ambiguous:
gh pr checks <number>
Review every candidate (and any borderline PR the user wants landed) before it
enters the plan. Run the code-review skill against the PR's diff:
gh pr diff <number>
Capture each review verdict as clean or has-findings (with a one-line
summary of the most serious finding). A candidate with unresolved high-confidence
bug findings moves to a REVIEW_BLOCKED bucket and is excluded unless the user
explicitly overrides after seeing the finding.
Print one consolidated plan, then stop and wait for an explicit yes:
DRAFT, CONFLICTING,
CHECKS_FAILING, CHECKS_PENDING, REVIEW_BLOCKED).With the review argument, end here — report verdicts and the plan, merge nothing.
Do not proceed to Phase 4 until the user confirms the printed plan. If the user opts to include an excluded PR (e.g. to merge despite pending checks), require that explicit per-PR yes and note it in the final status.
Only after the user confirms, merge each PR in the approved set. Merge oldest first so dependent branches see their predecessors:
for n in <approved-pr-numbers>; do
gh pr merge "$n" <method> --delete-branch
done
Where <method> is the Phase 1 choice (--squash / --merge / --rebase).
Rules during execution:
After the batch, refresh local state so the prune phase sees the merges:
git fetch --all --prune
By default (no --no-prune), hand off to release-cleanup in prune mode once
the merges have landed. It re-derives what is provably merged with its
squash-aware merge oracle, prints its own dry-run plan, and requires its own
confirmation before deleting any local branch, remote branch, or worktree. Do not
delete branches or worktrees directly from this skill beyond the per-PR
--delete-branch already done in Phase 4.
If any PR was left unmerged (conflicted, failing, or skipped), tell
release-cleanup to treat those branches as in-flight so they are not pruned.
With --no-prune, stop after Phase 4 and report; do not prune.
merge-open-prs — Phases 1-5. Review, confirm, merge, then delegate prune to
release-cleanup. The full sweep. (Default.)merge-open-prs review — Phases 1-3. Review every open PR into the trunk and
print the plan. Merge nothing, prune nothing.merge-open-prs --no-prune — Phases 1-4. Review, confirm, merge; skip the prune.merge-open-prs <base> — run against an explicit base branch instead of the
auto-detected trunk (after confirming that branch exists). Combines with review
and --no-prune.If the user scopes the run ("only PRs labeled X", "skip the prune"), honor it: still review and gate, but restrict the candidate set or stop before the phase they excluded.
Report:
release-cleanup prune summary, or that pruning was skippedgh-fix-ci, or cut a release from trunk via the release skill)npx claudepluginhub shipshitdev/skillsDrives a pull request to merge-ready across five criteria (sync, CI, inline comments, conversation, threads), then smart-merges it. Automates the PR review-to-green loop.
Drains open GitHub pull request queues by merging safe independent PRs first, fixing blocked PRs, and moving on from pending CI. Useful for multi-PR and WIP-drain prompts.
Merges reviewed PRs when triggered by /pr-merge or merge commands. Handles squash/rebase, worktrees, integration branches, and auto-merge for CI gating.