work-wave
Skill1 starsChanged 2 months agoMITView on GitHub
Run N GitHub issues at once, one work-issue run per issue in its own worktree, with the footprints proved disjoint, the cross-lane coupling question answered and recorded, the merge order fixed, and the branches merged together and verified before any lane opens a pull request. Use ONLY when the user explicitly invokes work-wave. It never plans an issue, never merges one, and never advances a single issue: for one issue, use work-issue.
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- divvy-up/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- adversarial-reviewSkill
- databricks-apiSkill
- divvy-upSkill
- eli5Skill
- file-issueSkill
- handoffSkill
- inbox-to-memorySkill
- jd-auditSkill
- jd-fileSkill
- jira-refineSkill
- memory-consolidateSkill
- memory-indexSkill
- mutation-testingSkill
- readme-coauthorshipSkill
- technical-writingSkill
- work-issueSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 45
Run the resume probe (see Resume) before anything is written under WAVE_DIR.
- Very specific: line 128
Every git write on a lane's branch belongs to that lane's work-issue, and every git write on MERGE_TREE belongs to you.
≈ “Common” is an estimate: at least 1 in 5 of the 383,637 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
work-wave
work-issue advances one issue and refuses a concurrent sibling at its gate, which is right for what it owns. Three issues, three worktrees, three agents, and one orchestrator holding the parts true across all of them is a shape it does not cover, and run by hand that orchestration loses the same four things every time: a coupling between two lanes that no diff shows, the merge test run last instead of first, a fact one lane learned and another paid to relearn, and a file handed back at a path the orchestrator could not read.
Width across lanes is safe under two conditions. No two lanes write the same path, and that gets proved by a script before anything is dispatched, the way divvy-up proves a wave. And no lane's change alters what another lane builds against, which no script can prove: two diffs in core/ and app/storage/ are disjoint and can still be about one thing. Disjoint paths prove two lanes cannot lose each other's writes. They do not prove the two lanes are independent, and this skill asks the second question on its own, records the answer per pair, and turns it into a merge order before a lane exists.
Cost is N work-issue runs plus a merge test, and the runs are the cost of the issues, not of this skill. What this skill spends beyond that is one worktree for the merge test and the orchestrator's own reading of N plans, and both are spent so that a coupling costs a merge-order row here instead of a rebase conflict, a reverted pull request, and a re-run later. Every judgment—footprints, coupling, order, what a lane's report means—stays on the session model; the lanes are dispatched at opus, because a lane is itself an orchestrator running gates.
Four skills cover four shapes of the same job. Reach for agent-guild when the work needs a written constitution and an independent checker per task. Reach for divvy-up when a plan is already approved and its tasks can be carved into disjoint file ownership in one tree. Reach for work-issue when one issue has one approved plan and should go all the way to an answered pull request. Reach for work-wave when two or more issues each have one, and they should go at the same time.
This skill is user-invoked (disable-model-invocation: true) because a misfire during ordinary planning spends a whole fan-out, while a missed trigger costs the user one word.
Where a step names a shell command, treat it as the intent and use your native shell or file tools.
Resolve once per invocation:
- ISSUES — every issue number in the arguments: bare integers,
#N, or issue URLs. Fewer than two stops the run with "one issue iswork-issue N". There is no "issues from the conversation" mode, for the reasonwork-issuegives: a number inferred from context runs this entire wave against the wrong tickets. - REPO —
gh repo view --json nameWithOwner --jq .nameWithOwner - DEFAULT —
gh repo view --json defaultBranchRef --jq .defaultBranchRef.name. Never assumed to bemain. - ROOT —
git rev-parse --show-toplevelof the invoking directory - COMMON —
git rev-parse --git-common-dir, made absolute - PROJECT — ROOT's final path segment, lowercased to
a-z0-9- - WAVE_ID — ISSUES sorted ascending and joined by
-:113-114-115. Derived from the inputs so the same set of issues lands on the same directory every time it is typed. - WAVE_DIR —
<COMMON>/work-wave/wave-<WAVE_ID>/. Subpaths:lanes.md,harvest.md,footprint/issue-<N>.md,footprint/check.txt,footprint/check-failed.txt,coupling.md,order.md,facts/issue-<N>.md,facts/wave.md,merge-test/<k>.md,reports/issue-<N>-<phase>.json,gate/issue-<N>.md,baseline.txt,reports/issue-<N>-<phase>-interim-<k>.json,repoll/issue-<N>. A finished wave moves to<COMMON>/work-wave/closed/wave-<WAVE_ID>/. Under the common dir forwork-issue's reasons: one location every lane's worktree can see, invisible togit status, and it outlivesgit worktree remove. It holds outputs, and nothing in it says which step the wave believes it reached. - HANDBACK — WAVE_DIR, spelled absolute. It is the one path every lane is told to write to and to name in its report, and every location a lane reports—its
worktreeand itsrun_dir—is absolute or is refused (arefusedorfailedreport may carry a nullworktree, which reports no location), whilefiles_changedstays repo-relative by the brief's contract: subagent shells reset their working directory between calls, so a worktree-relative path in a report addresses whatever tree the reader happens to be in. - PLAN[N] — per issue, first hit wins: the
--plan N=PATHargument;<ROOT>/docs/plans/*issue-<N>*.mdor<ROOT>/docs/plans/*-<N>-*.md, newest by name; a path linked from the issue under aPlanheading. These arework-issue's routes 1 through 3. Its route 4—the plan held in the conversation—is unreachable from a fresh subagent, so a plan that resolves only there is a missing plan here. Each hit is made absolute, and that absolute path is what the lane's argument line carries, aswork-issue's route 1. - LANE[N] — the lane's derived names, all
work-issue's: BRANCHissue-<N>, WORKTREE<ROOT>/../<PROJECT>-issue-<N>/, RUN_DIR<COMMON>/work-issue/issue-<N>/. - LANE_MODEL —
opus, orfablefrom--lane-model fable. Never lower: a lane runsdivvy-up's gate,code-review, and a red-team on whatever model it was dispatched at, and that model is the judgmentdivvy-upkeeps on the session model for a reason. - MERGE_TREE —
<ROOT>/../<PROJECT>-wave-<WAVE_ID>-merge/. Exists only while a merge test runs. - VERIFY_CMD, INSTALL_CMD — harvested off disk the way
work-issueharvests: manifest scripts first (package.json,Makefile,pyproject.toml,Cargo.toml); then runnable scripts undertests/orscripts/; then what.github/workflows/runs; thenabsent. - CONTRACT_PATHS — the union, across every lane's plan, of paths
divvy-upStep 1 would make wave-0 tasks: types, interfaces, schemas, migrations. A lane whose build report names one of these, infiles_changedor incontract_changed, triggers a merge test at Step 5. - FLAGS —
--review-loop[=<comment>]goes on every lane'swork-issueinvocation this run dispatches, as--review-loopor--review-loop="<comment>"in the form the user gave it, and is the lane brief's{{REVIEW_LOOP}}(empty where the flag is absent). This skill writes nothing to WAVE_DIR for it: a lane's RUN_DIR keeps the mode once any dispatch carried it, so a build-phase opt-in still holds at publish.--auto-budget <ratio>,--defer-after <k>, and--repair-class <class>set the ruling policy every lane'swork-issueinvocation carries, so a lane rules its own budget, triage, and red-team stops where nobody is watching to answer them. Before the resume probe, runwork-wave/scripts/lane-policy.py flagswith whichever of the three the user gave. It fills each one left out with the lane default,--auto-budget 4.0,--defer-after 3, or--repair-class unowned-write, and prints the lane brief's{{POLICY}}:--auto-budget 4.0 --defer-after 3 --repair-class unowned-writewhen none was given. Exit 3 refuses the wave with its stderr lines quoted. The policy is written nowhere in WAVE_DIR, so every dispatch carries the one this invocation resolved.--dry-runruns Steps 0 through 3, renders the confirmation, and dispatches nothing, creates no worktree, and pushes nothing.
gh auth status is a Step 0 preflight. Unauthenticated stops the run: the issues cannot be read, and route 3 of PLAN cannot be followed.
Step 0 — Gate
- Run the resume probe (see Resume) before anything is written under WAVE_DIR. Row 2 matches a fresh wave and a wave interrupted inside this step alike, and both run the rest of this step from item 2; any later row jumps there.
- Resolve PLAN[N] for every issue. Any issue whose three routes all miss refuses the whole wave, naming every such issue at once: "Plan them first:
writing-plans, thenwork-wave <ISSUES> --plan N=PATH." One refusal listing three missing plans beats three runs each finding one, and a wave that starts with two lanes of three is a different wave from the one the user asked for. gh issue view N --json title,url,bodyfor each, and writeWAVE_DIR/lanes.mdwith one row per lane:| Lane | Title | Plan | Worktree | Run dir |, every path absolute.- In-flight
work-issueruns. Any<COMMON>/work-issue/issue-N/for an N in ISSUES that is not underclosed/is a lane already started. It stays in the wave: Step 1 proves its footprint on itsRUN_DIR/plan.md, Step 3's collision check exempts its worktree, mid-rebase included, and Step 4's dispatch reaches it throughwork-issue N, whose own resume probe places it. Anyissue-M/for an M not in ISSUES is a sibling this wave does not own, and Step 1 hands it to the script with--runsso its footprint is proved against every lane's. - Harvest VERIFY_CMD and INSTALL_CMD, and derive CONTRACT_PATHS by reading every plan for the contract shapes.
- Last, after items 1 through 5, write
WAVE_DIR/harvest.md: the already-started lanes and the in-flight siblings item 4 found, VERIFY_CMD, INSTALL_CMD, and CONTRACT_PATHS. It is the resume probe's only evidence that this step finished.lanes.mdexists from item 3 on, so a run interrupted during items 4 or 5 leaves a WAVE_DIR with noharvest.md, and resume row 2 sends it back through this step rather than on to Step 1 without its siblings found or its commands harvested.
Done when: every issue in ISSUES has an absolute PLAN[N] on disk, lanes.md names every lane with absolute paths, gh is authenticated, VERIFY_CMD is resolved or absent, and harvest.md, written last, records item 4's runs, VERIFY_CMD, INSTALL_CMD, and CONTRACT_PATHS—or the run stopped at the refusal naming every issue without a plan, or at fewer than two issues.
Step 1 — Footprint
For each lane, run work-wave/scripts/check-footprints.py --extract PLAN[N] and, on exit 0 only, save its stdout to WAVE_DIR/footprint/issue-<N>.md. It reads every Files:, **Files:**, owns:, or Files owned line and the ## Waves table where the plan carries one, and prints one bare repo-relative path per line. A non-zero --extract exit stops Step 1: quote its stderr and name the plan. Fix the plan's ownership lines so they name their paths in backticks, then run --extract again, so every footprint file is --extract output. The --lane reader still refuses decoration rather than stripping it, because the reason it gives has to quote a string that is in the file.
A lane already started (Step 0 item 4) is proved on its RUN_DIR/plan.md, the copy its own work-issue builds from, never on PLAN[N]. Where the copy carries a ## Waves table, pass RUN_DIR/plan.md itself as the lane's --lane issue-N= argument. Where it has none yet, run --extract on the copy, save its output as footprint/issue-<N>.md, and pass that file instead, never the tableless copy: the script reads a plan with no table as a bare path list, so its prose lines become paths and a real overlap passes. The lane's resume builds from the copy, so a source plan edited since then describes work nobody will do.
Then:
work-wave/scripts/check-footprints.py --lane issue-113=WAVE_DIR/footprint/issue-113.md --lane issue-114=WAVE_DIR/footprint/issue-114.md … --runs <COMMON>/work-issueA non-zero exit is a hard stop, not a warning. Two lanes owning one path is two worktrees rewriting one file, and the rebase conflict that produces lands at a lane's Step 5 after the user has walked away. Its pair: lines on a pass are Step 2's worklist: exactly one per pair of lanes, so the coupling record has a row for every pair and cannot skip one.
Save the output to WAVE_DIR/footprint/check.txt on exit 0 only. A non-zero exit's output goes to WAVE_DIR/footprint/check-failed.txt, because resume row 4 reads any check.txt as a passed proof and would carry a failed one on to Step 2.
Every lane's own work-issue will run check-inflight.py again at its Step 0 item 6, and that is kept, not relied on. N lanes dispatched in one message write their ## Waves tables within seconds of each other, and that script skips a sibling whose table is not there yet, so each lane's check can pass against siblings that have not written theirs. This step is the one check that holds every footprint at once, and Step 5 re-runs it over what the lanes actually derived.
So where that script skips, this one fails closed. An in-flight sibling with no parseable ## Waves table, or whose table carries an entry the script rejects as malformed, prints an unchecked: line and exits 1, because its footprint is unknown and an unknown footprint can overlap any lane. A malformed entry voids the whole run's proof, since a backticked `src/a.py` reads as no overlap with a lane's bare src/a.py. A tableless in-flight sibling stops the wave until it writes its table, or until the user moves its run directory to <COMMON>/work-issue/closed/ because the run is dead. A sibling with a malformed entry stops it until the run's plan spells that entry bare, or until the user moves a dead run to closed/ the same way. Name the sibling and both ways forward; which one applies is the user's call.
Done when: check-footprints.py exited 0 over every lane's footprint, each already-started lane's taken from its RUN_DIR/plan.md copy, and every in-flight sibling run, each sibling's table read and compared, and its output, pair: lines included, is saved to WAVE_DIR/footprint/check.txt—or the run stopped at an overlap, or at an unchecked: sibling named with both ways forward, with the output in footprint/check-failed.txt and no check.txt written.
Step 2 — Couple and order
Take each pair: line and ask the question the footprint proof cannot answer: would one lane's change alter what the other builds against? Read both plans against each other for the three shapes divvy-up names—both change behavior some third module reads, one fix may make the other unnecessary, both touch a runtime agreement that is neither a type nor a schema—and for the fourth that only appears across lanes: one lane's plan consumes, by name or by path, something the other lane's plan changes. A schema one lane relaxes and another lane's comparison depends on is that fourth shape, and its two diffs are disjoint.
divvy-up resolves a coupling inside one tree, by placing a task in a later wave or by merging two tasks into one. Neither exists here. Every lane bases on origin/DEFAULT and cannot build on a sibling's branch, and two issues cannot be merged into one task. What a wave can do is order the merges, keep a lane out, or refuse. Write one row per pair into WAVE_DIR/coupling.md:
| Pair | Answer | Evidence | Resolution |Answer is one of independent, directional A→B, mutual, or unclear. Evidence quotes the plan lines that decided it, or says what was read and found nothing. Resolution follows from the answer:
| Answer | Resolution |
| independent | none |
| directional A→B, and B merely observes or tests what A changes | order: B after A. The merge test at Step 6 is what proves B still passes with A's change in front of it. |
| directional A→B, and B's tasks would write against the thing A changes | hold: B until A merges. B built against the old contract merges after A as a tree the merge test then reports red, which spends a lane to learn what both plans already said. B leaves this wave and is named in the final report as the next one. |
| mutual, or either may make the other moot | refuse. Two lanes each carrying half of one change are one issue planned twice; say which two, and stop. Serializing them does not fix it, because each lane's plan is still half. |
| unclear | ask: a question for Step 3, written down here rather than settled by a guess three lanes will build on. |
Then run work-wave/scripts/order.py build --wave-dir WAVE_DIR, which writes WAVE_DIR/order.md, the merge order:
| Order | Lane | After | Why |Topological over every order: row, ties broken by issue number ascending, so two runs on one set of plans produce one order. After names the lanes this one merges behind, or —. Why quotes the coupling row or says no coupling; number order. A held lane appears with Order held and its After naming the lane it waits on. A hold: row holds its lane, and a lane whose order: row puts it after a held lane is held too, since a lane's successors leave with it. An ask row counts as none until Step 3 settles it. Exit 1 is a refuse row or a cycle among order: rows, its lanes named on stderr: stop, naming them. Exit 3 is a missing or unparseable coupling.md, a Resolution naming a lane outside the wave, or a WAVE_DIR not named wave-<N>[-<N>...]: correct the row or the path and run build again. Every lane in WAVE_ID gets exactly one row, placed or held: the resume probe reads an order.md that omits, repeats, or adds a lane as unreadable and stops. The order is also the sequence the merge test merges in, and the sequence the final report hands the human.
Done when: coupling.md has one row per pair: line, each with an answer, evidence, and a resolution from the table; order.md places every lane that stays, names every held lane and what it waits on; and every unclear pair is a written question—or the run stopped at a refuse.
Step 3 — Confirm
Put every ask row to the user before anything else, and settle each one into order, hold, or none on its coupling row. After every ask row is settled, run work-wave/scripts/order.py build --wave-dir WAVE_DIR again, so a settled order: or hold: reaches the merge order Step 6 merges in and the shape line below quotes.
Then the collision check. Run work-wave/scripts/check-worktrees.py --root ROOT --lane issue-N=WORKTREE [--lane ...] [--started issue-N ...] with one --lane for every lane that is not held, its WORKTREE as LANE[N] spells it, and --started issue-N for each of those lanes that Step 0 item 4 found already started. A held lane gets neither flag, since the script exits 3 on a --started with no --lane. A lane is a hit when its WORKTREE exists as a directory or as an entry in git worktree list --porcelain, prunable entries included. The script resolves both sides before comparing, so never compare the paths by hand. Exit 1 prints one collision: issue-N <path> line per hit on stderr. Any hit refuses the wave here, naming every such path at once. Exit 3 is a usage error or a failed git worktree list: stop and report it, since no lane was judged. A tree already sitting at a lane's own <PROJECT>-issue-N path lands that lane on work-issue's isolation ask row, which an unattended lane cannot answer, and the table states no precedence between that row and --isolate's pin. So the check runs whatever --isolate turns out to do. A lane already started (Step 0 item 4) is exempt when the tree at its WORKTREE holds its own issue-N, checked out or mid-rebase: work-issue made that tree, and its resume probe reads it rather than the isolation table. A lane stopped on a Step 5 rebase conflict has a detached HEAD, which is why the script reads the rebase's own branch instead of the porcelain's branch line.
Then one confirmation, in one message:
Wave 113-114-115: 3 lanes on opus, worktrees at `../skills-issue-113/`, `../skills-issue-114/`, `../skills-issue-115/`. Footprints disjoint (7 paths, checked 1 in-flight run). Coupling: 113→115 directional, so 115 merges after 113; 114 independent. Merge order: 113, 114, 115. Held: none. Merge test: baseline now, on any contract change, before any pull request, and before the final report. On yes: each lane runs `work-issue N <plan> --isolate --no-publish`, with `--review-loop[=<comment>]` and the policy ` --auto-budget 4.0 --defer-after 3 --repair-class unowned-write` added, the first only where the wave carries it, unattended through its red-team, then, once the merge test is green, runs again without `--no-publish` to push `issue-N` and open a pull request against `main`. Never `main`. Go?The shape line is the user's correction point, so the merge order, the held lanes, and {{POLICY}} as rendered are in it rather than in a file they would have to open. This confirmation answers each lane's work-issue Step 0 confirmation on the user's behalf, in two halves: the execute-and-commit half now, and the push-and-pull-request half only when Step 7 re-dispatches the lane after a green merge test. The lane brief says so, and work-issue does not ask again. --dry-run renders this message and stops.
Done when: every ask row is settled and order.md rebuilt from it, no unheld lane's WORKTREE path exists outside the already-started exemption, and the user answered yes to the wave as shaped—or the run stopped at a collision naming every existing path, a no, or a dry-run, with nothing dispatched and no worktree made.
Step 4 — Baseline and dispatch
Run the merge test once with no branches, per references/merge-test.md, as one background call to scripts/merge-test.py --baseline. It does the following: git worktree add --detach MERGE_TREE origin/DEFAULT, INSTALL_CMD, VERIFY_CMD with its exit status and tail saved to WAVE_DIR/baseline.txt with exit: <status>, the base: line, install: <INSTALL_CMD>, and verify: <VERIFY_CMD> ahead of its tail, and the run recorded as WAVE_DIR/merge-test/0.md, then git worktree remove --force MERGE_TREE. Before any lane spends anything, this proves the mechanism—the install, the suite, the removal—and records what green looks like on DEFAULT, so a red merge later can be pinned on a lane rather than on the tree the wave inherited.
Then read references/lane-brief.md and instantiate it once per lane that is not held, with {{PHASE}} build and {{GRANT}} the build half. Dispatch every lane in a SINGLE message so they run concurrently—one dispatch per message is the serialization the wave exists to remove. Name LANE_MODEL on every dispatch. Each lane is a general-purpose subagent told to invoke work-issue by name with <N> <PLAN[N]> --isolate --no-publish plus --review-loop[=<comment>] where the wave carries it, plus --wave-baseline <WAVE_DIR>/baseline.txt, plus {{POLICY}}, and nothing about its worktree, its branch, or its run directory is made here: work-issue's Step 1 makes them, and --isolate is what keeps its isolation table from asking a question an unattended lane cannot answer. --wave-baseline lets a lane whose base SHA and commands match copy the wave's baseline instead of running VERIFY_CMD again; the lane still runs INSTALL_CMD in its own tree. A lane whose plan's - Verify with: command differs from VERIFY_CMD declines the reuse and gates on its own plan's command at Step 1, Step 3, and every repair re-gate, while every merge test runs the full VERIFY_CMD. --no-publish stops the lane once its Step 4's Done-when holds, so the withheld push half holds at the lane even when the grant is misread.
Every git write on a lane's branch belongs to that lane's work-issue, and every git write on MERGE_TREE belongs to you. This skill itself never commits, never pushes, and never touches issue-N or DEFAULT.
Run every message a lane returns through handback.py before reading it. Write the message to a temp file outside WAVE_DIR, then run work-wave/scripts/handback.py --wave-dir WAVE_DIR --lane issue-N --phase build --text FILE. A message that parses as the brief's report contract for this lane and phase is a terminal report, saved to WAVE_DIR/reports/issue-<N>-build.json. Anything else is a hand-back: the lane's turn ended mid-run, and the script saves the message as WAVE_DIR/reports/issue-<N>-build-interim-<k>.json. Route on what it prints:
terminal <path>— the lane reported. Gate it at Step 5.redispatch <k> <path>— the lane handed back. Resume it without asking: continue that lane's own agent with the lane brief's resume line (references/lane-brief.md, "The resume line"), substituting<path>and the phase. That agent still knows what it dispatched. Where it can no longer be continued, as in a wave resumed in a new session, dispatch the phase's brief fresh instead, andwork-issue's own probe resumes the run. Runhandback.pyagain on whatever comes back.- Exit 1 — the third hand-back in this phase with no terminal report. Stop the wave on that lane and quote the stderr line, which names every interim report.
- Exit 3 — a usage error, an unreadable FILE, a terminal report already on disk that the script refused to overwrite, or a report or hand-back it could not save. Stop the wave and quote stderr.
Done when: merge-test/0.md and baseline.txt exist and MERGE_TREE does not; every unheld lane was dispatched in one message at LANE_MODEL with the build grant; and every report is on disk, written by handback.py, or the wave stopped on a lane's third hand-back with its interim reports named.
Step 5 — Gate a lane
As each build report returns:
- Facts. The lane's
factsarray and itsWAVE_DIR/facts/issue-<N>.mdare the same list; where they differ, the file is the one the lane wrote as it went and wins. Then runwork-wave/scripts/lane-policy.py facts --run-dir <run_dir> --wave-dir WAVE_DIR,<run_dir>the report's own, or itsclosed/path where the run has moved there since. It appends each- [wave] policy:line of the lane'sRUN_DIR/policy.logthatfacts/wave.mdlacks, so every ruling the lane made without asking reaches the siblings, and a re-run appends nothing. Every other lane reads the directory, and the next dispatch inlines all of it. - Footprint, again. Re-run
check-footprints.pywith every returned lane'sRUN_DIR/plan.mdin place of its footprint file, the unreturned lanes still on their footprint files, and--runsas before. The lane's## Wavestable is the footprint it actually wrote, and a lane whose derivation drifted onto a sibling's path is found here rather than at the merge. Contract change. First run
gh pr list --head issue-<N> --state all --json url --jq '.[].url'for the lane, its stdout saved to a temp file outside WAVE_DIR. A non-zero exit stops the wave with its stderr quoted and writes no gate record for that report, because a failed command cannot answer "no pull request". The missing record sends the report back through this step on resume, so the check runs again onceghworks.Then run
work-wave/scripts/gate-lane.py classify --report WAVE_DIR/reports/issue-<N>-build.json --pr-urls FILE --recheck-exit N [--contract PATH ...], FILE the savedghoutput, N item 2's exit code, and one--contractper CONTRACT_PATHS entry, a directory spelled with its trailing/. It writes nothing and prints two lines,contract-change: <paths>orcontract-change: none, thenroute: <route>. Afiles_changedentry is a contract change when it equals a--contractpath or sits inside a--contractdirectory, and everycontract_changedentry (the wave-0-owned subset the lane reports) is one. Exit 0 prints a route the wave carries on past (done,stopped,failed,refused), and exit 1 prints a stop (early-publish,recheck-failed,reprompt); both are answers for item 4. Exit 3 is a usage error, an unreadable input, one that isn't a JSON object, astatusoutside the four, or alanethat isn'tissue-N: stop the wave with its stderr quoted and write no gate record.A
contract-change:line naming any path, whatever theroute:line says, triggers a merge test now over every lane branch that has commits, returned or not, as onescripts/merge-test.pycall with a--laneper branch:git -C ROOT rev-parse --verify issue-Mfor each. A schema relaxed in one lane is the change the others should meet while they still build, and they meet it early only when this lane returns ahead of them. The result goes intoWAVE_DIR/facts/wave.md, the one facts file the orchestrator owns, as a line:- [wave] merge test k: <green|red at issue-A × issue-B: paths>. Every lane reads the wholefacts/directory before each dispatch, so the line reaches every still-running lane.A red result is read against
coupling.mdthe way Step 6 reads one: a pair recordedindependentthat is not gets its row corrected. Name the lane whose change broke the other in thatfacts/wave.mdline, so its dependents still building meet the break at their next dispatch. The wave carries on to Step 6, and a red that persists there stops the wave with the pair named. Nothing publishes on a red.- Route. Route the report by item 3's
route:line and the table's row for that route: the first row isearly-publish, the secondrecheck-failed, the lastreprompt, and the rest are named bystatus.gate-lane.py classifytakes the first route that matches, in this order:early-publish,reprompt,recheck-failed, then the report'sstatus. An early publish outranks the rest because a pull request opened before the merge test stops the wave whatever else the report says, so a report with a non-nullprand a relativeworktreeroutesearly-publish, and so does one whosestatusisdonewhilegh pr listprinted a URL.
| Report | Route |
a build report whose pr is non-null, or for which gh pr list --head issue-<N> --state all --json url --jq '.[].url' prints a URL | The lane published before the merge test, against its withheld grant. Either signal stops the wave, with the lane and its pull-request URL named; whether that pull request stays open is the user's call. The lane fills pr itself, so GitHub's answer is the one that catches a lane that opened a pull request and reported pr as null. |
| the footprint re-check (item 2) exited non-zero | Stop the wave with the script's stderr lines quoted, the way Step 1 stops on a non-zero exit. Nothing proceeds to Step 6. |
done | The lane waits at Step 6. |
stopped | The lane's question is held for the user with the wave's next message. The lane is out of the merge set until work-issue N resumes it with the answer, and every lane ordered after it in order.md is moved to held by work-wave/scripts/order.py hold --wave-dir WAVE_DIR --lane issue-N --why TEXT, TEXT saying why issue-N left. Exit 3 means order.md has no row for issue-N or is malformed: stop the wave and name the file, since the merge order is no longer known. |
failed, or refused at its own gate | The lane is out of the merge set; lanes ordered after it are moved to held by order.py hold, as for stopped; every other lane proceeds. No revert, because its writes are on its own branch in its own worktree and clobbered nothing; no rung-up retry, because work-issue has already applied divvy-up's retry inside the lane and LANE_MODEL is already the rung a retry would reach. Its report is quoted in the final report, and work-issue N resumes it once a human has read that. |
A contract field missing (facts excepted) or of the wrong type, worktree or run_dir not absolute, or head not a SHA, where only a refused or failed report may leave worktree and head null | Never reaches this step: handback.py catches it at Step 4 and saves the message as a hand-back, so the resume line asks the lane for its report again. A relative path in a report is the round trip this skill exists to remove. Where classify prints route: reprompt anyway, stop the wave naming the report path and the field, and write no gate record: handback.py refuses to overwrite a saved report, so a re-prompt's answer cannot replace it, and the fix is the user's. |
- Gate record. Last, after items 1 through 4, write
WAVE_DIR/gate/issue-<N>.md. Its first line isroute: <done|stopped|failed|refused|early-publish|recheck-failed>, the route item 4 took, withearly-publishfor the early-publish stop andrecheck-failedfor the failed re-check stop; the resume probe reads a record that opens on anything else as unreadable and stops the wave on it. Write it withwork-wave/scripts/gate-lane.py record --wave-dir WAVE_DIR, item 3'sclassifyflags,--recheck-output FILEwith FILE holding item 2's output, and--merge-test <k|none>,<k>themerge-test/<k>.mditem 3's merge test wrote, ornonewhere nothing triggered one. It writes the route line, thenfootprint re-check: exit <n>and that output, thenmerge test: merge-test/<k>.mdand the record's ownresult:line, ormerge test: none, in one rename, so no record opens on anything but its route. Append any note below the script's lines. Exit 0 means the record is written, a stop route included, sinceclassifyalready returned the stop. Exit 3 writes nothing: arepromptroute, amerge-test/<k>.mdthat is missing or has noresult:line, aWAVE_DIR/gatethat is a symlink, or an inputclassifyrefuses. Stop the wave with its stderr quoted. Where item 3'sgh pr listexited non-zero, the wave stops with no gate record for that report, so a resume runs the check again. The record is the resume probe's only evidence that this step finished for a report: a build report saved at Step 4 with no gate record beside it returned just before an interruption, and goes back through this step rather than past it. A gate record whose route is the early-publish stop or the failed re-check stop is a recorded stop, and the resume probe stops the wave again on it.
Done when: for every returned lane, its facts are on disk and its policy.log lines are in facts/wave.md, the footprint re-check exited 0 or the wave stopped on it with the stderr lines quoted, a contract change ran the merge test and its result is a line in facts/wave.md, a red one naming the lane that broke the other with the pair's coupling.md row corrected where it said independent, no build report carries a pr and no gh pr list for a build lane printed a URL, the lane is done or is out of the merge set with its dependents held and the reason recorded, and its gate/issue-<N>.md records the route, the re-check, and the merge-test result, written after all of them—or a failed gh pr list stopped the wave with its stderr quoted and no gate record written, or a reprompt route stopped it naming the report path and the field, with no gate record written. A recorded stop ends the wave here, with nothing proceeding to Step 6.
Step 6 — Merge test before publish
Enter when every unheld lane has returned, every build report in the merge set has its gate/issue-<N>.md, and no gate record is a recorded stop; otherwise go back to Step 5. An empty merge set—every lane failed, refused, stopped, or held—has nothing to merge-test or publish: skip this step and Step 7 and go to Step 8's report, which names the held and failed lanes. Run the merge test per references/merge-test.md over the merge set in order.md's order, as one scripts/merge-test.py call with a --lane per branch, which does one git merge --no-ff --no-edit <sha> at a time on each branch's recorded SHA, then INSTALL_CMD and VERIFY_CMD, recorded as WAVE_DIR/merge-test/<k>.md with the base: it merged onto, the SHA of every branch merged, and its result: <green|red|conflict> line, per merge-test.md step 6.
A conflict names the branch that failed to merge and every branch it conflicts with: each branch already merged in this run whose own diff against the base: touches a conflicted path, or DEFAULT where none does. The branch merged just before it may have touched none of those paths. Record the conflict: line merge-test.md step 3 gives, git merge --abort, and stop the wave at this step with those branches named. A conflict after a passing footprint proof means a lane wrote outside the footprint it declared, and the lane's own divvy-up gate should have caught it; either way, resolving it is a judgment call no unattended run makes.
Red with a green baseline is the cross-lane coupling that every ownership proof passed. Read the failing output against coupling.md: a pair recorded independent that is not gets its row corrected, and the lane whose change broke the other is the one held. Stop with the evidence; nothing publishes. A red suite is not routed back to a lane for repair here, because the repair belongs to whichever issue the coupling makes it belong to, and that is the question the user answers.
Green, with git -C MERGE_TREE diff --stat HEAD and git -C MERGE_TREE ls-files --others --exclude-standard both empty, proceeds. The first catches a tracked file the suite changed, the second an untracked file it wrote, which diff never shows; either non-empty is dirty after verify: and red, the untracked paths listed. Neither is git status: the status read that once reported clean over a staged index ran in a copied tree whose index was shared, and ls-files --others reads MERGE_TREE's own index. Remove MERGE_TREE.
Done when: merge-test/<k>.md records its base:, every merged SHA, the merge result, and VERIFY_CMD's real tail; the result is green and both post-verify checks were empty; MERGE_TREE is gone—or the run stopped on a conflict naming the branches it is with, or on a red suite with the pair named, and nothing published.
Step 7 — Publish
Check the base before any dispatch: git -C ROOT fetch origin DEFAULT, then run work-wave/scripts/wave-state.py probe and wave-state.py phase on its output as the Resume section runs them, and dispatch only when phase prints phase: 7. On phase: 6, DEFAULT moved after the newest green merge test or a newer record is red, and each lane's rebase at work-issue's Step 5 would publish a combined tree no merge test saw, so run Step 6 again first and check again the same way before the dispatch. Act on any other line as the Resume section's "Act on the line phase prints" paragraph says. A merge onto the current tip tests the combined tree the lanes' clean rebases produce, not the SHAs they will publish; Step 8's re-test at the published HEADs covers those SHAs, after the pull requests exist.
Read references/lane-brief.md again and instantiate it once per lane in the merge set, with {{PHASE}} publish, {{GRANT}} the full grant, and {{FACTS}} the directory's current contents. Dispatch every one in a SINGLE message at LANE_MODEL. Each lane invokes work-issue <N> <PLAN[N]> --isolate again, with --no-publish dropped, --review-loop[=<comment>] added where the wave carries it, and {{POLICY}} added; work-issue's resume probe reads the red-team clean and no pull request and places the lane at its Step 5, and from there the lane rebases, pushes issue-N, opens its pull request, and runs its triage and repair as its own skill says, without asking.
Run every returned message through handback.py as Step 4 does, with --phase publish, so a terminal report lands at WAVE_DIR/reports/issue-<N>-publish.json and a hand-back is resumed or stops the wave by Step 4's rule. After each terminal report is saved, run lane-policy.py facts on its run_dir as Step 5 item 1 does. Classify each message first: run the same command with --check added, which writes nothing and prints terminal <status> or handback. Where it prints terminal failed, terminal refused, or terminal stopped, other than the poll-cap stop below, take the order.py hold below, then run handback.py without --check to save the report, so the hold lands before the report does and never lands for a message the script saves as a hand-back. Route by the same table as Step 5, so a failed, refused, or stopped lane, other than the poll-cap stop below, moves every lane ordered after it in order.md to held by order.py hold, and that order.md write comes before the lane's reports/issue-<N>-publish.json: a crash between the two leaves the lane unreported, so a resume runs Step 7 for it again with its successors already held. A lane that stopped with triage/waiting when work-issue's review poll hit its cap is done for this wave's purposes, since resolving stays the reviewer's act and work-issue N continues it. Step 8 re-polls it once before the report. The gate record is not rewritten: the resume probe reads each publish report's status, and a failed, refused, or stopped one takes its lane out of the merge set, except a stopped lane whose RUN_DIR (open or under closed/) holds triage/waiting. A publish report with no readable status stops the resume.
Done when: phase printed phase: 7 over a probe taken after the fetch, at the moment of dispatch; every lane in the merge set was dispatched with the full grant in one message and every report is on disk, written by handback.py, or the wave stopped on a lane's third hand-back with its interim reports named; each is done, waiting on its reviewer, or out of the merge set with its dependents held and the reason recorded.
Step 8 — Report
A merge-set lane whose open RUN_DIR holds triage/waiting and that has no WAVE_DIR/repoll/issue-<N> is re-polled once. Write every such lane's WAVE_DIR/repoll/issue-<N> before the dispatch, as one line, dispatched: <date -u +%FT%TZ>; the probe reads only whether the file exists. The record comes first so a resumed wave never re-polls a lane twice. A crash between the record and the dispatch costs that lane its re-poll and nothing more. The re-polls run before the merge-test re-check below, because a re-polled lane that repairs moves its HEAD. Instantiate the lane brief once per such lane, with {{PHASE}} repoll, {{GRANT}} the full grant, and {{FACTS}} the directory's current contents. Dispatch them all in a SINGLE message at LANE_MODEL, so the wave waits one poll window, not one per lane. Each lane invokes work-issue <N> <PLAN[N]> --isolate, with --review-loop[=<comment>] where the wave carries it, and {{POLICY}}. work-issue's resume probe puts the lane back in its Step 6 poll, and a review that lands goes through triage and repair as work-issue says. Run every returned message through handback.py as Step 4 does, with --phase repoll, which saves a terminal report to WAVE_DIR/reports/issue-<N>-repoll.json, then run lane-policy.py facts on its run_dir as Step 5 item 1 does. A re-poll report changes neither the merge set nor order.md: every lane has already published, so nothing is left to hold, and a repair that breaks the combined tree meets the re-test's red. Then probe again.
Before the report, probe as the Resume section runs it and tell the answers apart by the reason phase prints: row 10: is the re-poll above, row 11: the re-test, and row 12: the report. Where it prints row 11:, a lane's HEAD moved since the newest merge-test/<k>.md—a repair round moved it—or that record merged a lane that has since left the merge set, so run the merge test once more, in order, before anything is reported, as one scripts/merge-test.py call over the merge set. The order the human merges in has to have been tested at the SHAs they will merge. Act on any other line as the Resume section says.
Then the final report: the merge order as a numbered list of pull-request URLs with each lane's After; the held lanes and what each waits on; the failed or stopped lanes with their reports quoted, a re-polled lane's reports/issue-<N>-repoll.json quoted in place of its publish report; the path of the newest merge test and its result line; the coupling table; the fact count and the path of facts/; and the closing line, "a human merges, in this order", or "waiting on the reviewers" where every lane is answered but none has cleared. Then move WAVE_DIR to closed/ only when every lane's own RUN_DIR has moved to its closed/: before that the wave is still resumable, and a wave directory under closed/ is what the resume probe reads as finished.
Done when: every lane row 10 named has its repoll/issue-<N> record and, unless a crash fell between the two, its reports/issue-<N>-repoll.json; the merge test is green at the current HEAD of every lane in the merge set and the report names the order, the held and failed lanes, the merge-test path, the coupling table, and the facts path, and ends on the line the state earns—or the wave stopped on a lane's third hand-back with its interim reports named.
Resume
The world outranks WAVE_DIR, and WAVE_DIR outranks memory. Each lane's state is work-issue's to read, through its own resume probe, and this skill never guesses at a lane's phase: it asks by re-dispatching work-issue N, which resumes itself. WAVE_DIR says only what this skill has already produced. First match wins:
| # | Probe | Resume at |
| 1 | <COMMON>/work-wave/closed/wave-<WAVE_ID>/ exists | done; say so. Where a lane RUN_DIR is open again, stop instead, naming each such lane: its own work-issue N resumes it, and a closed wave never restarts |
| 2 | no WAVE_DIR, or WAVE_DIR with lanes.md or harvest.md missing | Step 0 |
| 3 | lanes.md and harvest.md; no footprint/check.txt | Step 1 |
| 4 | check.txt; coupling.md or order.md missing | Step 2 |
| 5 | order.md; no merge-test/0.md | Step 3, every ask row and the confirmation again, then Step 4 |
| 6 | merge-test/0.md; some saved build report has no gate/issue-<N>.md, or some gate record recorded a stop | Step 5 for the ungated reports only, then probe again; a recorded stop stops the wave again, naming the lane and its pull-request URL or the re-check's stderr lines, until the user rules on it |
| 7 | merge-test/0.md; some unheld lane has no reports/issue-N-build.json | Step 4 for those lanes only, in one message; a lane whose RUN_DIR exists is resumed by its own work-issue, and its build report is whatever it returns |
| 8 | every gate record; some lane in the merge set has no reports/issue-N-publish.json, and the newest merge-test/<k>.md with k > 0 whose recorded branches are exactly the merge set, each at its current HEAD, is missing or not green | Step 6, which stops again on a red or conflicted record |
| 9 | the newest merge test over exactly the merge set at its current HEADs is green; some lane in the merge set has no reports/issue-N-publish.json | Step 7 for those lanes only, when the fetched origin/DEFAULT equals that merge test's base:; where it differs, Step 6, then Step 7 |
| 10 | every publish report; some merge-set lane's open RUN_DIR holds triage/waiting and WAVE_DIR has no repoll/issue-<N> | Step 8's re-poll for those lanes only, then probe again |
| 11 | every publish report; a non-empty merge set; the HEAD of some lane in it moved since the newest merge test, or that test merged a lane that has since left the merge set | Step 8's re-test, then the report |
| 12 | every publish report; the newest merge test over exactly the merge set at its current HEADs is green, or an empty merge set | Step 8's report |
Run the table through its script rather than walking it by hand. First git -C ROOT fetch origin DEFAULT, because row 9 compares against the fetched origin/DEFAULT. Then work-wave/scripts/wave-state.py probe --wave-dir WAVE_DIR --root ROOT --default DEFAULT [--pr-bundle FILE], its stdout saved to a temp file outside WAVE_DIR, and work-wave/scripts/wave-state.py phase --probe on that file. --pr-bundle takes Step 5's gh pr list answers where they are on hand, as a JSON object mapping issue-<N> to the URLs printed, so a row 6 stop names each pull request from the probe's detail.prs.
Act on the line phase prints. Exit 0 with a step number resumes at that step, scoped as its row's cell says; done is row 1. Exit 1 is a stop: report its reason and every null field the probe's stderr names, and stop the wave. A null is a read that failed, so it always stops, and fixing what stderr names and probing again is the way on. Exit 3 means the probe or the phase could not run; report its stderr and stop. The table above is the readable copy, and the script's RESUME_ROWS must match it cell for cell, which tests/work-wave-smoke.sh checks.
A wave re-invoked with --review-loop passes it on the next dispatch of every merge-set lane whose RUN_DIR is still open: Step 4's dispatch at row 7, Step 7's at row 9. Step 8's re-poll is a dispatch too, so a lane waiting at the poll cap gets the flag there. A wave re-invoked with different policy flags passes the new {{POLICY}} at those same dispatches. A lane past both, or one the wave already re-polled, needs work-issue N --review-loop run by hand.
A lane's work-issue may itself be mid-run on a herdr agent or a stranded worktree; those are its rows 2 and 3, and re-dispatching it is how they get read.
Further Reading
- references/lane-brief.md — read at Steps 4, 7, and 8 to instantiate each lane's dispatch and the report contract it returns
- references/merge-test.md — read at Steps 4, 5, 6, and 8 to build the scratch tree, merge in order, verify, and remove it
- scripts/merge-test.py — run at Steps 4, 5, 6, and 8 as
merge-test.py --wave-dir WAVE_DIR --root ROOT --default DEFAULT --merge-tree MERGE_TREE --install INSTALL_CMD --verify VERIFY_CMD [--lane issue-N ...] [--baseline], in the background, to run the merge test and write its record - scripts/check-footprints.py — run at Step 1 to print each lane's footprint from its plan:
work-wave/scripts/check-footprints.py --extract PLAN. Run again at Step 1 to prove the lanes' footprints disjoint and list the pairs, and at Step 5 to prove it again over what the lanes derived:work-wave/scripts/check-footprints.py --lane issue-N=PATH --lane issue-M=PATH [...] [--runs DIR] - scripts/check-worktrees.py — run at Step 3 to refuse the wave on any unheld lane whose WORKTREE already exists or is registered, exempting a started lane's own tree:
work-wave/scripts/check-worktrees.py --root ROOT --lane issue-N=WORKTREE [--lane ...] [--started issue-N ...] - scripts/order.py — run at Steps 2 and 3 to write
order.mdfromcoupling.md, and at Steps 5 and 7 to hold the lanes ordered after one that left:work-wave/scripts/order.py build --wave-dir WAVE_DIR, orwork-wave/scripts/order.py hold --wave-dir WAVE_DIR --lane issue-N --why TEXT - scripts/gate-lane.py — run at Step 5 to name each build report's contract change and route, then to write its gate record:
work-wave/scripts/gate-lane.py classify --report FILE --pr-urls FILE --recheck-exit N [--contract PATH ...], thenwork-wave/scripts/gate-lane.py record --wave-dir WAVE_DIR <the same flags> --recheck-output FILE --merge-test <k|none> - scripts/handback.py — run at Steps 4, 7, and 8 on every message a lane returns, to save its report or its interim hand-back and say whether to resume it, and with
--checkat Step 7 to classify a message without writing it:work-wave/scripts/handback.py --wave-dir WAVE_DIR --lane issue-N --phase build|publish|repoll --text FILE [--check] - scripts/wave-state.py — run at every resume to gather the probe and answer its phase:
work-wave/scripts/wave-state.py probe --wave-dir WAVE_DIR --root ROOT --default DEFAULT [--pr-bundle FILE], thenwork-wave/scripts/wave-state.py phase --probe FILE - scripts/lane-policy.py — run once per invocation to validate the policy flags and render
{{POLICY}}, and at Steps 5, 7, and 8 to copy a returned lane's rulings intofacts/wave.md:work-wave/scripts/lane-policy.py flags [--auto-budget R] [--defer-after K] [--repair-class C], orwork-wave/scripts/lane-policy.py facts --run-dir RUN_DIR --wave-dir WAVE_DIR
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
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.

