/soleur:drain-prsfrom soleur
Triages open GitHub PRs into mergeable tiers, confirms scope with the operator, then fixes and merges green PRs in one pass. Counterpart to drain-labeled-backlog.
Ships in soleur. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Cloud Mode (Devin): before pipeline work run bash "${CLAUDE_PLUGIN_ROOT}/scripts/cloud-detect.sh". If CLAUDE_PLUGIN_ROOT is unset (cloud exec shells do not export it), resolve the root by IDENTITY, never by script basename: for d in "$HOME/.local/share/devin/cli/plugins/cache" and /opt/.devin/plugins, skip unless [ -d "$d" ], then MANIFEST="$(find "$d" -path '*/.claude-plugin/plugin.json' -exec grep -l '"name"[[:space:]]*:[[:space:]]*"soleur"' {} + 2>/dev/null | head -1)", ROOT="${MANIFEST%/.claude-plugin/plugin.json}" — one resolution, two consumers: $ROOT/scripts/cloud-detect.sh and $ROOT/scripts/precommit-guard.sh. (Shape check, not authentication: a planted {"name":"soleur"} dir passes — ADR-179 A11.) local or not-local:no-devin-env proceeds normally; any other not-local:<reason> applies <plugin-root>/devin/INSTRUCTIONS.md §Cloud Mode: emit the --banner, fan out sequentially with Reviewed-Coverage: sequential-fallback disclosure (never claim an independent review ran), message_user ack before any secrets read or production mutation, and run precommit-guard.sh before any git commit — hooks do not fire in cloud.
Grok Build (plugins/soleur/lib/harness.ts invokeSkill()): Read this SKILL.md in this process and run it to completion. A one-segment soleur:<name> in this document names a SKILL — on Grok Build, Read plugins/soleur/skills/<name>/SKILL.md in this process; it is not a nested tool_use. A multi-segment id such as soleur:<domain>:<name> names an AGENT: spawn it, never Read it, and on Grok Build spawn_subagent takes the id with its colons replaced by hyphens (agentIdToGrokSubagentType). Claude Code: Skill tool for a skill (soleur:<name>), Task tool with subagent_type for an agent. Forbidden is executing a subset, not the Read.
Triage all open remote GitHub PRs and drain the mergeable ones in one operator-confirmed pass: enumerate → triage into tiers → confirm scope → fix each in-scope PR to green → merge. The PR-counterpart to drain-labeled-backlog (which drains labeled issues). Distilled from the 2026-06-30 drain session that merged 11 PRs across tiers.
Use merge-pr for a single named PR. Use drain-labeled-backlog for labeled issues (not PRs). Use this skill to drain the open-PR queue.
<decision_gate>
Merging is outward-facing — confirm before any merge. This skill confirms tier scope with the operator via AskUserQuestion before merging anything, and supports per-PR opt-out within a tier (not just per-tier accept/reject). Confirming a tier means the selected PRs are squash-merged to main — this is not a preview; it lands code (higher irreversibility than the issue-drain, which ends at PR-opened). Respects wg-zero-agents-until-user-confirms.
API budget. Arming any PR that carries no passing review evidence, bot PRs included, delegates to soleur:review, which spawns review agents which run autonomously and spend non-trivial Anthropic credit against the key in your session, scaling with PR count and review-cycle depth. The --dry-run flag prints the full tier table with zero merges and zero delegation. Soleur does not bill or proxy these calls — Anthropic does. The Soleur LICENSE (BSL 1.1) disclaims warranty for runtime cost; you operate this loop against your own budget.
</decision_gate>
gh authenticated, jq available.#$ARGUMENTS
Optional flags (any subset):
--tiers <list> — comma-separated tiers to drain (e.g., ready-green,needs-lockfile-fix). Default: prompt for tier scope at the decision gate. Tiers: ready-green, needs-lockfile-fix, needs-conflict-resolution, needs-review, broken, plus ready-unarmed (recover-only, never armed). parked PRs are always excluded; drafts are excluded unless the operator names one (see Rules).--pr <N,…> — restrict the whole run to an explicit set of PR numbers (still triaged + still gated).--dry-run — print the full tier table and exit with zero merges and zero delegation. More valuable here than in the sibling because this skill merges.Verify gh and jq are on PATH (abort with installation guidance if missing). Verify the current directory is a git repository: git -C . rev-parse --git-dir >/dev/null 2>&1 — git errors clearly on non-repo paths, so a fail-fast precheck beats a confusing downstream error.
Delegate to the helper triage-prs.sh:
bash "${CLAUDE_PLUGIN_ROOT}/skills/drain-prs/scripts/triage-prs.sh"
The helper runs gh pr list --state open --json number,title,headRefName,isDraft,mergeable,reviewDecision,labels,author,createdAt,statusCheckRollup (two-stage gh --json … | jq, never gh --jq with --arg — learning 2026-04-15-gh-jq-does-not-forward-arg-to-jq) and classifies each PR into eight tiers:
| Tier | Signal | Default handling |
|---|---|---|
ready-green | mergeable=MERGEABLE, no failing/pending checks | arm through the arm check (§4) |
needs-lockfile-fix | deps PR (labels has dependencies) failing guards-ruleset (its lockfile-sync member) / test-webplat / e2e on a frozen-install step | fix-recipe (a) → merge |
needs-conflict-resolution | mergeable=CONFLICTING, few/no other failures | fix-recipe (b) → merge |
needs-review | bot-fix/review-required label, or a feature PR with no review | delegate to soleur:review, which posts the evidence §4's arm needs (an inline read cannot arm, §5) → merge |
ready-unarmed | ready PR whose head verdict (ci-head-verdict.sh) is no-run or stalled: no full CI run exists, the red test row is the draft run's. awaiting-approval is not here: it lands in needs-review (the line shows ci=awaiting-approval; a maintainer must approve the fork run) | recover, never arm, unless another session is still inside wait-ready-run for it: gh pr ready --undo <N>, then the whole ready block (ready-run-wait.md), then re-triage |
drafts | isDraft=true | skip — author-owned WIP, never merged. A draft that also carries parked stays here, flagged parked: true in the JSON and PARKED label (held for the operator) on its text line, and is never readied even when the operator names it |
parked | has the parked label ("Reviewed draft held until an approved window; do not merge or arm auto-merge") | skip — reviewed and held for the operator; never merged, never armed, never fixed here. The operator removes the label. A parked draft is classified under drafts (drafts are classified first). The parked-hold member step of the required secret-guards check (scripts/ci-parked-hold.sh, #12396) fails while the PR carries the label, which binds auto-merge, the merge queue and every non-bypass identity, and admin-merge-ready.sh reads it as a red required context; it does not stop an admin-credentialed gh pr merge --admin, and anyone with triage access can remove the label. .claude/hooks/ship-operator-step-gate.sh stays as local defence in depth on a branch that carries it; a draft PR remains the first hold. The tier prints a recovery: line saying to do nothing (no other tier carries one except ready-unarmed). The label match is case-insensitive, like the hook's |
broken | CONFLICTING and many failing checks | surface; fix only if in explicit scope |
Pass --dry-run to stop here and print the table.
Present the tier table via AskUserQuestion. The operator selects which tiers to drain and may opt individual PRs out within a tier. Nothing merges until this returns. (See the <decision_gate> block above for the irreversibility + budget framing.)
For each selected PR: bring it to green via the fix-recipes below if needed, then arm it through the arm check (under the merge queue this ENQUEUES the PR; it is not yet merged). A ready-unarmed PR (readied, but no full CI run exists) is NOT armed: recover it first (gh pr ready --undo <N> with a user token, then the whole block below; GITHUB_TOKEN cannot ready a PR). A draft the operator authorizes is readied the same way and armed only once K=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/ci-head-verdict.sh" ready-count <N>) && gh pr ready <N> && bash "${CLAUDE_PLUGIN_ROOT}/scripts/ci-head-verdict.sh" wait-ready-run <N> --before-count "$K" exits 0 (one Bash call, timeout: 420000; reasons and recoveries: ready-run-wait.md); on non-zero report "readied but unarmed" with the last stdout line and arm nothing:
The arm. Every PR takes this one arm. Run the arm check's first statement from review-evidence-comment.md, both PR_NUMBER tokens replaced by the PR number, after the fetch, then the arm, all in one Bash call. The fetch puts the PR head in the local object store, which the check's merge-base needs:
git fetch -q origin "pull/<N>/head" || { echo "fetch of PR <N>'s head failed: not armed"; exit 1; }
# REPLACE THIS LINE with the arm check's first statement (linked above), PR_NUMBER replaced by <N>; it exits 1 on refusal
gh pr merge <N> --squash --auto --match-head-commit "${H:?run the arm check in this call}"
On a refusal, including a bot PR that carries no evidence, run soleur:review on the PR (it posts fresh evidence), then the same call again. If it still refuses, skip the PR and list it in the §7 report as unarmed: evidence=<…> unreviewed=<…>, copying the two values the refusal line printed (the check's variables do not survive the call). Never arm around it. The check cannot see code written while resolving a merge conflict (it skips merge commits), so a PR onto which drain-prs pushed a hand-resolved merge goes to soleur:review before this arm, even when the check passes. First-party bot PRs normally arm themselves server-side; drain-prs arms one only when autoMergeRequest is null.
.github/**, without explicit operator confirmation. merge_group runs the candidate's workflows in the base-repo context with repo secrets, so a pre-queue-green fork or workflow edit can exfiltrate them before anyone reads a run. Check each PR before arming: gh pr view <N> --json isCrossRepository --jq .isCrossRepository and gh api repos/{owner}/{repo}/pulls/<N>/files --paginate --jq '.[].filename | select(startswith(".github/"))' (not gh pr view --json files: it stops at 100 files, so a large PR could hide a workflow edit); true or any output means stop and ask (the tier confirmation at the decision gate does not cover it).main (#9454, ADR-270; the merge_queue rule lives in infra/github/ruleset-ci-required.tf) — arming enqueues the PR (a green PR enqueues, so the bullet and the block above agree); the queue handles the up-to-date merge, serialization and the final merge automatically — do not hand-roll update/wait loops, and never push gh pr update-branch or a merge of origin/main to a PR that is in the queue (a push dequeues it). An admin-bypass merge (only via settle-then-admin-merge.md) is the last resort, not the drain path. CodeQL is advisory on main (it reports no status on merge_group); the post-merge codeql-main-alert-gate.yml run is the signal. History: a first adoption (#5800) was reverted the same day for exactly that reason (ADR-032 amendment, upstream github/codeql-action#1537); #5840 stays open as the upstream tracker.gh-readonly-queue/main/pr-<N>-<sha>, the failing check-run is on the queue SHA, not the PR head, so gh pr checks <N> still reads green. Read the run instead: gh run list --event merge_group --limit 100 --json databaseId,headBranch,headSha,conclusion,url --jq '.[] | select(.headBranch | startswith("gh-readonly-queue/main/pr-<N>-"))', (about 8 runs per queue entry, so a smaller --limit can miss the PR on a busy queue; under grouped merging a member PR's group ref names the DEEPEST member — an empty select means correlate recent merge_group runs by headSha/createdAt, not "no run"), then diagnose the failing job from that run. The dequeue is silent (a failed_checks removal is re-queued by GitHub 2 to 3.5 minutes later while auto-merge normally stays armed; a red advisory job does not dequeue, so do not push over it): the PR stays OPEN, so gh pr view <N> --json state,autoMergeRequest reads OPEN with auto-merge armed (autoMergeRequest set) or disarmed (null); section 7's wait names it (LEFT THE MERGE QUEUE UNMERGED, reason from the queue's removal event). Recipe: merge-queue-dequeue.md. On a conflict or lockfile / kb-index drift, the local arm is: merge origin/main into the PR branch (merge-pr §3.1 "Route conflicts"), push only for a failure that will recur, and re-arm only when autoMergeRequest is null, through merge-queue-dequeue.md step 3 (the recipe's steps 2 and 3 win over any shorter inline recovery text). Cap it at ONE re-enqueue per PR before escalating to the operator.[ship.phase7.queue_wait_expired] (an armed PR that merely reads BEHIND is waiting for GitHub to enqueue it; the ship Phase 7 poll prints [ship.phase7.queue_wait], and sync-pr-behind.sh itself refuses it with kind=queue_wait; never gh pr update-branch it). Otherwise, if the PR is not in the queue (an admin-bypass path, or a rejection that names "not up to date"), run gh pr update-branch <N> — but never when both sides moved the knowledge-base/ file count, which a server-side merge resolves without the kb-index driver; merge origin/main locally and push instead (see merge-pr/SKILL.md §3.1 "Route conflicts"), then wait for CI to go green using Claude: Monitor tool / Grok: AwaitShell (plugins/soleur/lib/harness.ts pollInstructions()) — NEVER a backgrounded poll loop (hr-monitor-not-run-in-background-for-polling, hook-enforced by background-poll-prefer-monitor.sh), then arm through §4's block above (an admin-bypass PR only through settle-then-admin-merge.md).Every PR drain-prs arms needs a passing Review-Evidence comment covering its head, and only soleur:review posts one, so a PR without one is delegated to soleur:review before §4's arm, whatever its size or author. That includes feature PRs (needs-review), single-file priority/p3-low bot-fixes, bot-authored scheduled content PRs (community digests, the campaign calendar, content-distribution promotes, weakness digests) and bot-fix PRs carrying bot-fix/review-required. A read of gh pr diff <N> is triage, not review: it can decide to skip a PR, never to arm one.
See knowledge-base/project/learnings/workflow-patterns/2026-06-30-update-branch-drifts-lockfiles-and-npm11-pin.md and knowledge-base/project/learnings/workflow-patterns/2026-06-30-stale-bot-cron-pr-hallucinated-api-and-registration-sweep.md for the full failure analyses.
(a) Lockfile drift on deps PRs. gh pr update-branch / a main-merge silently desyncs the lockfile. There is exactly ONE lockfile per directory since ADR-191 — do not recreate bun.lock:
cd apps/web-platform
npx --yes npm@11 install --package-lock-only # package-lock.json — npm@11 ONLY
The lockfile-sync member of the guards-ruleset CI umbrella pins npm@11; regenerating package-lock.json with local npm produces a divergent shape and fails the gate. On a lockfile merge conflict, resolve by regenerating (git checkout --ours -- <lockfiles> then re-run), not by hand-picking hunks.
(b) Generated-file conflicts. Since #8377 / ADR-235 exactly one generated artifact is still committed: knowledge-base/engineering/architecture/diagrams/model.likec4.json (the KB index trio and rule-metrics.json are untracked caches and cannot conflict). Resolve it with bash "${CLAUDE_PLUGIN_ROOT}/scripts/resolve-regenerable-conflicts.sh" origin/main, which completes the merge and regenerates from the MERGED sources; do NOT hand-merge conflict markers in a generated artifact, and do NOT side-pick (--ours/--theirs each yield an artifact matching neither side's sources). The same holds for a HAND-AUTHORED file whose conflict sits beside clean hunks: git checkout --theirs <file> takes that side's WHOLE file and silently drops the other side's non-conflicting edits (#9134, model.c4); git checkout -m <file> recreates the markers so only the conflicting hunk is resolved.
(c) Stale bot PR (especially crons). Rebase first (gh pr update-branch) to re-validate against current main — an old green predates current gates — except an armed PR on a merge-queue repo, which the queue makes current itself (see the armed-on-a-merge-queue-repo bullet above; never update-branch it). Then check for a hallucinated substrate API (tsc --noEmit) and missing registration locations per ADR-033 §Registration checklist (the canonical list of every gated location for a new cron-* function). Mirror the structurally-closest live twin signature-for-signature rather than the PR's prose.
Arming returns at ENQUEUE, not at merge. Run cleanup-merged only once the PRs it should reap read MERGED. Wait on each enqueued PR with a BOUND (90 polls x 60s, the Phase 7 cap), through the Monitor tool (set timeout_ms to its maximum, or persistent: true where the tool offers it: the default is 5 minutes and the watch can run past that, including a 10-minute hold on a BLOCKED PR; when it expires, check the process is gone before re-arming) / AwaitShell (a BLOCKED line alone is not the end on the read path: keep waiting for the SOLEUR_CI_REQUIRED_SET marker or a REQUIRED-SET READ — line; never a backgrounded loop): bash "${CLAUDE_PLUGIN_ROOT}/scripts/monitor-pr-checks.sh" <N> --interval 60 --max-polls 90. It reads the merge queue (sync-pr-behind.sh <N> --queue-state) and ends MERGED, or LEFT THE MERGE QUEUE UNMERGED with the removal reason (the dequeue arm above: ONE re-enqueue, then report), or a timeout, or CHECKS GREEN BUT BLOCKED for an armed, green, un-queued PR held by something outside the check list (after a 10-minute hold, followed by the required-context read: RECOVERY hints and a SOLEUR_CI_REQUIRED_SET marker, read per ready-run-wait.md; wait for the exit before re-arming); it never syncs or pushes. A watch that exits 4 (DUPLICATE MONITOR) means a live monitor already watches that PR (a re-run drain re-arms every enqueued PR, so this is the expected outcome there). If that watch is a Monitor or AwaitShell task of THIS session, it is still your watch: read its output. Otherwise it reports to a session that may be gone: read the queue once with sync-pr-behind.sh <N> --queue-state (a dequeued answer is the dequeue arm below; gh pr view cannot show a silent dequeue), keep the PR in the set awaiting MERGED, never count it as done, and never loop on that read. To hear the outcome yourself, confirm ps -o args= -p <pid> names monitor-pr-checks.sh, kill <pid> (that ends the other session's watch with no verdict line, so that session must read the PR state rather than re-arm), and arm once. An enqueued PR that never reaches MERGED is that dequeue arm, not a merged PR:
bash "${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh" cleanup-merged
Report the drain delta: before/after open-PR count and the per-tier outcome (merged / enqueued / skipped / deferred), listing an enqueued PR as enqueued until it reads MERGED, then one line per PR §4 refused (#<N> unarmed: …) and one per PR whose head fetch failed (#<N> unarmed: fetch failed; not a refusal, so no soleur:review retry).
If $ARGUMENTS contains a RETURN CONTRACT section (i.e., this skill is being driven by another skill), run headless: skip the interactive decision gate and --dry-run prompts; drain only tiers explicitly named via --tiers. Follows the same pattern as plan, review, and ship.
parked PR is never readied, armed or merged, even when the operator names it. The operator removes the label first, in the GitHub UI or their own terminal.parked label is the one exception to the exception: it is never readied, even when named (the parked rule below).CI Required and the merge queue re-runs the checks on its own candidate, so a mis-triaged red PR never lands — but under the queue it does not fail at merge time: a red candidate is a SILENT dequeue (the PR stays OPEN, auto-merge disarmed). See it with the dequeue arm in step 4 (gh run list --event merge_group, or gh pr view <N> --json state,autoMergeRequest); the triage is an optimization, not the safety boundary."${CLAUDE_PLUGIN_ROOT}/scripts/admin-merge-ready.sh", which must exit 0) and that file's merge block, never through a gh pr checks --required watch (#8458, #8500). For a PR that is BEHIND with the new head's checks unsettled, "CI was green" is encoded as --green-sha <prior-green-sha>: it certifies the current head only when that head is GitHub's own verified merge of the green sha and the base — see the reference's "was-green carryover" section.2026-06-30-* learnings and ADR-033 §Registration checklist referenced in the fix-recipes landed in PR #5808 — they are on main. If a future reorg moves them, update the paths here.update-branch CI wait (hr-monitor-not-run-in-background-for-polling).test-webplat/e2e shard on a deps PR is usually recipe (a), not a real regression — check the install step before assuming the bump broke something.Unit tests live at drain-prs.test.sh. Run them with:
bash plugins/soleur/test/drain-prs.test.sh
Covers: one synthetic PR per tier (ready-green, lockfile-fail, conflicting, review-required, draft, broken, parked, including a parked conflicting PR with failing checks, a parked dependencies PR with a failing check, a parked PR whose head verdict is no-run, a Parked capitalised label, a parked draft carrying parked: true, and a parked-old decoy label), the head-verdict rows (ready-unarmed, pending-full / decided / awaiting-approval, resolver error), an empty-list case, and the tier-grouped JSON output shape.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jikig-ai/soleur --plugin soleur108 skills in this plugin
/admin-ip-refreshThis skill should be used to refresh the prod SSH allowlist (Doppler ADMIN_IPS) after operator IP rotation. Detects drift, mutates Doppler with explicit ack./agent-browserThis skill should be used when automating browser interactions via Vercel's agent-browser CLI. It handles web page navigation, form filling, screenshots, and data scraping using ref-based element selection./agent-native-architectureThis skill should be used when designing agent-native applications where agents are first-class citizens: architecting autonomous agents, creating MCP tools, building apps where features are agent-driven outcomes.Other plugins' skills for the same job