skills/pr-merge-train/SKILL.md
Drains open GitHub pull request queues without serial blocking. Use for multi-PR and WIP-drain prompts such as review all PRs, drain open PRs, merge clean PRs, reduce WIP, merge train, clean up pull requests, or land everything that is safe to merge.
npx skillsauth add shipshitdev/library pr-merge-trainInstall 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.
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, record the policy message and stop with the PR classified as blocked. Only after the user explicitly approves bypassing branch protection may you use an available admin merge path:
gh pr merge <number> --squash --delete-branch --admin
If confirmation is absent or admin merge is unavailable, keep the PR 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.development
TypeScript refactoring and modernization guidelines from a principal specialist perspective. This skill should be used when refactoring, reviewing, or modernizing TypeScript code to ensure type safety, compiler performance, and idiomatic patterns. Triggers on tasks involving TypeScript type architecture, narrowing, generics, error handling, or migration to modern TypeScript features.
tools
Resolves TypeScript and JavaScript problems across type-level programming, performance, monorepo management, migration, and modern tooling. Invoke when diagnosing "type instantiation excessively deep" errors, migrating JS to TS, configuring strict tsconfig, debugging module resolution, or choosing between Biome/ESLint/Turborepo/Nx.
tools
Turborepo monorepo build system guidance. Triggers on: `turbo.json`, task pipelines, `dependsOn`, caching, remote cache, the `turbo` CLI, `--filter`, `--affected`, CI optimization, environment variables, internal packages, monorepo structure, and package boundaries. Use when the user configures tasks or workflows, creates packages, sets up a monorepo, shares code between apps, runs changed packages, debugs cache behavior, or works in an `apps/` plus `packages/` workspace.
tools
Provides Tailwind CSS v4 performance optimization and best practices guidelines. Triggers when writing, reviewing, or refactoring Tailwind CSS v4 code; when working with Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.