/dstack-git:gate-and-mergefrom DStack Git
Gates and lands a queue of open PRs one at a time: reviews feedback, then merges, repairs, holds, or closes each. Human-in-the-loop only.
Ships in DStack Git. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Work through the open PRs or MRs in order, gating each one and driving it to a terminal: merged, repaired then merged, held, or closed. Every merge changes the base the next PR is gated against, so the loop stays serial. Never merge on a pending or pre-fix head.
This skill fires no sibling skill (disable-model-invocation: true). The feedback sweep reaches bundled scripts in scripts/ by path rather than by invocation.
Single-PR feedback with no merge belongs in resolve. Review-only passes do not land here.
OWNER/REPO (GitHub) or GROUP/PROJECT plus --host (GitLab) when the queue sits outside the current repository. The two read-only sweep scripts take it; the two thread-mutating ones need no repository argument.List every open PR with exactly this field list on GitHub (never add statusCheckRollup here; references/gotchas.md carries the failure it causes):
gh pr list --state open --limit 100 --json number,title,url,headRefName,baseRefName,headRefOid,isDraft,mergeable,mergeStateStatus,reviewDecision,maintainerCanModify
On GitLab use glab mr list --repo <GROUP/PROJECT> -P 100 -F json, paging with -p until a page returns empty and filtering locally with --jq (glab emits whole REST resources with no per-field selection). Page through everything. One page is never the full queue. Never gate on a rolled-up value here: detailed_merge_status (not the deprecated merge_status), head-pipeline state, approvals, and blocking_discussions_resolved are read separately per MR at their gates.
Build the stack order next. A GitHub PR whose baseRefName equals another open PR headRefName is that PR child; the rest are roots. The GitLab equivalent compares target_branch against other open MR source_branch. Order topologically, parents first, roots by ascending number or IID. Print the order as a tree and take one yes before the first merge. Parent merges retarget children on GitHub, so re-read each child baseRefName at its turn instead of trusting the opening graph. On GitLab re-read each child target branch and head SHA at its turn for the same reason.
Run the gate ladder below for each PR in order. Draft flags and unhandled nils are both findings; they differ only in what produced them, so no separate mechanical prefilter plus QA pass is needed.
Two questions decide the terminal, asked in this order. First, direction: the PR stated concern still holds, and its approach is still the one to take. Second, repair bound: every surviving finding has a bounded repair.
| Verdict | Condition | Action |
|---|---|---|
close | The concern is already satisfied, the approach is superseded, or the repair would replace the whole change. | Close with a rationale comment naming the evidence, after the human says yes to the close set. GitLab close is a separate step from the comment: post the note first, then glab mr close <iid> (no closing-comment flag exists). |
repair | Direction holds and every finding repair is bounded. | Repair at the root on the PR head branch, push, re-run the checks gate against the new head, merge. |
hold | Direction holds and one finding repair is unbounded, or a swept thread stayed needs-human. | GitHub: one PR review via gh pr review <n> --comment --body-file - carrying every unresolved finding. GitLab: one note via glab mr note create <iid> -m "<findings>" (the note family is EXPERIMENTAL; stable automation uses the discussions REST API via glab api), or the bundled scripts/gitlab-mr.py reply path (python3 scripts/gitlab-mr.py --host <host> --project <GROUP/PROJECT> --mr <iid> reply --discussion <hex-id> --body-file <tmp> --expected-head <approved-head-SHA>). Hold, then continue the queue. |
merge | No finding survives the ladder. | Merge at the current head SHA (headRefOid or MR sha). |
A repair counts as bounded only when all three hold: it changes no public contract the PR did not already change; the repository verification passes after it; it needs no decision the PR author has not already made. Anything else is unbounded. gh pr diff <n> --name-only is not the allowlist, because a root-cause repair reaches the subsystem owning the fault rather than staying inside the changed hunk. The file list feeds the first condition; it is not the test. Prefer --comment over --request-changes, because a comment records findings without seizing approval state.
Dispatch one fresh-context subagent per PR to run the reading gates: scope, diff, and tests. The assignment template is references/reviewer-subagent.md. Subagents return findings only. They never merge, push, comment, or see the merge decision, and they are never asked for a verdict. Mergeability, review feedback, and checks stay with the orchestrator, since each needs the queue-wide view or the mutation authority.
Treat each finding as evidence about the design that produced it. Name the design-level fault in one sentence before touching a line. Shape the repair so the general case absorbs the special case, then re-read the touched surface afterward. Conditionals that special-case the reported input, wrappers that catch the fault downstream, or flags that hide it leave the fault in place and do not count as repairs. Repairs may reach outside the PR file set and still stay bounded, provided they meet the three verdict-table conditions. File identity is not the test.
isDraft: true holds the PR with no comment. A draft is not asking.mergeable: "CONFLICTING" takes the conflict path in references/gotchas.md.reviewDecision: "CHANGES_REQUESTED" routes to the review-feedback gate rather than terminating here. The sweep answers the reviewer with a repair or a declined-with-evidence reply. Items the sweep cannot settle stay needs-human and hold the PR. The human is never overruled.draft: true holds the MR with no comment. detailed_merge_status: "conflict" (with has_conflicts) takes the conflict path in references/gotchas.md. not_approved routes to approvals (required approvals and approval rules stay distinct gates; a self-authored MR never self-approves). discussions_not_resolved and requested_changes route to review feedback, ci_must_pass and ci_still_running route to checks, and need_rebase plus draft_status hold for rebase or draft. The deprecated merge_status stays unused, and no single folded value gates anything. Read detailed_merge_status, the head pipeline, and the approval and discussion flags separately.Treat forge mergeability as a reported state, never as an explanation. For UNKNOWN or a disputed conflict flag, record the reported full base and head OIDs and compare that exact pair with the repository merge implementation where available. A newer live base gets evaluated separately when relevant. Never present the two results as one snapshot. Resolve abbreviated OIDs through actual objects; trailing hex is never invented.
Distinguish a clean merge result, actual content conflicts, and an inability to evaluate from missing objects or tool errors. Record a resulting tree where produced and inspect the relevant content when claiming preservation. A clean local merge proves only that pair under that merge implementation. Reviews, checks, and branch protection stay unsatisfied by it. Never auto-push an empty commit, close and reopen a PR, or claim UNKNOWN proves progress. When forge policy evidence stays unavailable, hold with the local proof and the unresolved forge fact stated separately.
Never gate on mergeStateStatus. The evidence lives in references/gotchas.md.
A PR carrying an unresolved thread, a non-empty review body, or a non-bot top-level comment reaches this gate. The rest skip it. The procedure is references/feedback-sweep.md, bound by five rules:
python3 scripts/gitlab-mr.py --host <host> --project <GROUP/PROJECT> --mr <iid> list, which returns the MR head SHA plus the full discussion and ordinary-note census across every page. Any head change across the census fails it instead of returning mixed evidence. Reply and resolve through the same helper (reply --discussion <hex-id> --body-file <tmp> --expected-head <approved-head-SHA>, resolve --discussion <hex-id> --expected-head <approved-head-SHA>), binding each mutation to the surveyed and adjudicated approved revision (never fetch a new head merely to satisfy the flag; a changed head stops publication for re-adjudication). Approval and reply-before-resolve stay mandatory. No GitHub node IDs on GitLab: address the MR by IID, discussions by hex ID, notes by integer ID.references/feedback-sweep.md, taken verbatim from resolve rubric. Verdicts of fixed or fixed-differently get repaired under the posture above, then replied to and resolved.needs-human sets the PR verdict to hold.git rev-list <review-commit>..<HEAD>: 0 is current, 1 to 3 is recent, 4-plus or unresolvable (rebased away) is stale. Stale approval holds the PR for re-review before merge. On GitLab pass the reviewed SHA explicitly (glab mr approve --sha <sha> refuses with 409 on mismatch) so a later head move cannot silently inherit approval.Finished when every enumerated item carries a verdict, every fixed and fixed-differently item is repaired with its thread resolved, and only needs-human threads stay unresolved.
The subagent reports the file set as mixed concerns, as a lockfile or generated path alongside source, or as one concern. Mixed concerns make later reverts impossible, and splitting a PR is a decision its author has not made, so a mixed-concerns finding fails the third bound condition and holds the PR. Criteria live in references/reviewer-subagent.md.
The subagent reads the whole diff once and returns findings in six classes, from wrong-on-a-plausible-input through convention. Each finding names a reachable input or state, a file:line, the design-level fault it evidences, and every file its repair would touch. Merely unlovely lines are not findings. Classes and return shape live in references/reviewer-subagent.md. The returned file list feeds the bound test; it is not the test. Read it against the three verdict-table conditions.
The subagent reports a behavior change with no test that fails without it, plus whether the repository has a suite fitting the change and whether the change touches a trust boundary or data at rest. Both answers feed the bound test. Plumbing never gets a test demanded for it.
This gate runs last, against the head that will actually merge. Any push from the feedback or repair path moves the head SHA and restarts CI, so earlier reads describe a head that no longer exists at merge time.
GitHub:
gh pr view <n> --json number,headRefOid,statusCheckRollup
GitLab: python3 scripts/inspect_mr_checks.py --host <host> --project <GROUP/PROJECT> --mr <iid> --json (--repo sets the subprocess working directory only). Exit 0 is verified green on the current head SHA; 1 is failed jobs or helper failure; 2 is indeterminate (running, missing, skipped, unrelated). Only 0 merges. The head pipeline must match the MR head SHA. A missing, skipped, or unrelated successful pipeline proves nothing.
Read one PR at a time, never in the bulk listing. references/gotchas.md carries why, plus how to read a CheckRun against a legacy status context and what to do with a still-running check.
Read required checks against the full head that will merge. Confirm head repository and ref identity (on GitLab: source project, source branch, and sha) before interpreting a mismatch between remote ref and PR metadata. Record the mismatch as pending evidence. Propagation lag is never diagnosed from elapsed time alone. Prior-head results never cover the new head, and zero runs is neither pass nor skipped. Head changes invalidate prior check evidence.
Separate scanner execution, policy evaluation, required status checks, review requirements, and protection rules. Successful analysis jobs never prove their policy evaluation passed. Fork-available check coverage gets reported separately from checks that were unavailable or never registered. Reported baseline failures get compared at the relevant base and configuration rather than treated as exoneration by any red main run.
Check out the PR into an isolated worktree. Repair at the root, make one commit whose subject names the gate that caught it, and push.
Cross-repo and fork limits change delivery, not the finding. GitHub maintainerCanModify: false on a cross-repo PR makes the push impossible, so the repair becomes a comment carrying the patch. A refused GitLab push to a fork-owned MR source branch becomes a note carrying the patch the same way.
Merge with a race guard both forges provide. GitHub: gh pr merge <n> --merge --match-head-commit <current headRefOid>, which refuses if the head moved under a concurrent push. GitLab: glab mr merge <iid> --sha <current sha> -y after exact approval, with --sha refusing on head move. Re-read the head SHA and re-approve rather than retrying blindly. glab mr merge has no general dry run.
Keep the landing queue serial at the merge boundary, because each merge changes later bases. Re-read each child actual base, head, and state at its turn. Conflict repairs never authorize rewriting the published branch. Use the permitted additive integration path unless a distinct rewrite was explicitly approved. Never recreate merged or closed refs, and verify the actual head repository before any repair push.
Merge queues and auto-merge are not interchangeable. On GitHub, when target rules require a merge queue, use the supported enqueue operation under the existing merge authorization and verify queue membership separately from final merge completion. GitLab has no GitHub-style merge queue: use --auto-merge (merge-when-pipeline-succeeds) under the existing merge authorization and verify separately (merge trains are Premium-tier and platform-managed, with no queue-position or bypass flag). Confirm the current ruleset and accepted API input rather than assuming one maps to the other. Required reviews and approvals stay required. Self-authored PRs never get self-approved by another credential or administrator bypass. Permitted bypasses need a separate exact preview with explicit authorization; otherwise hold for the required reviewer. Preserve the source branch unless deletion was separately requested (-d on GitLab only with explicit approval).
| File | Open it when |
|---|---|
references/feedback-sweep.md | The review-feedback gate fires, meaning the PR carries an unresolved thread, a review body, or a top-level comment |
references/reviewer-subagent.md | Dispatching the reading gates for a PR, at the dispatch step |
references/gotchas.md | The checks gate reads a PR, the listing call fails, mergeStateStatus or detailed_merge_status looks like a gate, or a PR conflicts |
hold, with the close rationale posted as the review comment. Closes never happen without the yes.hold. Absent reviews never merge.mergeable: "UNKNOWN" (GitHub) or detailed_merge_status stuck at checking, approvals_syncing, or unchecked (GitLab) means hold, with the local proof and the unresolved forge fact stated separately.gh pr checks <n> --watch --fail-fast then re-read; GitLab re-run of the checks helper (or poll plus -F json status parse) then re-read. Non-success statuses never merge.maintainerCanModify: false, GitLab refused fork-source push) deliver the repair as a comment or note carrying the patch. No second push flow is attempted.--match-head-commit (GitHub) or --sha (GitLab) refuses on head move. Re-read the head SHA and re-merge.gh pr view state: merged means done (possibly by a concurrent merge; report as merged-on-remote, not merge-succeeded). Open with a queue request means keep waiting. Open without means stop with the error plus the state. Closed means stop. GitLab glab mr view <iid> -F json: merged means done (report as merged-on-remote); opened with merge_when_pipeline_succeeds: true means auto-merge armed, so keep waiting; opened without means stop with the error plus the state; closed means stop.git fetch the base, git checkout -b revert/<merge-sha> <base>, git revert <merge-sha> --no-edit. Push straight to base only when the base is unprotected; otherwise push the revert branch, open a revert PR (GitLab: glab mr create --repo <project> --title "revert: <original title>" --description-file <tmp> --source-branch revert/<sha> --target-branch <base> -y after exact approval), and report it. On conflict stop and report the merge SHA.One line per PR naming its verdict: merged, repaired-then-merged with the repair SHA, held with the gate and the comment URL, or closed with the rationale comment URL. Merges never happen on pending or pre-fix oids. For every PR that reached the review-feedback gate, add swept-thread counts: enumerated, repaired, replied, resolved, and left needs-human.
agents/openai.yaml (opens in a new tab)references/feedback-sweep.md (opens in a new tab)references/gotchas.md (opens in a new tab)references/reviewer-subagent.md (opens in a new tab)scripts/get-pr-comments (opens in a new tab)scripts/get-thread-for-comment (opens in a new tab)scripts/gitlab-mr.py (opens in a new tab)scripts/inspect_mr_checks.py (opens in a new tab)scripts/reply-to-pr-thread (opens in a new tab)scripts/resolve-pr-thread (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub gosuda/dstack-skills --plugin dstack-git15 skills in this plugin
/atomic-issues-prsUse when the user says "atomic PRs" or requests one issue or PR per logical change. Don't use for single-change pushes or uncommitted change-sets./commit-push-currentUse when a human explicitly asks to commit and push to the checked-out branch with no branch creation and no pull request. Not for the default branch: use commit-push-main; not for a pull request: use commit-push-pr./commit-push-mainUse when a human explicitly asks to commit and push directly to the default branch, with no feature branch and no pull request. Not for another checked-out branch: use commit-push-current.Other plugins' skills for the same job