This is part 9 of 9 in the AI-Native Engineering series. Start with the course index or continue to the next part below.
Audience. You should know one programming language, Git, a shell, HTTP, and how to run tests. The examples use plain files, JSON, HTTP, Git, and shell so the ideas transfer across agent SDKs.
Shared capstone. Every part extends the same shop-agent: a support agent that searches products, inspects orders, and prepares—but never executes—a refund recommendation. The companion repository lives alongside the site source.
Build the Software Factory
Capability. Turn a backlog into a safe, observable conveyor belt where background agents make incremental progress and humans steer.
A software factory is not “let the model write everything.” It is a control plane:
flowchart LR
I[Issue with acceptance tests] -->|queues| Q[Queue / scheduler]
Q -->|leases| W[Isolated worktree + agent]
W -->|produces| V[Tests, lint, evals, security]
V -->|gates| PR[Review-ready change]
PR -->|requests| H[Human or agent review]
H -->|fix| W
H -->|merge| D[Deploy + telemetry]
D --> G[Doc gardening + regression case]
G --> I
Text equivalent: An issue with tests enters a queue. A worker receives an isolated worktree, produces code and evidence, and passes automated gates before review. Review either sends the work back for repair or merges it; deployment telemetry creates documentation and regression work that returns to the queue.
Module contract. Starting state: all prior artifacts in course/shop-agent. Add one issue with acceptance tests, risk, owner, checkpoint, and rollback; run both commands; prove the progress handoff is sufficient for a fresh agent.
Factory contracts. An issue has a measurable outcome, constraints, test cases, owner, and risk class. A run has a lease, budget, timeout, heartbeat, checkpoint, and cancellation. A merge requires tests, review evidence, and a clean diff. A deploy has rollback and post-deploy checks.
Measure the factory as a product: cost per successful outcome, time to first useful artifact, review acceptance rate, escaped defects, flaky-test rate, and human minutes per shipped change. PR count alone is a vanity metric.
Long-running design. Separate session (append-only record), harness (loop and routing), and sandbox (compute/files). Persist plans and progress outside the context window. Rehydrate from the last verified checkpoint, not from a model’s memory.
Entropy control. Schedule doc gardening, dead-code cleanup, dependency updates, flaky-test repair, and architecture checks. Throughput without cleanup eventually makes the repository less legible and slows every future agent.
Capstone acceptance. shop-agent can:
- discover and load the right skill;
- retrieve only relevant context;
- call read-only tools through the gateway;
- refuse injected instructions and wrong scopes;
- survive a timeout without duplicating work;
- produce a trace, tests, and review-ready diff;
- resume after a context reset from its progress file;
- explain what remains for a human.
Continue the series
← Previous: Parallelize Background Agents as a Bounded DAG
Return to the course index.