agentleFS
kostya-epifanovkostya-epifanov/claude-gantry/skills/integrate/SKILL.md

integrate

Skill1 starsChanged 3 months agoMITView on GitHub

Merges the ready open PRs one at a time into a fresh integration branch, resolving conflicts by what each PR is for, running the repo's checks after every merge, and opening one integration PR. Use when the user types "/gantry:integrate", or asks to integrate or combine the open PRs.

  • Commits and pushes

14 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use discover and audit.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    discover

    Also in 3 projects that use this

  • OpenAISkill

    audit

    Audit or critique a product flow, journey, workflow, funnel, onboarding path, checkout path, settings path, screen, or multi-step product experience by capturing screenshots first, then reporting UX, design, and accessibility findings inline from that evidence. Use Figma only when the user explicitly asks for a board. Use when the user asks to audit, review, critique, inspect, assess, analyze, evaluate, or give feedback on a product experience.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never touches a source PR's branch: No push, no rebase, no close, no edit.

    line 31
  2. Very specific:

    Read references/merge-loop.md — the conflict rules, the fix-attempt cap, the reset guard, and what a resumed or interrupted run has to do …

    line 44
  3. Distinctive:

    Every other stage's ask carries a pointer back here, by the rule's name.

    line 62
  4. Very specific:

    Read BASE (the base branch every candidate must target), GH, and BRANCH.

    line 121
  5. Distinctive:

    every predicted conflict, with both PRs' stated intent beside it, because that is what the resolution will be made from.

    line 244
  6. Distinctive:

    every skipped PR and its reason, in the script's words.

    line 246
  7. Distinctive:

    Ask: "Merge these N PRs in this order?" A "no" here costs nothing.

    line 249
  8. Distinctive:

    If nothing is off, make no commit and carry no docs change needed forward to the report and the PR body.

    line 420

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

gantry:integrate

Turn N open pull requests into one pull request whose combined tree passes the checks.

It reads the open PRs, states why it is leaving each unready one out, plans a merge order from a conflict matrix computed before anything is touched, then merges the rest one at a time into a fresh integration/<date> branch cut from the base. Every merge is a real merge commit, every conflict is resolved from what the two PRs are for, and the gate runs after each one — so a failure belongs to the PR that caused it rather than to the pile.

Why it exists. gantry:auto-unattended leaves a stack of drafts, each cut from the base and each checked only on its own. They conflict with each other on the boring shared surfaces — docs tables, counts, a version, a shared script — and a PR that passed alone can break once it meets the others. A green check on a PR says nothing about the combined tree. This skill is what says something about it.

Supervised by default. Two checkpoints: the queue, before any work starts, and the pull request, before anything outward-facing. --unattended prepares the same integration with nobody there: it answers every one of those questions by a fixed rule, publishes the PR as a draft, and still never merges it. See Unattended mode below and docs/SKILLS.md.

What it will not do

  • Never touches a source PR's branch. No push, no rebase, no close, no edit. The only write to a source PR is one comment, after you confirm it (--unattended posts none).
  • Never squashes or rebases. Merge commits keep each PR's commits reachable, which is what lets GitHub mark the source PRs merged when the integration PR lands — see references/pr-body.md.
  • Never takes --ours or --theirs wholesale, and never drops a hunk. A resolution is made from both PRs' stated intent, and recorded in the merge commit.
  • Never merges the integration PR. That is yours — in --unattended too, and it never runs gh pr ready either.
  • Never continues past a red gate by moving on to the next PR and hoping. It resets that merge out and says so.

Before you start

Read references/merge-loop.md — the conflict rules, the fix-attempt cap, the reset guard, and what a resumed or interrupted run has to do first. Read references/pr-body.md before composing anything outward-facing.

$GANTRY is this skill's plugin root — resolve it from this file's own location rather than hardcoding a path.

Every command below is flat: one invocation, no substitutions, no pipes, no chaining. Run them one at a time and read the output. tests/cases/integrate_flat_commands.sh keeps that true.

Unattended mode

--unattended is for a routine that prepares an integration while the owner is away. It is the same skill with the same guards — the base is gated first, every merge is gated, --strict throughout, two fix attempts, the reset guard, the lens review of the integration's own lines. What changes is that nothing is asked: each place the supervised skill would ask has one fixed rule, and where no rule can be safe the run stops or the PR is skipped. It never guesses a decision into the tree.

Every other stage's ask carries a pointer back here, by the rule's name. Read the rule before the stage.

RuleWhere supervised mode asksUnder --unattended
laneStage 2: an integration lane is already openResume only if this run is already on that lane's branch. Otherwise stop and name the lane: a second lane is how one integration PR silently becomes two. Find the lane's worktree with git worktree list --porcelain (the entry whose branch is that integration/* lane), read integrate-stop.txt at its root, and put that record's rule, reason and date in the stop line after the lane's name — so the owner sees why the lane is stuck, not only that it is. With no record there, say none was found, and give task.md's status if it exists. A routine that starts outside the lane therefore stops, by design, until the owner merges or removes the open one.
queueStage 4: merge these N PRs in this orderTake the queue order_queue.sh printed. On a fresh run, an empty queue stops the run before any lane exists, and the report says why each PR is out. On a re-run an empty queue is not a stop: everything is already integrated, so the run goes on as NEXT:nothing — docs, review and publish.
parentStage 5: which parent gantry:worktree should cut from<BASE>, always — the skill already says so. A HEAD that is neither fresh origin/<BASE> nor the planned base sha is the wrong-parent stop, as in supervised mode.
base-movedStage 5: re-ask the queue when base movedRe-run order_queue.sh and continue with the queue it now prints. No re-ask.
no-gatesStage 5: baseline gate exits 3 (NO-GATES)Stop. Never continue with no enforced checks; suggest .claude/gates.sh. The baseline runs before task.md exists, so there is no status to set: the UNATTENDED: stopped line and integrate-stop.txt (below) are the record.
conflictMerge loop: the two intents do not settle a conflict, or a version bump is not additiveSkip that PR by the ordinary skip procedure in stage 6 — reset the merge out under the reset guard, delete its pre-merge ref, record unresolved-conflict (unattended) under ## Skipped, cascade to stacked children. It is never a coin-flip resolution. A conflict in the base-into-lane merge (NEXT:merge-base, Base moved in references/merge-loop.md) has no PR to skip: git merge --abort, set status: blocked, and stop.
published-resetMerge loop: a reset that would discard a merge already pushedStop, status: blocked. Never reset or revert a published merge.
finish-mergeRe-run: a session died mid-conflictgit merge --abort, reset to that PR's pre-merge ref if one is left, re-queue the PR.
rewrittenRe-run: a PR was force-pushed since it was mergedStop, status: blocked, and name the PR. Never merge its new head — and skipping is not safe either: its earlier merge is already in the lane, and a skip never takes it out, so the draft would carry the stale commits under a row saying "skipped".
lens-errorStage 8: risk_floor.sh exits 2status: blocked and stop before any push; the report says the lens is malformed or could not run.
prStage 9: push, open the PR, comment on the included PRsRe-read reality; if a PR is now stale, re-merge its new commits once — through the gate and stage 8 again — and list any PR still stale in the body. Then publish with gh pr create --draft. No comments on the source PRs: say in the report that none were posted.

Where the run leaves a record. task.md is written in stage 5, so a stop before it (parent, no-gates, a red baseline, gate exit 2) has no file to mark — and task.md never holds a reason or a date even after it exists. So every unattended stop made once this run's lane worktree exists also writes integrate-stop.txt at the lane's root: exactly three lines, rule: <rule>, reason: <reason>, date: <UTC date, from date -u +%F>. The reason is one line — the same text as the UNATTENDED: stopped line's <reason>, never pasted gate output. Run bash "$GANTRY/lib/ensure_excluded.sh" /integrate-stop.txt first, so the record is never committed. A later stop overwrites it; a run that publishes deletes it (stage 10). A stop before this run has a lane (queue) writes no record. The lane stop never writes or overwrites one either: the open lane is not this run's, and its record holds the cause the owner needs — the lane stop only reads it back (see that rule). Every unattended stop also begins the report with the line UNATTENDED: stopped — <rule> — <reason>, which is what a caller reads. <rule> is the rule's name from the table, or — for a stop no rule names (wrong arguments, gh missing or unauthenticated, a red baseline, gate exit 2, a red docs gate after two fixes, a PR that keeps moving) — the stage's name, e.g. stage-1 or stage-7; never free text. Once task.md exists, the stop also sets status: blocked first, as the loop already requires. A run that publishes ends with UNATTENDED: published draft <url> instead. The mode: in task.md is unattended; it is a label for a reader, and the hook behaves as in any other mode.

What the PR body says. It opens by stating the PR was prepared unattended, is a draft, and has not been merged by anyone: draft means unwatched, not unverified — the reviewer reads the resolutions as nobody has. See references/pr-body.md.

Stage 0 — Arguments

$ARGUMENTS is one string. Recognise PR numbers, --base <branch> and --unattended. Numbers are an explicit list and override discovery. Anything else, say what you did not understand and stop.

State the mode back in one line: which PRs (or "discover"), the base if one was given, and whether it is supervised or --unattended. Under --unattended, never call AskUserQuestion — not in this skill and not in a skill it invokes; the table above is the whole answer to every question.

Stage 1 — Where this run stands

bash "$GANTRY/skills/ship/scripts/detect_state.sh"
bash "$GANTRY/skills/ship/scripts/detect_state.sh" --base <branch>

Read BASE (the base branch every candidate must target), GH, and BRANCH.

  • GH:missing or GH:unauth → stop. Discovery, the contracts and the PR all need it.
  • DETACHED → stop.
  • BRANCH starts with integration/ → this is a re-run in an existing lane. The base is not re-detected from scratch: take it from the lane's own integration PR when one exists (gh pr view --json baseRefName), else from task.md's base: field at the worktree root. A --base that disagrees with either is a stop, not an override — the lane was cut from one base and can only target that one.

Stage 2 — Candidates, and why each other PR is out

git fetch origin <BASE>
bash "$GANTRY/skills/integrate/scripts/list_candidates.sh" --base <BASE>
bash "$GANTRY/skills/integrate/scripts/list_candidates.sh" --base <BASE> 21 23 24

One block per PR, then CANDIDATES: and SKIPPED:. The script decides this, not you — do not second-guess a verdict, and do not add one of your own.

What the classes mean when you show them:

  • DRAFT:yes is not a reason to skip. Unattended runs open drafts, and those are the PRs this gathers.
  • CI:failing is a skip. CI:pending and CI:none are candidates, and both are shown at the checkpoint: pending may still go red, and none means the PR's own checks never ran at all.
  • MERGEABLE is reported and never acted on. Whether a PR can go in is decided in stage 3, against the base you just fetched.
  • RISK: is the Risk level: under the PR body's ## Risk heading. A PR with no ## Risk section is skipped (no-risk-section), and so is one whose level is not low, medium, high or critical (risk-level:<word> — unassessed is what ship writes when no review ran or the lenses could not be evaluated). The integration PR's ## Risk summary is the maximum over the PRs it merges, and a PR with no assessed level would make that maximum a claim nobody checked. Name every such PR in the checkpoint and the report, with the remedy: /gantry:review then /gantry:ship on its branch, which refreshes the section on the open PR. When the PR body's ## Risk section (from gh pr view <n> --json body, below) carries a Lenses: could not be evaluated line, the remedy is instead to fix the lens on the base branch, then /gantry:ship — re-running review does not clear it. Never merge one anyway, and never write a level for it.

Then read each candidate's contract — a gantry PR body carries ## What this change is for, ## Deliberately not done and ## Not proven by this run, and those are what you resolve conflicts from later — and its ## Risk and ## Guarded changes sections, which stage 10's ## Risk summary and ## Guarded changes are built from:

gh pr view <n> --json body

A CONTRACT:none PR still works. You have its title, its diff and its comments, and you say in the report that you had no stated intent for it.

An INTEGRATION_PR: line, or an existing integration/* worktree, means a lane is already open. Ask (AskUserQuestion; under --unattended, rule lane) whether to resume it — which means re-running this command from that worktree — or to start a new one.

Stage 3 — The queue, planned before anything is touched

Name the lane first, because every ref this run writes is named after it:

date -u +%F

The lane is integration/<that date>. If a branch of that name already exists locally or on origin, use the first free -2, -3 suffix — appending to yesterday's lane by accident is how one integration PR silently becomes two:

git show-ref --verify --quiet refs/heads/integration/<date>
git ls-remote --heads origin refs/heads/integration/<date>

ls-remote exits 0 whether or not it matched — a remote branch exists only when its output is non-empty. On a re-run the lane is the branch you are already on.

Then fetch every candidate's head into a lane-scoped ref, in one command, so the objects are present and stay reachable:

git fetch origin +refs/pull/21/head:refs/integrate/integration/<date>/pr/21 +refs/pull/23/head:refs/integrate/integration/<date>/pr/23

refs/ lives in the common git directory, shared by every worktree of this repository, so an unscoped refs/integrate/pr/21 would be one ref two lanes fight over — one lane force-moving the head the other is merging from. Scoping by lane is what makes two lanes at once safe.

bash "$GANTRY/skills/integrate/scripts/order_queue.sh" --base <BASE> --created 21:<epoch> --created 23:<epoch> 21=refs/integrate/integration/<date>/pr/21 23=refs/integrate/integration/<date>/pr/23

Pass --created from each PR's CREATED: epoch, so a rebased old PR is not treated as young. Pass --after <child>:<parent> for any pair the candidate list reported as STACKED_ON — ancestry usually shows it, and --after is what covers a parent that was force-pushed since.

It prints the stack relations, each item's size and age, the skips, the pairwise conflict matrix, and the queue. It creates no commit and moves no ref.

Compare each ITEM: sha against that PR's HEAD_SHA. A difference means the PR moved between listing and fetching — go back to stage 2 rather than planning against a head that no longer exists. Under --unattended, go back once; a second mismatch stops the run (stage-3), so a PR under active pushes cannot loop it.

On a re-run, also run the state script (stage 5's command) and fold it in: integrated items leave the queue, stale items re-enter it, unverified items go to the front (their merge is in and unproven, so it is gated before anything is added to it), a STRAY_PRE: ref is deleted before its item is re-queued, and rewritten items are shown for a decision (--unattended: rule rewritten, stop).

Stage 4 — Checkpoint: the queue

AskUserQuestion (under --unattended, rule queue). Nothing has been created yet. Show:

  • the queue in order, each item with why it sits there (isolated, overlapping, stacked), its CI class and its RISK: level;
  • every predicted conflict, with both PRs' stated intent beside it, because that is what the resolution will be made from;
  • every skipped PR and its reason, in the script's words;
  • on a re-run, what is already integrated, what is stale, and anything rewritten.

Ask: "Merge these N PRs in this order?" A "no" here costs nothing.

Stage 5 — The lane

Invoke gantry:worktree integration/<date>, with the name stage 3 settled. Let it own the branch, the fetch and entering the worktree.

It picks its own parent, and that is the one thing it cannot be told. gantry:worktree prefers develop, then origin/HEAD, then master/main, and asks when the current branch is something else — so under --base <branch> it can cut the lane from a branch this run is not integrating into. If it asks which parent to use, the answer is <BASE> (rule parent under --unattended). Then check, rather than assume:

git rev-parse HEAD
git rev-parse origin/<BASE>

Three outcomes, and they are not the same problem:

  • HEAD equals the fresh origin/<BASE> → right lane, current base. Go on.
  • HEAD equals the BASE: sha order_queue.sh printed, but origin/<BASE> has moved → base moved while you were at the checkpoint. Re-run order_queue.sh, and re-ask stage 4 only if the queue, the conflicts or the skips changed (--unattended: rule base-moved, no re-ask).
  • HEAD is neither → the lane was cut from the wrong parent (--unattended: write integrate-stop.txt, rule parent). Stop. Do not merge anything into it and do not "fix" it by merging the base in: the lane would then carry every difference between that parent and <BASE>, and the PR would offer all of it for review. Say which branch it was cut from, and that the remedy is to remove the lane (git worktree remove) and re-run from <BASE>.

The baseline gate, before task.md exists

bash "$GANTRY/lib/run_gates.sh" --strict

A red base makes every later red gate ambiguous, so it is proved first:

  • 0 → go on.
  • 1+ → stop (--unattended: write integrate-stop.txt, rule stage-5). The base itself is red. Nothing merged here could be blamed fairly.
  • 2 → stop (--unattended: write integrate-stop.txt, rule stage-5). The gate could not run.
  • 3 → NO-GATES under --strict. AskUserQuestion (under --unattended, rule no-gates, which writes integrate-stop.txt): continue with no enforced checks (which goes in the PR body under Not proven by this run), or stop and add .claude/gates.sh first. This is the one place the strict default can be overridden, and only by you.

This runs before task.md is written, deliberately: the readiness hook arms on task.md plus status: implementing, and a stop chosen here should not be blocked by it.

Then write task.md

At the worktree root, not committed (gantry:worktree already excluded it):

---
id: integration-<date>
title: Integrate PRs <numbers> into <BASE>
project: <repo>
branch: integration/<date>
base: <BASE>
mode: <auto, or unattended under --unattended>
status: implementing
---

with the queue as its Context & goal, one acceptance criterion — run_gates.sh --strict exits 0 on the final tree — an Open questions section saying None., and a ## Skipped section, which is where a skip decided during the loop is written down so a later run and the PR body both find it.

status: implementing arms the readiness hook where the repo has .claude/gates.sh, so a turn cannot end on a red combined tree. Before any deliberate stop, set status: blocked first — see references/merge-loop.md.

On a re-run, act on the state before merging anything

bash "$GANTRY/skills/integrate/scripts/integration_state.sh" --base <BASE> 21=refs/integrate/integration/<date>/pr/21 23=refs/integrate/integration/<date>/pr/23

Route on NEXT: — finish-merge, verify, merge-base, merge-items — exactly as references/merge-loop.md sets out. It is an order, not a menu.

Stage 6 — The merge loop, one PR at a time

Full rules in references/merge-loop.md. The shape, per queued PR:

git update-ref refs/integrate/integration/<date>/pre/21 HEAD
git -c rerere.enabled=true -c merge.conflictStyle=zdiff3 merge --no-ff --no-commit refs/integrate/integration/<date>/pr/21

Resolve any conflict from both sides' intent. Then:

git -c rerere.enabled=true commit -m "integrate: merge #21 — <title>" -m "<one line per conflicted file, and how it was resolved>"
bash "$GANTRY/lib/run_gates.sh" --strict

Green → drop the pre-merge ref and take the next PR:

git update-ref -d refs/integrate/integration/<date>/pre/21

Red → a separate fix commit, then the gate again, at most twice. Still red → reset this merge out, delete the pre-merge ref, record the skip in task.md's ## Skipped, and skip every queued PR stacked on it. Exit 2 → stop, and it does not count as an attempt.

Deleting that ref is part of the skip, not tidying. Left behind, the state script reads it as a merge whose gate never went green, so the next run sends a PR that was deliberately skipped back into the fix loop for a merge that is no longer in the tree — and NEXT: never reaches nothing.

The settings ride on git -c rather than git config: a linked worktree's git config writes the repository-wide file that every other checkout reads.

Stage 7 — Docs: check and update the docs for the combined tree

Each source PR documented its own change alone, against the base it was cut from. The combined tree is what the docs now have to describe, and the boring shared surfaces — a skill count, a table, a flags list, a changelog — are exactly where two true-in-isolation edits add up to one wrong number or two entries for one change. This stage reconciles the docs on the lane, before the reviewer, so the reviewer reads the docs change together with the resolutions rather than finding the drift afterwards.

On a fresh run task.md still says status: implementing from stage 5, and it stays so through this stage: the readiness hook is wanted here as much as in the loop. On a re-run, set it back to status: implementing before anything else — a resumed lane says blocked, reviewed or shipped, and under any of those the hook is off.

Collect what the PRs touched, or should have

git diff --stat origin/<BASE>..HEAD -- '*.md' docs/ README.md CHANGELOG.md

origin/<BASE>, which stage 2 fetched — a stale local <BASE> would list doc changes made on the base as if a PR had made them. Then each included PR's ## What this change is for, re-read here, because a resumed run is usually a different session and nothing from stage 2 survives in it:

gh pr view <n> --json body

A CONTRACT:none PR contributes its title and its diff, and the report says it had no stated intent.

Check the combined tree against the docs

The surfaces, where the repo has them — a surface the repo does not keep is nothing to check, never something to create:

  • docs/SKILLS.md: the skill-count line, the skills table, the shared-flags list. A count is the sum of what every included PR added, not either PR's number — the same arithmetic rule as a conflict in the loop, applied to a file that may have merged cleanly.
  • README.md: every section that names a skill or a flag.
  • CHANGELOG.md: one entry per included PR under the repo's unreleased heading, and no duplicate or contradictory entries now that the merges have met.

Update, in one commit of its own

If nothing is off, make no commit and carry no docs change needed forward to the report and the PR body. Otherwise, exactly one commit, separate from every merge and fix commit, so a reader can tell what the merges did from what the docs needed. First make sure the hook's own log cannot ride along — the readiness hook has been writing .claude/artifacts/gate-hook.log since task.md was written in stage 5, and the exclude otherwise lands only at Publish:

bash "$GANTRY/lib/ensure_excluded.sh" .claude/artifacts/

Then stage the doc paths explicitly — each file this stage edited, by name, never git add -A, and never a path the repo does not have, which git add refuses with nothing staged:

git add -- <each doc path this stage edited>
git commit -m "integrate: docs — <what was reconciled>" -m "<one line per surface, and the PR it is for>"

integration_state.sh reads back only integrate: merge <token> subjects, so this one is inert to a re-run.

The gate, like after any other commit

bash "$GANTRY/lib/run_gates.sh" --strict

Red → a separate fix commit, staged the same way, then the gate again, at most twice:

git add -- <each doc path the fix touched>
git commit -m "integrate: fix docs — <why>"

Still red → set status: blocked and stop: the only thing that changed is the docs commit, and the tree must not reach the reviewer or the PR red. There is no pre-merge ref and no reset here — the docs commit is the lane's own, not a PR's. Exit 2 → stop, and it does not count as an attempt.

On a re-run

A resumed run arrives here from NEXT:nothing — including one that last stopped blocked on a red docs gate, which nothing in git marks. Set status: implementing, then run the gate first, before deciding anything: the lane's last gate result is not in this session. Red → the fix loop above with a fresh budget of two, and the report says so. Then collect and check as on a fresh run. An earlier integrate: docs commit is never amended:

git log --first-parent --format=%h%x20%s origin/<BASE>..HEAD

A second one is made only if something is still off, and the report lists each. A docs commit made on a re-run goes on through review, the checkpoint and the push like any other — a lane that already has a PR takes only the push in Publish, and the commit must not stay local with the report naming its sha.

The rules this stage keeps

  • Every command is flat, as everywhere in this skill — tests/cases/integrate_flat_commands.sh scans this stage too.
  • Never touch a source PR's branch. A docs gap that belongs to one PR is fixed on the lane, and that PR's author learns of it from the comment in Publish, not from an edit to their branch.
  • Never merge the integration PR. That is still yours.

Stage 8 — Review the resolutions, not just the diff

Set status: implemented first, because the reviewer's own stop would otherwise meet an armed readiness hook.

Dispatch one reviewer (Agent): the repo's .claude/agents/reviewer.md if it defines one, else gantry-reviewer. Do not write a new agent. Give it paths and commands, not contents:

git log --first-parent --format=%h%x20%s origin/<BASE>..HEAD
git show --remerge-diff <merge-sha>

--remerge-diff shows exactly what the resolution changed against a mechanical merge, which is the part no ordinary diff review ever sees. Also give it each integrate: fix commit and the integrate: docs commit from stage 7 — the docs reconciliation is part of the combined change it is reviewing — plus the source PR numbers and their contracts, and ask specifically for what only appears when PRs meet:

  • two PRs adding the same helper under different names;
  • a count, a table or a list updated twice;
  • version bumps that disagree;
  • something one PR deferred that another already fixed;
  • a resolution that kept both sides' text but not both sides' behaviour.

The lines the integration wrote, through the review lenses

Each source PR's guarded files were read by its own review. The lines this run wrote — conflict resolutions, integrate: fix and integrate: docs commits — were read by nobody yet, and a resolution inside a guarded path is exactly where two safe changes become an unsafe one. So the target repo's review lenses (.claude/review-lenses/*.md, read from the base — see skills/review/SKILL.md step 2b) run on exactly those commits. Take every sha the git log --first-parent above printed — the merge commits and the lane's own commits — and pass them all:

bash "$GANTRY/lib/risk_floor.sh" --commits origin/<BASE> <sha> <sha> <sha>

For a merge commit the script counts only the files where the recorded resolution differs from a mechanical merge, so a merge that went in cleanly contributes nothing and a PR's own guarded files are not counted twice. It prints one block per lens that fired (LENS:, FLOOR:, FILE: lines, END), or nothing — in which case the PR body's ## Lines written by the integration says None.. Exit 2 is not nothing: a lens is malformed or the script could not run. Stop at the checkpoint and say so (--unattended: rule lens-error, no checkpoint — status: blocked, no push); a None. published over lines nobody checked is the false all-clear this section exists to prevent.

For each lens that fired, dispatch one more reviewer (Agent) with a fresh context, the same role as above, with the lens body as its brief:

bash "$GANTRY/lib/risk_floor.sh" --body <name> origin/<BASE>

Give it the lens body, the worktree, the shas whose files matched and the FILE: lines, and ask for findings in exactly those commits' changes — git show --remerge-diff <sha> for a merge, git show <sha> otherwise — plus one "what to look at" note per matched file. Its notes go into the PR body verbatim. A finding that is an interaction defect gets a fix commit and a gate run like any other (and the new fix commit is itself one of the integration's own lines: run the script again over it).

Verify every finding before acting on it. An interaction defect gets a fix commit and a gate run. A finding about a single PR's own content is not yours to fix — invoke gantry:handover and let the source PR's author have it. Then set status: reviewed.

Stage 9 — Checkpoint: the pull request

First re-read reality, because a source PR may have been pushed while the loop ran:

bash "$GANTRY/skills/integrate/scripts/list_candidates.sh" --base <BASE>
bash "$GANTRY/skills/integrate/scripts/integration_state.sh" --base <BASE> 21=refs/integrate/<lane-branch>/pr/21

Anything now stale is shown with the offer to merge the new commits first (--unattended: rule pr, one re-merge, no offer).

AskUserQuestion (under --unattended, rule pr), with the included table (number, title, merge commit, conflicts y/n, gate result, risk level), the overall risk level, every lens that fired on the integration's own lines, the skipped list with reasons, every resolution and its reasoning, the docs commit (or that none was needed), and what the review found: "Push the lane, open the integration PR against <BASE>, and comment on the N included PRs?"

Stage 10 — Publish

Set status: shipped first — the push is next, and a status written after it would miss it.

bash "$GANTRY/lib/ensure_excluded.sh" /task.md /plan.md /handover.md /review.md /qa.md .claude/artifacts/

Compose the body per references/pr-body.md into .claude/artifacts/integration-pr-body.md, then let the checker decide whether it reads as prose:

bash "$GANTRY/scripts/check_pr_body.sh" .claude/artifacts/integration-pr-body.md
git push -u origin HEAD
gh pr create --base <BASE> --head integration/<date> --title "<title>" --body-file .claude/artifacts/integration-pr-body.md

Under --unattended the command is this one instead — the same body file, always a draft:

gh pr create --draft --base <BASE> --head integration/<date> --title "<title>" --body-file .claude/artifacts/integration-pr-body.md

The body file stays inside the checkout and is passed by a relative path, run from the worktree root with no cd in the same command: a body file from outside the repository is an upload by path, which a privileged-command gate asks a human about. Once the PR is open — or, on a lane that already has one, once the push is done — remove it, so a later run never reads a stale body as its own. If gh pr create failed, leave it: it is excluded from git, and the next run composes it afresh. At the same point, in every mode, delete the lane's stop record too: a published lane is no longer stuck, and a record left behind would be read back by the next lane stop as its cause.

rm -f .claude/artifacts/integration-pr-body.md integrate-stop.txt
gh pr comment 21 --body "Included in the integration PR <url>, merged as <sha>. Nothing on this branch was changed."

Under --unattended skip these comments entirely. One comment per newly included PR — a re-run does not comment again on a PR it commented on before. If the lane already has a PR, the push is the whole of this stage, and then:

bash "$GANTRY/skills/ship/scripts/detect_state.sh" --base <BASE>
gh pr checks

Stage 11 — Report

  • The base, the lane branch, and the worktree path.
  • Included: each PR, its merge commit, whether it conflicted, and its gate exit code.
  • Skipped: each PR and the reason, in the words the script or the loop used.
  • Every conflict resolution and what it was decided from.
  • Docs: the integrate: docs commit, sha and subject, and what it reconciled — or no docs change needed.
  • Risk: the overall level (the maximum over the included PRs), each PR's level, the PRs skipped for no-risk-section or risk-level:<word>, and which lenses fired on the lines the integration wrote — or that none did.
  • The gate: --strict or overridden, the baseline result, the exit code after each merge, and how many fix attempts were used.
  • HOOK:conditions-met or conditions-unmet from lib/detect_stage.sh — and what that does not settle: the detector cannot see whether the hook is registered.
  • Which reviewer ran, named plainly, and what it found.
  • The handover.md path, if anything was handed back.
  • The PR URL, and two things about it that are not obvious: merge it with a merge commit — a squash or rebase rewrites the commits, so no source PR's head reaches the base and none of them will be marked merged — and a stacked child PR may stay open even then, because its base branch is its parent's, which the integration merge never updates.

Under --unattended, the first line is UNATTENDED: published draft <url> or UNATTENDED: stopped — <rule> — <reason> (see Unattended mode), and the report also says that the PR is a draft, that no comments were posted on the source PRs, and every skip made by a rule rather than by a person (unresolved-conflict (unattended)).

Be honest about anything skipped, unverified, or self-reviewed.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.