/bett3r-ai-workflow:merge-multifrom bett3r-ai-workflow
Land a finished fleet — merge each reviewed unit PR into `int/<run-id>` (conflicts resolved once), run the scoped gate there, and open the single integration PR to the default branch.
Ships in bett3r-ai-workflow. Installing the plugin adds it to Claude Code.
/start-multi ends with N reviewable PRs open against the run's integration branch int/<run-id> and nothing merged. You review them at your own pace; this command is the landing, run afterwards in a fresh session: everything it needs is on disk (run.yaml) or on GitHub (gh pr view). The integration branch is why reviews stay per unit, conflicts are resolved once as merge commits, and the gate runs once on the assembled tree, the only place cross-unit breakage exists.
Optional run-id. Default: the most recent run in .work/multi/ for this repo.
| Flag | Effect |
|---|---|
--dry-run | Print the inventory (step 1), run step 1b's read-only ruling and report the would-refuse set, then stop. Merges nothing. |
--only <ids> | Land a subset; the rest stay open against integration. |
--land | Also merge the integration PR into the default branch (step 6). Off by default: that is the last irreversible act. |
1 — Inventory. Report; do not act.
Read .work/multi/<run-id>/run.yaml for the unit set, the wave order and the integration branch. git fetch origin. Then read each unit's real state from GitHub, since run.yaml was written before review:
gh pr view <n> --json number,title,state,baseRefName,headRefName,headRefOid,mergeable,mergeStateStatus,reviewDecision
Print one row per unit and act on each finding as its bullet says:
int/<run-id>. Retarget (gh pr edit <n> --base int/<run-id>) or exclude the unit; a wrong-target merge reports MERGED and delivers nothing.MERGED. Skip it; re-running after a partial land is the expected path.reviewDecision is CHANGES_REQUESTED. Stop; that is the human's outstanding objection.passed in run.yaml, or has no PR. Exclude it.--dry-run continues into the read-only step 1b, reports the would-refuse set (each refused unit with its verdict line and its stacked dependents) and stops before step 2. Done when every unit has a row and a disposition: merge, skip, retarget or exclude, or stop.
1b — Rule each unit's concerns, before merging it.
/verify-build posted a flow/concerns commit status on each unit's head; that status is advisory (a private free-plan repo cannot require it), and a human can merge over a red one. This command is the hard block: before merging a unit, rule it yourself from files taken off its own head commit, not the working tree, a sibling's checkout, or the status read back.
The unit's work-docs folder comes from its lane's own record: work_item: in .work/multi/<run-id>/units/<unit-id>.state.yaml, the exact value the lane copied from its /start's .work/mode.yaml, resolved with work-docs-path --item <work_item>. The state file is found by the unit's units[].id, which is not itself the work item. A missing state file, a missing or empty work_item:, or a work-docs-path verdict other than outcome=ok refuses the unit, and the block then runs no concerns-check and prints no verdict line. Never fall back to run.yaml's units[].id as the work item. <sha> is the headRefOid step 1 read.
STATE=".work/multi/<run-id>/units/<unit-id>.state.yaml"
WORK_ITEM=$(sed -n 's/^work_item:[[:space:]]*//p' "$STATE" 2>/dev/null | head -n 1 \
| sed -e 's/[[:space:]]#.*$//' -e 's/[[:space:]]*$//' -e "s/^[\"']\(.*\)[\"']$/\1/")
DOCS=
[ -n "$WORK_ITEM" ] && DOCS=$(work-docs-path --item "$WORK_ITEM" | tail -n 1 \
| sed -n 's/^WORK-DOCS-PATH:v1 outcome=ok .* path=\([^ ]*\) .*$/\1/p')
if [ -z "$DOCS" ]; then
echo "unit <unit-id>: refuse — no work_item in $STATE, or work-docs-path did not resolve it"
else
TMP=$(mktemp -d)
git show "<sha>:$DOCS/concerns.md" > "$TMP/concerns.md" 2>/dev/null || rm -f "$TMP/concerns.md"
git show "<sha>:$DOCS/decisions.md" > "$TMP/decisions.md" 2>/dev/null || rm -f "$TMP/decisions.md"
concerns-check --decisions "$TMP/decisions.md" "$TMP/concerns.md"
fi
Read the last line, CONCERNS-CHECK:v1 outcome=pass|fail|error …, not the exit code (ADR-004). The mapping, each outcome once:
outcome=pass → merge the unit.outcome=fail → refuse the unit.outcome=error → refuse the unit. A malformed file, a fabricated or foreign waiver citation, or a corrupt decisions.md is not-success exactly like fail.A missing concerns.md at the unit head is a refusal, not "no concerns". /verify-build always commits the file, empty when the unit raised none, so its absence at that sha means that unit's /verify-build did not complete, and the block already refuses it: concerns-check returns outcome=error reason=file-not-found. A missing decisions.md is not by itself a refusal, since concerns-check reads it only when a concern is waived.
Report a refused unit by id with its verdict line; the same line goes into the integration PR body under step 4's declared − landed heading. A refusal blocks its dependents: a stacked child's branch is cut from its parent's tip, so merging the child without the parent in int/<run-id> would deliver the parent's unruled work by the back door; refuse every unit stacked (directly or transitively) on a refused one, and say so. Units with no dependency on the refused one merge.
Done when every unit has a ruling: merge, or refuse with its verdict line and its dependents named.
2 — Merge into integration, in dependency order.
Follow run.yaml's waves — a stacked child after its parent. Merge each unit PR into int/<run-id>. Merge exactly the head sha Step 1b ruled (gh pr merge <n> --match-head-commit <sha>, or git merge <sha> in the integration worktree), never whatever the branch points at now: if the head has moved since that ruling, re-run Step 1b at the new head sha and refuse on anything but outcome=pass. A stacked child's PR targets its parent's branch: gh pr edit <n> --base int/<run-id> before merging it, and delete no unit branch while a PR still targets it, since deleting a base closes the child unmerged.
Regenerate after every unit merge, clean or resolved, before the next: in the integration worktree, at the merged tip (git pull first after a gh pr merge), run worktree-pool regenerate <ruled sha> and read its WORKTREE-POOL:v1 cmd=regenerate line. A host that merges generated files by keeping one side (a merge=<driver> in .gitattributes) loses a unit's generated change without any conflict; such a host declares designTooling.regenerate (and optionally designTooling.regenerateCheck) in .blueprint.config.json, and the call runs them and commits the regen. outcome=regenerated with regen=committed|clean|none continues, and step 3's gate covers a regen=committed commit; outcome=refused reason=merge-driver-without-regenerate names paths= a custom driver merged while nothing is declared, and blocks step 5 until the host declares the key or you regenerate those paths and record it as a resolution; outcome=failed step=regenerate|regenerate-check|regenerate-commit stops merging, reported with its output.
Resolve conflicts in the integration worktree as merge commits, never by rewriting a unit branch: the unit branch is the artifact the human reviewed, and a rebase invalidates that review silently.
git checkout --theirs, then re-run the generator.*.orig residue is checked before committing; a .ts.orig passes every gate uncompiled.base + Σ (each unit's delta against its own base), the addends /start-multi's step-8 report carries, and verify by running the suite, since every branch's value is wrong on the merged tree.owesSiblings entry in units/<id>.state.yaml and every PR-body "for the merge" section, check the merged file even where git did not conflict, apply the obligation on integration with a test red without it, and record it as a resolution; an unresolved one blocks step 5.Count the conflicts as you merge: for each unit merge, the files git reported conflicted. Append one entry to run.yaml's mergeConflicts for this invocation, { units, conflictedFiles: <n>, resolutions: <n>, wavePrefactor: <run.yaml's flag> }, and print it in the report and the integration PR's Conflict resolutions: the before-and-after measure for --wave-prefactor, recorded on every run so runs without the flag are the baseline. Record every resolution as you make it (which units, which file, what was kept and dropped, why), in the integration PR body (step 5) and as an entry in the run-level decisions.md: the reviewer approved unit diffs; what ships is those diffs plus your resolutions.
The run-level decisions.md is <root>/<run-id>/decisions.md, resolved with work-docs-path --item <run-id> (run.yaml's runId:), never a hardcoded root. It holds this command's own conflict resolutions and, under followUps: in-lane, step 2c's forks, nothing else; /design-multi Phase B's policies are not restated there, since each unit's committed design.md carries them. If work-docs-path --item <run-id> refuses (a hand-made run id, or one built from a unit id work-docs-path cannot carry, such as a Jira key with an underscore), write no run-level decisions.md entry: put its WORK-DOCS-PATH:v1 verdict line in the integration PR body under Conflict resolutions instead, and continue merging. /merge-multi is the file's single writer: each entry is a ## D<n> — <title> with step: merge-multi · slice: — · decidedBy: orchestrator, its id one more than the highest already in the file, in the D-entry grammar /build's record companion (reference/build-record.md) states.
Done when every unit ruled merge is in int/<run-id> at its ruled sha with its worktree-pool regenerate verdict read, every conflict and obligation has a recorded resolution, and no *.orig remains.
2b — Census the agreed scenarios on the integrated tree.
Every unit's tests meet only here, so a scenario a sibling owns, which a lane's /verify-build only warned on, is ruled here. With every unit ruled merge merged, run scaffold-commit census --item <run-id> --repo <integration worktree> on int/<run-id>, over the fleet's one scaffold report (/start-multi step 0's), and read the last line, SCAFFOLD-COMMIT:v1 verb=census outcome=…, not the exit code (ADR-004):
outcome=ok → continue.outcome=blocked blocks step 5: each not-implemented: <id> presence=<absent|pending> is an agreed scenario no merged unit implemented, a pending .todo( or .skip( test counting as none, and the integration PR body lists each line verbatim.outcome=error, or no verdict line → blocks step 5, as blocked does.outcome=skipped reason=no-scaffold-report → step 0 made no scaffold commit: the integration PR body says so, and there is nothing to census.Each hold: <id> under review (<why>) is an ESAS-296 hold: the integration PR body lists it on its own line, never as missing a test, and it blocks nothing. The escape is a human strike or writing the test: the owner strikes the scenario in their own words, quoted verbatim beside its id under the integration PR body's Scenario census (an agent's judgement strikes nothing), or the test is written (on the owning unit's branch and re-merged, as step 3 fixes a red gate) and the census re-run.
Done when the census printed outcome=ok, every not-implemented: id is struck by the owner, or step 0 made no scaffold commit and the body says so.
2c — Sweep the deferred follow-ups: followUps: in-lane runs only.
Without followUps: in-lane in run.yaml's flags, this step does not run. Otherwise read <runDir>/followups/<unit>.md for every unit merged in this invocation and dispatch one agent, the executor, in an integration worktree on int/<run-id>, to work every item marked needsOwner: no, one at a time, under the lane's rules (/verify-build Step 3a): red test first, test-runner and scope-check, one commit per item, fix(<scope>): follow-up <unit>/F<n>. Each fix made without the owner is a fork: an in-lane-fork D-entry in the run-level decisions.md (question, option chosen, options rejected and why, the commit), with decidedBy: orchestrator. An item marked needsOwner: yes, or one the agent finds needs an owner decision after all, becomes a ticket: listed under the integration PR body's Follow-ups needing an owner decision, one per item with its text verbatim, for the owner to file or file through the tracker when one is wired. Mark each item in the file status: fixed <sha> or status: owner. Step 3's gate runs after this step, so it covers the sweep's commits.
Done when every deferred item of a merged unit is fixed with its D-entry or listed for the owner.
3 — Run the gate, once, on integration.
Bump each touched plugin's plugin.json once on int/<run-id> before the gate; the version-bump step must read PASS there, and a SKIP reason=deferred-to-merge-multi is refused as red, since integration carries no .work/lane.yaml and a SKIP means a stale lane brief leaked in; remove it and re-run.
Run the gate as the full-gate skill says, in the repo's scoped mode (--fast where the host has no scoped mode, and say so), on int/<run-id>, reading the verdict from the GATE-STEP: lines and baseline-diffing against the default branch. The whole-repo --full and --all runs are never a flow step's; that run is CI's, or the user's on request. The integration diff is the union of every unit's diff, so the scoped verdict certifies the fleet's combined diff and its importers; report the ref it ran at and therefore which units it covers, naming a unit excluded with --only as not covered.
A red gate is fixed on integration, not deferred. If a failure traces cleanly to one unit and the fix is more than a line, push the fix to that unit's branch and re-merge, so the unit PR stays an honest record of its own work. A fix pushed to a unit branch changes its head: re-run Step 1b at the new head sha before re-merging, and refuse on anything but outcome=pass. Otherwise fix on integration and name the unit in the commit message. The integration PR opens over GATE: PASS only; a red integration branch has no owner once the fleet is torn down.
Done when the gate printed GATE: PASS on the current tip of int/<run-id> and the version-bump step read PASS.
3b — Take the owed measurements, on an idle machine.
A lane takes no timing measurement (/build Boundaries); each one it owed is an entry titled measurement owed: <exact command> in that unit's decisions.md. Grep every merged unit's record for them. With the gate's last run finished and no fleet lane, gate or build of yours in flight, run each owed command serially on int/<run-id>, recording uptime beside each result: a 1-minute load above half the core count makes the number not a measurement, so wait and re-run rather than record it. Commit the results where the slice said they go, naming the unit, and list each one under the integration PR's ### Gate. A measurement that regresses past the bound its design set is a finding in the PR, and blocks nothing the design did not say it blocks.
Done when every owed measurement has a committed result taken under the load bound, or is listed in the PR as not taken, with why.
4 — Collect the closing keywords.
A PR merged into int/<run-id> does not close its issues: GitHub fires closing keywords only on merges into the default branch, so every Closes #N in a unit PR body is inert. Collect the union of issues referenced across every unit PR into the integration PR body, one closes keyword per issue: Closes #56, closes #62, closes #63. A bare list (Closes #56, #62) closes the first and turns the rest into mentions; /verify-build step 6 states the binding rule.
Reconcile the manifest: run.yaml declares the run's units and you have just enumerated what merged, so compute declared − landed. If it is non-empty, the integration PR body states it under its own heading and the report leads with it: a unit step 1b refused is listed with its CONCERNS-CHECK:v1 verdict line, and a deliberately dropped unit is recorded as dropped with a reason. The integration branch name is not evidence of scope; it was fixed at cut time.
The epic's goal oracle is reported here, red or green; landing every unit with it still red is a reportable outcome, not a silent success.
Done when the body carries one closes per referenced issue, the declared − landed set (even when empty), and the goal oracle's verdict.
5 — Open the integration PR.
gh pr create --base <default> --head int/<run-id> — ready for review, not a draft. Then verify its base, since gh pr create succeeds silently against the wrong ref. The body is an index, not a concatenation: what landed, what you resolved and what the gate said; every unit PR keeps its full body at its own URL.
## Fleet <run-id> — <N> units
| Unit | PR | ADR |
|---|---|---|
| TV1-1001 — <title> | #101 | ADR-0142 |
| TV1-1002 — <title> | #102 | — |
### Conflict resolutions
conflicts: <n> files over <m> unit merges (wave prefactor: on|off)
- TV1-1004 × TV1-1007 in `src/foo.ts` — kept X, dropped Y, because <reason>.
- (or "none")
### Scenario census
<step 2b's census verdict line verbatim, then each `not-implemented:` and `hold:` line on its own line,
or "no scaffold report">
### Decided in-lane, review after the fact
<followUps: in-lane runs only; omit otherwise. Per unit, the forks its PR lists under the same heading, then step 2c's,
each `D<n> — <question> — chose <option> (<commit>)`, so the owner can reverse any of them>
### Follow-ups needing an owner decision
<followUps: in-lane runs only: step 2c's owner items, one bullet each, verbatim; or "none">
### Gate
<the full-gate report block, verbatim — step names, counts, baseline diff, and
anything reported SKIP / INCONCLUSIVE, not selected by the scoping, or
excluded from the repo's widest run, by name>
Closes #56, closes #62, closes #63
Done when the PR exists with baseRefName equal to the default branch.
6 — Land (--land only).
Merge the integration PR into the default branch. Then two assertions, because both failures report success:
git fetch origin
git merge-base --is-ancestor origin/int/<run-id> origin/<default> # the merge actually delivered
for n in <every referenced issue>; do printf '%s %s\n' "$n" "$(gh issue view "$n" --json state -q .state)"; done
Check the line count before the states, since a gh failure prints a blank state and greps clean. Close the stragglers (gh issue close <n> -c "landed in #<pr>"). Bulk form when the set is long:
comm -13 <(gh issue list --state closed --limit 500 --json number -q '.[].number' | sort) \
<(printf '%s\n' <referenced> | sort)
Whatever that prints is still open. Then delete int/<run-id> if the repo deletes merged branches, and report the default-branch sha the fleet landed at. Done when the ancestor check succeeded and every referenced issue printed CLOSED.
Without --land, stop at step 5 and report the integration PR URL and its mergeable state, saying plainly that nothing has landed.
6b — Push the KPI dashboards: attended only.
A design's agreed KPIs are committed as blueprint-kpi-<map>.json dashboards (ESAS-306, ADR-116 in blueprint), and that repo's APM shows them only after the repo's own declared push runs. For each repo the fleet touched, read observability from its .blueprint.config.json at the default-branch sha step 6 reported:
push declared, a human present (no .work/lane.yaml, not a headless run): run the command exactly as written, from that repo's root on the landed default branch, and report its output. The repo scopes it (teselly: --dashboards-only --glob 'blueprint-kpi-*.json'), so it touches no alert group.push declared, unattended: never run it. Print push owed: <command>, the command verbatim, and carry the line into the step 7 report for a human to run.push: print push: none declared, followed by the declaration's noPush reason when it gives one.Without --land nothing has landed, so nothing is pushed in either mode: print push owed: <command> for each declared push. Never push from int/<run-id>: the dashboards would go live before the code that feeds them is on the default branch, and a push credential belongs to an attended session only. Done when each repo printed its push output, its push owed: line, or push: none declared.
7 — Report.
Units merged (and any skipped, with why) · declared − landed, always, even when empty · the epic goal oracle's verdict · conflict resolutions, counted, with step 2's mergeConflicts entry · under followUps: in-lane, the in-lane forks per unit and step 2c's, and the owner items · the gate verdict · the integration PR URL · issues closed vs. still open · step 6b's push output or each push owed: line, verbatim. Done when run.yaml carries landedAt and integrationPr, so a re-run is a no-op.
--land.What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub bett3r-dev/bett3r-ai-workflow --plugin bett3r-ai-workflow15 commands in this plugin
/blueprint/blueprint — drive a hosted session from this laptopDrive a hosted Blueprint session from this laptop. connect (the session for this branch, plus the local listener), disconnect (stop the listener, forget the session), status./blueprint-send/blueprint-send — this conversation, into Blueprint's memorySend this conversation to Blueprint's memory now, the secret check first. A captured conversation becomes log hits of the repository, labelled "said in conversation, not decided"./build/build — drive the slicesDrive each slice in .work/slices.yaml to green through the dual gate (executor → test-runner → scope-check ∥ verifier) and commit it: the implementation loop of the pipeline./capture-learnings/capture-learningsCapture what this session taught and route each learning to the repo that owns the artifact, filed with its filters and expiry. Most sessions file nothing./commit/commitStage and commit the working tree as well-formed, logically grouped commits in the repo's conventions. For ad-hoc changes outside the slice loop./cpu-pool/cpu-pool — lift the pool before a fleetLift the CPU pool before a fleet (one machine-wide compiler token pipe every lane's cargo joins), and say how to launch the orchestrator inside it. Also status, refill, down.