Auto Build
Overview
Collapse plan → build into a single approved, autonomous pass that implements every task the disciplined
way — test-first, integrated, reviewed, individually committed — while the DAG guarantees nothing is built
before its dependencies land and the checkpoint guarantees a stop is always resumable. It removes the human
stepping between tasks, not the verification: every task still earns a passing test and its own commit.
Phase 0: Preflight — plan, clean baseline, working branch
- Resolve the plan (
$plan, or newest .ulpi/plans/*) and its independent Phase-0 intake snapshot
(<stateDir>/intake/<run>.json from the active run config/checkpoint), then run the deterministic gate:
node <auto-plan-dir>/scripts/validate-plan.mjs <plan.json> --intake <absolute-snapshot.json> — a
non-zero exit is disqualifying (the same structural judge auto-plan and the pipeline preflight run;
mechanically checked, never prose-only). No plan → route to auto-plan. No intake snapshot → STOP and
route to pipeline intake; the plan cannot establish its own scope authority. Malformed/cyclic plan →
STOP (it would build on a broken base).
- Confirm
root is a git work tree with a committed workingBranch; never build on a protected branch
without explicit confirmation.
- Require a CLEAN baseline:
git status --porcelain shows only expected planning artifacts
(.ulpi/spec/*, .ulpi/plans/*). Anything else → stop and ask the user to commit/stash.
- Fold the prior-run lessons from your loaded context into the engineer briefs —
auto-learn
routes them into CLAUDE.md / .claude/rules (auto-loaded for you), but a subagent engineer starts
fresh, so a lesson the machine already paid for (a flaky service, a validate footgun, a boundary that
bites) must be copied into its brief to reach the agent doing the work.
- Declare the run's budget/caps with
budget-guard (max fix iterations per task, concurrency cap,
token/wall-clock ceiling). Create the checkpoint-resume file with one unit per task. On resume,
load the existing checkpoint and skip done tasks.
Success criteria: a valid plan, a clean git baseline on a confirmed branch, budget + checkpoint set.
Phase 1: One approval gate
Present the full plan (tasks, layers, what each touches). Wait for an UNAMBIGUOUS affirmative ("approve",
"go", "yes"); treat hedges ("looks reasonable", "I guess") as NOT approved. This is the single human gate.
If the plan was just generated, commit it as one preparatory commit so it doesn't bleed into task 1.
Success criteria: explicit approval recorded; planning artifacts committed separately.
Phase 2: Walk the DAG — layer by layer
For each layer in topological order (barrier between layers), build its tasks — in parallel across
worktrees, capped by fan-out-work. When the plan assigned a task a specialist (agent/skill/
reviewer — auto-plan matched it to an INSTALLED agent/skill by description), spawn the engineer and
reviewer as those specialists and have the engineer invoke the domain skill first; a missing name
degrades to a general engineer and is recorded, never a hard failure. Per task, run the build contract
(references/build-contract.md):
- Gate on deps — all
dependsOn integrated? else dep_blocked (point at the root), skip.
- Implement (isolated) — a fresh worktree + task branch; RED (a failing test for the behavior) →
GREEN (minimal code) → REFACTOR; stay inside the task's write scope.
- Integrate — a serialized merge of the task branch onto the working branch, removing the merged
worktree. Integration is merge-only; it does not run the whole-workspace validate.
- Review —
adversarial-verify the integrated slice against ITS acceptance criteria (slice-scoped:
an unmet whole-codebase invariant a LATER task owns is an observation, not a block on this slice).
Skippable only if the user disabled per-task review.
- Fix loop —
converge-loop (bounded, MAX_FIX≈3) on findings inside the task's write scope until
the slice's validate is green; else mark blocked with the reason (don't spin).
- Commit + checkpoint — one commit for the task's files + its status; mark the unit
done.
Update the checkpoint as each task reaches its terminal state.
Success criteria: every task in the layer is done, blocked, or dep_blocked — each integrated
task test-passing and individually committed; the barrier holds before the next layer.
Phase 3: Stop-and-ask triggers (throughout)
Halt the autonomous pass and ask the user — do not push through — when:
- a task's test/build won't go green without an obvious fix (surface the failure + diagnosis);
- the spec is ambiguous or a task needs a decision the spec doesn't cover;
- a task is high-risk/irreversible (see rule 6) — get explicit sign-off before continuing.
After the user resolves it, re-invoke to resume from the next pending task.
Success criteria: risky/ambiguous/unfixable situations reach the user, not a guessed-through commit.
Phase 4: Final validate + report
Once the DAG is walked, run the whole-workspace validate ONCE on the integrated tree — the load-bearing
end-state gate (slices can each pass yet break the merged tree). Then report per Output Contract: tasks
done/blocked/dep_blocked, tests added, commits, the final validate result, and anything escalated. Fail
closed: a red final validate is never reported as a clean build.
Success criteria: the integrated tree's validate result is known and reported honestly; the checkpoint
reflects the final state.
Common Rationalizations
| Rationalization |
Reality |
| "Approval means I can push through anything now." |
Approval authorizes the PLAN, not irreversible surprises. Destructive/ambiguous steps still stop and ask. |
"I'll git add -A to save time." |
That absorbs unrelated work into a task's commit and breaks clean rollback. Stage only the task's files. |
| "Dependency isn't integrated yet, but I'll build anyway and reconcile later." |
That's building on a broken base. dep_blocked it; don't construct on a missing migration/route/symbol. |
| "The slice validate is red but it's a pre-existing failure." |
Then classify it as pre-existing and say so — don't silently mark the task done on red, and don't discard correct work either. |
| "This task is drowning the review in whole-codebase gaps." |
Per-task review is slice-scoped. Attribute end-state gaps to the owning task as observations; don't block the current slice. |
| "One big commit at the end is simpler." |
It destroys per-task rollback and hides which task broke what. One commit per task. |
Red Flags
- A task marked
done with a red slice validate, or with a test skipped/weakened to pass.
git add -A / commits mixing multiple tasks' files.
- A task built while a
dependsOn is still pending/blocked.
- An irreversible action taken inside the pass with no stop-and-ask.
- Two agents writing the working tree without worktree isolation.
- A resume that rebuilt already-integrated tasks (checkpoint ignored/overwritten).
- A red final workspace validate reported as a clean build.
Enforcement (deterministic, not prose)
While this skill is active, a skill-scoped PreToolUse hook runs scripts/guard-git-hygiene.sh on
every Bash call: bulk staging (git add/stage -A/./--all and whole-repo pathspecs like :/),
commit -a/--all, plain git push --force (non-lease), reset --hard, and clean -f are BLOCKED
at the tool layer (token-parsed — --amend and commit-message contents never false-positive). The
clean-rollback contract is enforced by machinery, not by asking nicely. Rules 2–3 above are therefore
not aspirational.
Guardrails
- One human gate (plan approval); everything irreversible/ambiguous/unfixable still escalates.
- Clean baseline required; one commit per task; stage only that task's files.
- Follow the DAG; never build on un-integrated dependencies; never ship/mark-done on a red validate.
- Test-driven every task; never weaken/skip tests to go green.
- Isolate parallel writers; serialize integration; prune merged worktrees.
- Durable resume: skip
done, never overwrite the checkpoint.
- Fail closed on the final validate.
When To Load References
references/build-contract.md — the per-task contract: worktree/branch, RED→GREEN→REFACTOR, integrate
(merge + worktree removal), slice-scoped review, the bounded fix loop, and the task-exit gate.
converge-loop (skill) — the bounded per-task fix loop.
adversarial-verify (skill) — the per-task slice review.
fan-out-work (skill) — parallel, capped, isolated per-layer task execution.
checkpoint-resume (skill) — durable per-task state + skip-done resume.
budget-guard (skill) — the run-level caps and escalation contract.
Output Contract
Report:
- plan built + working branch; the single approval recorded
- per task: done / blocked / dep_blocked (with reasons), tests added, the commit
- the final whole-workspace validate result (green/red — honest)
- anything escalated to the user (unfixable / ambiguous / irreversible)
- checkpoint file path (durable, resumable record)
1---2name: auto-build3description: Implement a whole DAG plan autonomously — one approved pass, one clean rollback point per task, never building on a broken base. It requires an approved plan (specced upstream) and a clean git baseline, takes a SINGLE human approval of the plan, then walks the DAG layer by layer: for each task it implements on an isolated worktree branch test-first (RED → GREEN), integrates the slice onto the working branch, reviews the integrated change, runs a bounded fix loop until the task passes, and commits it individually — so any point is a clean rollback. It follows the dependency graph strictly (a task builds only once its deps integrate), checkpoints every task so it resumes exactly where it stopped, and STOPS-and-asks on unfixable failures, ambiguity, or irreversible steps rather than pushing through. This is the BUILD phase. Composes fan-out-work (per layer), converge-loop (per-task fix), adversarial-verify (per-task review), checkpoint-resume, and budget-guard.4---56<EXTREMELY-IMPORTANT>7This drives real, unattended code writing across many tasks. Non-negotiable:81. ONE HUMAN GATE: approve the plan. After an unambiguous approval, run autonomously — but that approval9 is the ONLY blanket authorization. Irreversible/ambiguous/unfixable situations still STOP and ask.102. CLEAN BASELINE FIRST. Require a clean git tree (only expected planning artifacts uncommitted). Per-task11 commits must never absorb unrelated local work, or the clean-rollback guarantee breaks.123. ONE SLICE AT A TIME, EACH ITS OWN COMMIT. Implement, test, integrate, review, fix, commit — per task.13 Stage only that task's files (never `git add -A` blindly). Any commit is a clean rollback point.144. FOLLOW THE DAG — NEVER BUILD ON A BROKEN BASE. A task builds only once ALL its `dependsOn` are actually15 INTEGRATED on the working branch. A task whose dependency never landed is `dep_blocked` (pointed at the16 root), never built anyway.175. TEST-DRIVEN, FAIL CLOSED. Every task earns a failing-then-passing test and a green slice-scoped18 validate before it's `done`. Never mark a task done on a red validate; never weaken/skip tests to go19 green (that's faking the gate).206. STOP AND ASK — do not push through — on: a test/build that won't go green without an obvious fix; a21 spec ambiguity or a decision the spec doesn't cover; or a high-risk/irreversible step (auth/permission22 changes, destructive migrations, payments, deletions, deploys, anything touching secrets, anything you23 can't `git revert`).247. ISOLATE PARALLEL WRITERS. Tasks in a layer run in separate worktrees; integration is a serialized25 merge onto the working branch that also removes each merged worktree. Never two agents writing the26 working tree at once.278. RESUME IS DURABLE. On resume, read the checkpoint and rebuild only tasks not `done` — never redo28 integrated work, never overwrite the checkpoint with a fresh pending doc.29</EXTREMELY-IMPORTANT>3031# Auto Build3233## Overview3435Collapse plan → build into a single approved, autonomous pass that implements every task the disciplined36way — test-first, integrated, reviewed, individually committed — while the DAG guarantees nothing is built37before its dependencies land and the checkpoint guarantees a stop is always resumable. It removes the human38stepping *between* tasks, not the verification: every task still earns a passing test and its own commit.3940## Phase 0: Preflight — plan, clean baseline, working branch4142- Resolve the plan (`$plan`, or newest `.ulpi/plans/*`) and its independent Phase-0 intake snapshot43 (`<stateDir>/intake/<run>.json` from the active run config/checkpoint), then run the deterministic gate:44 `node <auto-plan-dir>/scripts/validate-plan.mjs <plan.json> --intake <absolute-snapshot.json>` — a45 non-zero exit is disqualifying (the same structural judge auto-plan and the pipeline preflight run;46 mechanically checked, never prose-only). No plan → route to `auto-plan`. No intake snapshot → STOP and47 route to pipeline intake; the plan cannot establish its own scope authority. Malformed/cyclic plan →48 STOP (it would build on a broken base).49- Confirm `root` is a git work tree with a committed `workingBranch`; never build on a protected branch50 without explicit confirmation.51- Require a CLEAN baseline: `git status --porcelain` shows only expected planning artifacts52 (`.ulpi/spec/*`, `.ulpi/plans/*`). Anything else → stop and ask the user to commit/stash.53- **Fold the prior-run lessons from your loaded context into the engineer briefs** — `auto-learn`54 routes them into CLAUDE.md / `.claude/rules` (auto-loaded for you), but a subagent engineer starts55 fresh, so a lesson the machine already paid for (a flaky service, a validate footgun, a boundary that56 bites) must be copied into its brief to reach the agent doing the work.57- Declare the run's budget/caps with `budget-guard` (max fix iterations per task, concurrency cap,58 token/wall-clock ceiling). Create the `checkpoint-resume` file with one unit per task. On **resume**,59 load the existing checkpoint and skip `done` tasks.6061**Success criteria:** a valid plan, a clean git baseline on a confirmed branch, budget + checkpoint set.6263## Phase 1: One approval gate6465Present the full plan (tasks, layers, what each touches). Wait for an UNAMBIGUOUS affirmative ("approve",66"go", "yes"); treat hedges ("looks reasonable", "I guess") as NOT approved. This is the single human gate.67If the plan was just generated, commit it as one preparatory commit so it doesn't bleed into task 1.6869**Success criteria:** explicit approval recorded; planning artifacts committed separately.7071## Phase 2: Walk the DAG — layer by layer7273For each layer in topological order (barrier between layers), build its tasks — in parallel across74worktrees, capped by `fan-out-work`. When the plan assigned a task a specialist (`agent`/`skill`/75`reviewer` — auto-plan matched it to an INSTALLED agent/skill by description), spawn the engineer and76reviewer as those specialists and have the engineer invoke the domain `skill` first; a missing name77degrades to a general engineer and is recorded, never a hard failure. Per task, run the build contract78(`references/build-contract.md`):79801. **Gate on deps** — all `dependsOn` integrated? else `dep_blocked` (point at the root), skip.812. **Implement (isolated)** — a fresh worktree + task branch; RED (a failing test for the behavior) →82 GREEN (minimal code) → REFACTOR; stay inside the task's write scope.833. **Integrate** — a serialized merge of the task branch onto the working branch, removing the merged84 worktree. Integration is merge-only; it does not run the whole-workspace validate.854. **Review** — `adversarial-verify` the integrated slice against ITS acceptance criteria (slice-scoped:86 an unmet whole-codebase invariant a LATER task owns is an observation, not a block on this slice).87 Skippable only if the user disabled per-task review.885. **Fix loop** — `converge-loop` (bounded, `MAX_FIX`≈3) on findings inside the task's write scope until89 the slice's validate is green; else mark `blocked` with the reason (don't spin).906. **Commit + checkpoint** — one commit for the task's files + its status; mark the unit `done`.9192Update the checkpoint as each task reaches its terminal state.9394**Success criteria:** every task in the layer is `done`, `blocked`, or `dep_blocked` — each integrated95task test-passing and individually committed; the barrier holds before the next layer.9697## Phase 3: Stop-and-ask triggers (throughout)9899Halt the autonomous pass and ask the user — do not push through — when:100101- a task's test/build won't go green without an obvious fix (surface the failure + diagnosis);102- the spec is ambiguous or a task needs a decision the spec doesn't cover;103- a task is high-risk/irreversible (see rule 6) — get explicit sign-off before continuing.104105After the user resolves it, re-invoke to resume from the next pending task.106107**Success criteria:** risky/ambiguous/unfixable situations reach the user, not a guessed-through commit.108109## Phase 4: Final validate + report110111Once the DAG is walked, run the whole-workspace `validate` ONCE on the integrated tree — the load-bearing112end-state gate (slices can each pass yet break the merged tree). Then report per Output Contract: tasks113done/blocked/dep_blocked, tests added, commits, the final validate result, and anything escalated. Fail114closed: a red final validate is never reported as a clean build.115116**Success criteria:** the integrated tree's validate result is known and reported honestly; the checkpoint117reflects the final state.118119## Common Rationalizations120121| Rationalization | Reality |122|---|---|123| "Approval means I can push through anything now." | Approval authorizes the PLAN, not irreversible surprises. Destructive/ambiguous steps still stop and ask. |124| "I'll `git add -A` to save time." | That absorbs unrelated work into a task's commit and breaks clean rollback. Stage only the task's files. |125| "Dependency isn't integrated yet, but I'll build anyway and reconcile later." | That's building on a broken base. `dep_blocked` it; don't construct on a missing migration/route/symbol. |126| "The slice validate is red but it's a pre-existing failure." | Then classify it as pre-existing and say so — don't silently mark the task done on red, and don't discard correct work either. |127| "This task is drowning the review in whole-codebase gaps." | Per-task review is slice-scoped. Attribute end-state gaps to the owning task as observations; don't block the current slice. |128| "One big commit at the end is simpler." | It destroys per-task rollback and hides which task broke what. One commit per task. |129130## Red Flags131132- A task marked `done` with a red slice validate, or with a test skipped/weakened to pass.133- `git add -A` / commits mixing multiple tasks' files.134- A task built while a `dependsOn` is still pending/blocked.135- An irreversible action taken inside the pass with no stop-and-ask.136- Two agents writing the working tree without worktree isolation.137- A resume that rebuilt already-integrated tasks (checkpoint ignored/overwritten).138- A red final workspace validate reported as a clean build.139140## Enforcement (deterministic, not prose)141142While this skill is active, a skill-scoped PreToolUse hook runs `scripts/guard-git-hygiene.sh` on143every Bash call: bulk staging (`git add`/`stage -A/./--all` and whole-repo pathspecs like `:/`),144`commit -a/--all`, plain `git push --force` (non-lease), `reset --hard`, and `clean -f` are BLOCKED145at the tool layer (token-parsed — `--amend` and commit-message contents never false-positive). The146clean-rollback contract is enforced by machinery, not by asking nicely. Rules 2–3 above are therefore147not aspirational.148149## Guardrails150151- One human gate (plan approval); everything irreversible/ambiguous/unfixable still escalates.152- Clean baseline required; one commit per task; stage only that task's files.153- Follow the DAG; never build on un-integrated dependencies; never ship/mark-done on a red validate.154- Test-driven every task; never weaken/skip tests to go green.155- Isolate parallel writers; serialize integration; prune merged worktrees.156- Durable resume: skip `done`, never overwrite the checkpoint.157- Fail closed on the final validate.158159## When To Load References160161- `references/build-contract.md` — the per-task contract: worktree/branch, RED→GREEN→REFACTOR, integrate162 (merge + worktree removal), slice-scoped review, the bounded fix loop, and the task-exit gate.163- `converge-loop` (skill) — the bounded per-task fix loop.164- `adversarial-verify` (skill) — the per-task slice review.165- `fan-out-work` (skill) — parallel, capped, isolated per-layer task execution.166- `checkpoint-resume` (skill) — durable per-task state + skip-done resume.167- `budget-guard` (skill) — the run-level caps and escalation contract.168169## Output Contract170171Report:1721731. plan built + working branch; the single approval recorded1742. per task: done / blocked / dep_blocked (with reasons), tests added, the commit1753. the final whole-workspace validate result (green/red — honest)1764. anything escalated to the user (unfixable / ambiguous / irreversible)1775. checkpoint file path (durable, resumable record)