From agents-library
Triage the project's open pull requests and batch the trivial ones onto a branch you name. Lists every open PR, fans out one review sub-agent per PR that reads the diff and judges it across four lenses — size/scope, change type, mergeability/CI, and an actual correctness read — then recommends include or skip with reasoning. Consolidates the verdicts into one ranked list, lets you pick which to take, and locally git-merges the chosen PRs into your target branch (no push, nothing closed on GitHub), reporting conflicts and a final summary. Use this whenever the user wants to sweep open PRs, batch or bulk merge pull requests, "clean up the PR queue", collect the easy/trivial/safe PRs, merge the low-risk ones together, or assemble several PRs onto one branch — even if they don't say the word "skill". Requires the `gh` CLI; works on the local repo, never pushes or closes PRs on its own.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agents-library:batch-merge-prsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are the **orchestrator** of a triage-and-batch-merge sweep over the
You are the orchestrator of a triage-and-batch-merge sweep over the project's open pull requests. The user wants to find the trivial, low-risk PRs sitting in the queue and collect the ones they choose onto a single branch they name — without hand-reviewing each one and without touching the remote.
Your job: list the open PRs, fan out one review sub-agent per PR, consolidate their include/skip verdicts into one ranked list, let the user pick, then locally git-merge the chosen PRs into the target branch and summarize what happened.
Two guardrails frame everything below:
Skimming a PR list by title tells you almost nothing — "fix typo" can hide a behavior change and "small refactor" can be genuinely trivial. The only way to know if a PR is safe to batch is to read its diff. But reading a queue of PRs yourself is slow and the lenses compete: "is this small?" and "is this correct?" pull attention in different directions. One sub-agent per PR, each holding the same four lenses over a single diff, gives every PR a real review in parallel. You then merge their verdicts into one ranked list so the user sees a decision table, not a stack of reports.
The sub-agents only assess — they read, they judge, they never merge or edit anything. Merging happens later, under your control, locally. Keeping assessment separate from action is what makes the verdicts trustworthy and the merge step safe to reason about.
Before dispatching anything, build the picture you'll bundle into every sub-agent so the agents don't each re-derive it.
gh works. Run gh auth status. If gh is missing or not
authenticated, stop and tell the user — this skill cannot list PRs without it.AGENTS.md, README, CLAUDE.md,
CONTRIBUTING. These tell you the conventions, commit style, and quality bars
a PR should respect — the same bars the per-PR reviewer judges against. Capture
a short summary to pass along.main —
detect it (git symbolic-ref refs/remotes/origin/HEAD, or fall back to
whichever of main/master exists). Call it <main>. Note which remote
points at GitHub (usually origin); you'll fetch PR heads from it.gh pr list --state open --json number,title,author,headRefName,baseRefName,isDraft,mergeable,labels,additions,deletions,changedFiles.
This is the work-list. Capture it. Skip drafts by default (mention you did);
the user can ask to include them.If there are no open PRs (or only drafts and the user didn't ask for those), say so and stop — there's nothing to triage.
Dispatch one sub-agent per open PR, all in parallel — issue every Agent/Task
call in a single message so they run concurrently (the
superpowers:dispatching-parallel-agents pattern). For a large queue (say >15
open PRs), tell the user the count and confirm before fanning out that wide.
Each sub-agent's prompt is assembled from three parts:
<main>, and the target branch name.references/pr-assessment.md and include it
verbatim. That file is the sub-agent's entire instruction set for how to judge
a PR. Also give it the one PR's number and its row from the gh pr list JSON.gh; return exactly one verdict in this
schema.The sub-agent fetches its own PR's diff (gh pr diff <n>) and details
(gh pr view <n> --json ..., including mergeable, mergeStateStatus, and CI
via statusCheckRollup) so the orchestrator prompt stays small and the work
parallelizes cleanly.
If a sub-agent fails, note that PR as "not assessed" and continue with the rest — never block the whole sweep on one PR.
Collect the verdicts into one decision table, sorted include candidates first (by ascending risk), then skips, then any that failed to assess. Render each PR on a compact line:
[#142] ✅ include · trivial · docs · +6/-2, 1 file · clean, CI green
— README typo fixes, no code paths touched
[#137] ⚠️ review · borderline · deps · +1/-1, 1 file · clean, CI green
— bumps lodash minor; low risk but touches a runtime dep
[#131] ❌ skip · not-trivial · core · +210/-44, 9 files · CONFLICTS with target
— refactors the auth flow; needs a real review, not a batch merge
Then summarize: how many PRs are include candidates, how many borderline, how many to skip, and call out anything that conflicts with the target branch or has red/pending CI — those are the ones most likely to bite during the merge.
Keep it skimmable. The user is making a pick from a table, not reading reviews.
Ask the user two things:
<main>; if it
exists, you'll merge onto it as-is (tell them which).Set up the branch once, then merge each chosen PR in the order the user gave (or ascending PR number):
<main> (git fetch <remote> first, then
git checkout -b <target> <remote>/<main>). If it exists, check it out. Make
sure the working tree is clean before you start — if it isn't, stop and tell
the user rather than risk their uncommitted work.git fetch <remote> pull/<n>/head:__batch_pr_<n>.git merge --no-ff __batch_pr_<n> -m "Merge PR #<n>: <title>".
The --no-ff keeps each PR as a distinct, revertable merge commit, so the
batch stays auditable.git merge --abort) — do not attempt to resolve it silently. Record the PR
as "skipped — conflicts with the batch," and continue with the rest. A
half-resolved merge the user didn't see is worse than a cleanly skipped PR.__batch_pr_<n> branches when done.Do not push, and do not run gh pr merge. The branch stays local.
Report the outcome as a clear ledger:
#<n> — <title>.Each sub-agent returns exactly one verdict:
pr: <number>
title: <pr title>
recommendation: include | review | skip (✅ | ⚠️ | ❌)
triviality: trivial | borderline | not-trivial
change_type: docs | deps | config | test | refactor | core | mixed
size: +<additions>/-<deletions>, <n> files
mergeable: clean | conflicts | unknown (vs the target branch)
ci: green | red | pending | none
summary: one line on what the PR does
reason: one line on why include / review / skip
risks: short note on anything that gives pause (empty if none)
recommendation maps to triviality and risk: include = trivial and cleanly
mergeable with no correctness concerns; review = borderline or low-but-real
risk the user should eyeball before batching; skip = not trivial, conflicts,
red CI, or a correctness concern the agent actually found in the diff.
gh missing/unauthenticated: stop in Phase 0; this skill needs it.npx claudepluginhub cleanunicorn/agents-library --plugin agents-libraryProvides CDSS development patterns for drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), and alert classification integrated into EMR workflows.