Layer: execution. Proof: make prove LEVEL=execution.
One giant session becomes small agents with a model, a turn cap, a tool list and a budget each.
A single long session carries every file it ever read. Context grows, cost grows, and one wrong turn is expensive. Nothing says what the planner may do versus the builder.
Ask one session to plan, build and review a feature. Watch /context fill.
.claude/agents/planner.md,builder.md,reviewer.md,verifier.md. Each names a model alias,maxTurnsandtools. The builder runs in its own worktree..factory/config.jsonlists six stages, each with a model, turn cap, dollar budget and permission mode. It also lists the allowed models and routes: an epic plan goes to Opus, docs work goes to Haiku.factory/config.tsvalidates the file with zod.
Run make factory ISSUE=1 FLAGS=--dry-run. It prints each stage with its limits and the review-loop cap. The main session stays small because stages run elsewhere.
- Type
make factory ISSUE=1 FLAGS=--dry-run. Expect six stages in order. - Open
.factory/config.json. Change the build model to one not inallowedModels. Expect the proof to fail. - Revert it.
make prove LEVEL=execution checks every agent has model, maxTurns and tools, the config validates, every stage model is allowed, and prints the worst-case cost of one pass.
Track A: add a stage budget and see the worst case change. Track B: write a new agent for accessibility review.
- Models are routed per stage in
.factory/config.json. Readcost.jsonfrom a run to see what each stage spent, and lower the effort on the stages that spent most for the least gain. - Two terminals, each on its own worktree (
git worktree add), run two sessions at once without overwriting each other. The builder agent usesisolation: worktreefor the same reason. - Pick the orchestration by what you need back:
| Need | Use |
|---|---|
| A result from one focused read | a subagent |
| A fixed order of stages with caps | the factory runner or .claude/workflows/factory.js |
| Many independent runs of one prompt | claude -p in a loop |
The verifier runs in plan mode, the builder accepts edits inside its own worktree, and the reviewer keeps notes in .claude/agent-memory/reviewer/. .mcp.json names a GitHub server whose token comes from the environment, so it holds no secret. A project server still asks for approval before it connects.
What does one runaway stage cost you today?
