From shipshitdev-library
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.
How this skill is triggered — by the user, by Claude, or both
Slash command
/shipshitdev-library:pr-merge-trainWhen to use
review all PRs, drain open PRs, merge clean PRs, reduce WIP, merge train, clean up pull requests, land green PRs, drain WIP
This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Drain open PR queues by merging safe independent PRs first, fixing blocked PRs
Drain open PR queues by merging safe independent PRs first, fixing blocked PRs narrowly, and moving on whenever unrelated CI is still pending. The goal is lower WIP, not a serial full review of every branch.
Inputs:
Outputs:
Creates/Modifies:
External Side Effects:
Confirmation Required:
Delegates To:
gh-fix-ci for red or setup-stuck CI diagnosis.gh-address-comments for actionable review comments that require a code change.code-review only for a single risky diff, not as a serial full-review pass over the queue.green, red, pending,
conflict, needs-review, or dependency-blocked.green PRs immediately, before feature or fix work.red PRs, inspect only failing checks, setup-stuck pending jobs, and
actionable review comments. Patch narrowly, push, report "CI pending, moved
on", then continue with the queue.gh auth status -h github.com
git status --short
git fetch --all --prune
gh repo view --json nameWithOwner,defaultBranchRef
gh api repos/{owner}/{repo} --jq '{allow_squash_merge,allow_rebase_merge,allow_merge_commit}'
Record any dirty local files before touching PR branches. Never stash or revert unrelated work. If local changes could be disturbed, create an isolated worktree for each PR fix.
Parse the user's prompt for dependency edges: PR numbers, branch names, or titles that must land before another PR. Also infer dependency blocking from stacked PRs when a PR's base branch is another open PR branch.
Start with one queue snapshot:
gh pr list --state open --limit 200 \
--json number,title,url,isDraft,headRefName,baseRefName,author,mergeable,reviewDecision,statusCheckRollup,updatedAt
If more than 200 PRs are open, paginate with the GitHub API before classifying. Collect unresolved review threads in the same discovery phase, using GraphQL when needed so every open PR has review-thread state before individual work begins. Summarize comments; do not quote long review text.
Use the first matching bucket in this order:
dependency-blocked — an explicit user edge or stacked base branch requires
another open PR to merge first.conflict — GitHub reports merge conflicts, unknown mergeability after refresh,
or a base/head state that cannot be merged without conflict resolution.red — at least one required check failed, was cancelled, or timed out.pending — required CI is queued, in progress, waiting, or expected.needs-review — draft PR, unresolved requested changes, or unresolved material
review comments that block merge confidence.green — required checks pass, the PR is mergeable, dependencies are satisfied,
and there are no unresolved blocker comments.Do not treat optional experimental checks as blockers unless the repository marks them required or the PR's change scope makes them clearly material.
Topologically sort green PRs by explicit dependency edges. Merge every
independent green PR before fixing red, conflict, or needs-review PRs.
Choose the merge strategy from repository settings. Prefer the repo's normal strategy; if unknown, try squash first, then rebase, then merge commit only when the repository allows it:
gh pr merge <number> --squash --delete-branch
gh pr merge <number> --rebase --delete-branch
gh pr merge <number> --merge --delete-branch
If merge is blocked only by branch policy despite green required checks and an explicit queue-drain request, record the policy message and use the allowed admin merge path when the account and repository permit it:
gh pr merge <number> --squash --delete-branch --admin
If admin merge is unavailable, classify the PR as blocked with the exact policy message. After each merge batch, refresh PR metadata for dependent or overlapping PRs before continuing.
For each red PR that is not dependency-blocked:
Use gh-fix-ci behavior for setup-stuck jobs. If a job has spent 5-8 minutes in
setup, checkout, dependency install, or tool install without a repo-code step
running, cancel and rerun the job or workflow:
gh run view <run-id> --json jobs
gh run cancel <run-id>
gh run rerun <run-id> --failed
gh run rerun <run-id> --job <job-id>
After pushing a fix, do not wait for broad CI unless that PR is the next required
merge in the user's dependency order. Report: CI pending, moved on.
pending: leave it pending unless it is the next required merge. If it is next,
poll only that PR's required checks and apply the setup-stuck rule.conflict: report the conflict exactly. Resolve only if the user asked for
conflict resolution as part of the queue drain and the fix is narrow.needs-review: report the requested changes or material unresolved comments.
Address comments only when the requested fix is clear and scoped; otherwise
leave the PR blocked with the comment summary as evidence.dependency-blocked: report the upstream PR or explicit user order that blocks
it. Reclassify after the upstream PR merges.End every run with these sections:
PRs merged — PR number, title, merge strategy, and checks used as evidence.PRs fixed and pushed, CI pending — PR number, commit pushed, failed check
fixed, focused local check run, and pending CI checks.PRs blocked — PR number, bucket, and exact blocker: failed check, pending
required check, conflict, requested changes, dependency edge, policy block, or
unavailable admin path.Evidence — check names, review decisions, relevant workflow/job names, and
any setup-stuck reruns or cancellations.Deploy status — explicitly state that no deploy ran.npx claudepluginhub shipshitdev/skillsReviews 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.
Manages Mergify merge queue: queue/dequeue PRs via comments, inspect PR state, check queue status, and pause/unpause the queue. Useful for CI integration failure debugging.
Automatically polls and shepherds open PRs/MRs: triages review comments, fixes CI failures, pushes autofix commits, and keeps pull requests moving without manual intervention. Supports GitHub and GitLab.