Quality at every station: building a software factory

AI-generated illustration.
Between August and the end of October, 227 pull requests merged into a codebase I work on through a pipeline of agents. As it runs today, an agent picks an issue off the backlog, plans it, builds it in its own worktree, reviews it, fixes what the review found and opens the PR. Other agents unblock it, review it again against the merge with the main branch, and tell me when it's ready to merge. For the changes I point it at, a QA agent then attacks the deployed build over real HTTP.
People have started calling that kind of setup a software factory. In the last few months I've watched most of the talks and read most of the guides, and they agree on more than their titles suggest. This article takes the best of them, maps each idea onto the pipeline I built, and gives an order to build your own in. Where an idea is someone else's, I say whose. Most of the design is mine, and so are most of the mistakes.
The codebase is a .NET modular monolith partway through a port from a legacy system, and the factory is a set of Claude Code commands, skills, hooks and a few Node scripts. It would work in any stack. What it depends on is GitHub.
What a software factory is
The cleanest definition I've found is from the LaunchDarkly guide by Alexis Roberson: the parts don't matter on their own, and "the factory is what happens between them, when one agent's plan becomes another agent's pull request and a third agent's review." Her closing line is the one I'd put on the wall: "build the stations so that each one can refuse a bad change. That refusal is the product."
Eric Zakariasson's talk at AI Engineer gives the longer view. He walks through Dan Shapiro's levels of autonomy, from autocomplete up to delegating whole tasks to agents, and ends at the factory, which he describes as "essentially like a black box": the human supplies intent and the agents build, test and ship. Early in the same talk he says the honest thing: "To be honest, I don't think we're really there yet." He works at Cursor. If the people building the tools aren't running lights-out, nobody reading this should plan to.
The LeadDev guide by Chris Kelly defines a factory by its properties: "instrumented, repeatable, quality-gated production". Read it knowing that Kelly runs developer experience at Augment Code, that the page carries an Augment partner block beside it, and that it ends in a product pitch. The definition still holds up.
My working definition is narrower. A software factory is a set of stages, each owned by an agent or a script, that hand work to each other through a shared record (for me, GitHub issues and pull requests), where every stage owns the quality of what it passes on and checks the work of the stage before it, and a human owns the last station before production. Refusing a bad change is how a stage exercises that ownership. What it buys is the other side of it: a change that reaches me has already been checked by every stage it passed through. Take that ownership away from the stages and what's left is an agent with a lot of permissions. That can be useful, but it's a different thing.
Make the codebase ready first
Zakariasson's readiness test is three questions: is the codebase runnable, accessible and verifiable? Can an agent start it, can it reach the context it needs, and can it prove its change works? He says verification is the part "people should be spending a lot more time" on, and that matches my experience. Every stage downstream is only as good as the checks it can run.
So a lot of my factory is plain CI: gates that make the rules mechanical. The repo has a deterministic check that every source change comes with a test change, a check that the generated OpenAPI contract matches the code, a formatter that fails the build on drift, and a comment budget enforced in CI. The budget used to be the phrase "extremely concise", and a phrase loses every argument with a hard-won explanation, so now it's a number, and the number is the point.
That's the pattern for everything that follows. A rule an agent has to read and remember will be forgotten on the run where it matters, so wherever I can I turn the rule into a script that fails. Here is one rule in the three forms it has taken, because the progression is the whole method.
The first form is a line in the root CLAUDE.md:
- NEVER modify auto-generated files (`// <auto-generated>`, `src/Domain/Entities/`)
The agent reads it at the start of every session, and some sessions edit a generated file anyway, usually deep into a long run when the instructions are far behind the context. The second form is a PreToolUse hook: a shell script Claude Code runs before every Edit or Write, which exits 2 to block the call and surfaces its message to the agent. Here it is, trimmed to the logic:
#!/bin/bash
file_path=$(cat | sed -n 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
[ -z "$file_path" ] && exit 0 # no path to judge: never block on ambiguity
block() {
echo "BLOCKED: $file_path is auto-generated and must never be edited by hand ($1)." >&2
echo "Change the generator or the source it reads instead." >&2
exit 2
}
case "$file_path" in
*src/Domain/Entities/*) block "generated from templates" ;;
esac
if [ -f "$file_path" ]; then
# The marker must open its line, which is how every generator emits it. Matching it anywhere
# on the line blocked documentation *about* the convention: a hand-written file became uneditable.
if head -n 5 "$file_path" | grep -qE '^[[:space:]]*(//|#)?[[:space:]]*<auto-generated>'; then
block "carries an <auto-generated> marker"
fi
fi
exit 0
Twenty lines, registered once in .claude/settings.json, and the rule stopped depending on anyone's memory. Even the comment inside it is a post-mortem: the first version matched too loosely and locked a hand-written file. The third form is a CI gate, for the cases a hook can't see. The generated OpenAPI contract is committed to the repo, and a CI step regenerates it and fails the build if the result differs from what the PR committed. The agent can't bypass that one, and neither can I. The hook catches the agent at the keyboard; CI catches whatever got past the hook. Every rule in my factory is somewhere on that path from prose to hook to gate, and the ones still in prose are the ones I trust least.
Zakariasson makes a related point about rules files. He calls rules "probably the most misunderstood concept" and says they "should just like emerge dynamically", written when an agent goes off the rails, like a standard operating procedure. Write each rule the day you need it, and the week after, see if you can make it a check instead.
Intake: an issue that can stand on its own
Roberson is blunt about intake: "A blank text box makes a poor front door because it accepts anything." Her small factory starts from a GitHub issue template, so the agent always gets the same fields.
My version is a grooming stage. /groom-backlog reads recently updated issues and judges each one against four gates: a clear goal, concrete acceptance criteria, a location in the code, and no open product decisions. An issue that passes gets the ready-for-agent label. One that doesn't gets a single clarifying comment, and a human answers it. The groomer is told to judge the substance, because an issue with a heading called "Acceptance criteria" and nothing testable under it is the most common way a bad task gets in.
Issues don't only come from people. An hourly sre-sweep skill reads production telemetry, traces a failure to the line of code and the commit that introduced it, and files a top-priority (p0) issue written to pass the same four gates. It never calls the rest of the pipeline. The hand-off is a label, never a call, and the issue is the whole message, which is why it has to stand on its own. I'd give that rule to anyone designing one of these. That hand-off is also the riskiest path in the factory, because production telemetry is text that strangers can write. I come back to it in "What I'd add next".
Plan: look first, and make the plan cheap to reject
App Vitals' lesson series is the most practical teaching on planning I've seen. Their second lesson splits planning into look, design, approve, slice, and names the failure it prevents with a line every agent user will recognise: "Claude finds an issue, it gets really really excited and it opens a PR." The look step makes the agent explore the code (related work in the queue, existing patterns, who depends on what) before it designs anything. They also give a size: "10 to 15 tasks is kind of like a sweet spot." Breaking changes get sliced into add, migrate and remove.
Roberson explains why the human belongs here and not later: "The plan is where judgment is cheapest." She calls it the factory's version of shift left, moving judgment earlier "so bad decisions are caught before they become code."
My planning stage is built on GitHub's Spec Kit, the MIT-licensed toolkit behind the /speckit.specify, /speckit.plan and /speckit.tasks commands. Spec Kit is designed for a human to drive one step at a time. I changed it in two kinds of ways.
The small changes fit it to the pipeline. Spec directories and branches are numbered by the GitHub issue, so specs/<issue>-<slug>/ always traces back to its issue. Each command gained a --yes mode that takes the default, writes it down as auto-selected, and leaves the real decision to a later gate. And the spec template gained a mandatory section where the author has to name the peer handlers, services and DTOs the change should follow. That's App Vitals' look step, made into a form field. It exists to make the author look at prior art before inventing an abstraction the codebase already has.
The big change is that one agent writes the spec, the plan and the tasks. My first version used five agents, one per Spec Kit command, each starting cold. They drifted from each other, so the next stage spent its time finding the drift. Spec Kit's analyze step, I realised, existed mostly to catch drift between artifacts written by separate agents, a failure the split itself created. One agent writing all three files and then checking them against each other is cheaper and more consistent.
Clarifying questions were the other lesson. The planner sorts each open question into high confidence, which it answers itself and records, or low confidence, which goes to a human. On one run that went badly: eight rounds of questions, about 1.3 million tokens, and no code written. The post-mortem fits in a sentence: answering a question manufactured the next one. Now, on resume, the bar for asking narrows to questions whose wrong answer would break compilation, leak data across tenants, ship an insecure default or corrupt stored data. Everything the planner decided on its own goes into the PR body under a collapsible heading that lists the decisions it made without asking. I think of it as the cheap half of oversight. Nobody has to answer anything mid-run, but every judgment call is in front of the reviewer before it merges.
This is where I part company slightly with App Vitals, who are "firm believers that you need to plan in the loop" with a human approving every plan. For a greenfield product I'd agree. In a mature codebase with good grooming, I find most plans aren't worth my attention, and the ones that are announce themselves through the questions the planner can't answer. The test-first rule is the one I don't bend: every task that touches src/ must be preceded by a task that writes its test, and the engine checks the parsed task list for it.
Build: one issue, one worktree, a hard cap
Once a plan exists, the build is the part every demo shows, and to me it's the least interesting part. Roberson says the same: "Every demo shows the execution station." The decisions that matter are about isolation and limits.
Zakariasson prefers a VM per agent, because worktrees share a machine and its databases, caches and services. He's candid that "it is more expensive" and takes much more setup. I use git worktrees, and I've paid for it. The rule that came out of it is in /dev-manager in bold: at most two issues in flight, counted across the whole machine, because concurrent worktrees have filled the disk before. Dispatch also refuses to run with less than 20 GB free. If a lane shows no source change for 90 minutes, a watchdog marks it stalled, frees its slot and leaves the worktree for me to inspect. Before that rule existed, two stuck lanes could hold dispatch at zero forever.
Every agent prompt in the build engine is wrapped so its commands run inside its worktree and nowhere else. Bootstrap creates the worktree from the main branch, copies in the gitignored test configuration, and assigns the issue so a second dispatcher can't pick it up. I learned the "copies in" part the hard way: worktrees didn't get the gitignored hook config, so formatting silently stopped in them and CI failed on encoding.
Model routing happens per phase. The planner, the legacy-parity checker and the reviewer run on Opus, because a wrong plan or a missed finding costs the whole run. Implementation runs on Sonnet, and bootstrap on Haiku. The dispatch loop itself runs on Sonnet too, because a tick is bookkeeping, and paying the top model to re-read its instructions every tick buys nothing. A colleague added an opt-in preset that puts Fable, Anthropic's top-tier model, on the planning and review phases for the issues that deserve it.
Verify: never let the builder grade its own work
Every source I read lands on the same rule, and the phrasing differs only in how blunt it is. App Vitals' third lesson: "if the builder also writes the test and gets it to green, then the builder can cheat." Kelly: "An agent grading its own work will pass its own work, every time." Roberson: "the factory always verifies what the agent reports." App Vitals add the detail that matters most in practice: "Red tests are never weakened to go green."
Every change is reviewed in three places, and none of them is the agent that wrote it: inside the build engine, in a CI review job that reruns on every push to a ready PR, and in a separate /pr-review session that also runs the tests itself.
Inside the build engine, a read-only review agent first runs the deterministic test-parity script (the same one CI runs, and the reviewer is told not to second-guess it), then reviews the diff against the same rubric file the CI review job uses. A separate fixer addresses the critical and high findings or declines them with a reason, and the loop runs at most four times. Anything still open turns the PR into a draft with the findings listed.
After the PR opens, /pr-review runs in a separate session. It splits the review into three parallel passes: correctness and regressions; security, tenant isolation and performance; API contracts and test gaps. Every finding has to carry a file and line, a concrete failure scenario, and evidence, and for any claim about data or runtime behaviour the evidence is the query or command output that proves it. A finding whose evidence doesn't verify is dropped. A real one, with the names changed, looks like this:
path: src/Edi/Exports/GetExportFilesHandler.cs:142
defect: records are marked Sent and committed before the post-processor runs; when it
rejects the batch the client gets a 400 but the records stay Sent, so the next poll
skips them and the invoices never ship
scenario: one invoice in a batch fails the override check → whole batch 400 → every
invoice in it is silently lost
evidence: the SaveChanges at :142 precedes the post-processor call at :158; the handler
test at tests/.../GetExportFilesHandlerTests.cs covers the happy path only
blocking: true (wrong behavior on a production path)
reverses: none
remedy: move the commit after post-processing, or mark Sent only on a 2xx; either way
add a test that fails with the commit in its current place
Nothing in that finding is an opinion. The line numbers can be checked, the scenario can be run, and the test gap can be confirmed by reading one file. That's what "evidence required" means in practice, and it's the difference between a reviewer that finds bugs and one that produces reading material. Only five kinds of finding block a merge:
- wrong behavior or a crash on a production path
- a security or tenant-isolation regression
- data loss or an irreversible write
- a broken published contract
- the PR's primary behavior left unprotected by tests
Everything else becomes a non-blocking follow-up. That list is what made the review loop converge. Without it, every review round could find something new, and a PR could circle between review and fix without ever reaching a verdict. After three needs-work rounds the reviewer stops and hands me a recommendation. The fixer has its own bar: every fix comes with a test that fails when the fix is reverted or mutated and passes with it in place.
The reviewer also runs the full test suite, end-to-end tests included, on the merge of the PR with the current main branch. Never the bare head: a stale head is a tree that will never exist on the main branch, so testing it manufactures failures that vanish on merge. That rule came from a stale branch that threw 18 package-downgrade errors. The end-to-end requirement came from something worse: a PR that merged with 14 failing end-to-end tests, because CI filters them out for speed. Now an ok verdict requires e2e=pass, and it takes 45 to 50 minutes on one machine. It's the most expensive line in the pipeline, and the one I'd keep if I could keep only one.
There's one real disagreement among the sources here. Roberson keeps the builder unaware of the review rubric, on the grounds that "an agent that knows the rubric writes code for the rubric." I do the opposite and use the same rubric in the engine and in CI, so the two reviews agree instead of drifting. My read is that hers is the better design when the reviewer is a model judging taste, and mine works because the rubric's blocking items are mostly things you'd want the builder to aim for anyway. I haven't tested hers.
Ship: one merge path, and a human hand on it
/pr-ship is the only command in the pipeline allowed to merge, and it says at the top that merging is deploying, because the main branch auto-deploys. It runs in shadow mode by default, reporting what it would merge, until I pass --live. It merges one PR per tick, oldest first, because each merge can cause conflicts in the others and /pr-unblock handles them one at a time.
The gates are all mechanical and checked in the same script call as the merge: not a draft, mergeable, CI green, no unresolved threads, and a review verdict of ok with end-to-end tests passed. The verdict can't be a GitHub approval, because the pipeline's PRs are authored by the same account the agents run as, and GitHub refuses self-approval. So /pr-review posts a marker comment that binds its verdict to the exact commit SHA it reviewed. Any push after the review voids it. The ship stage trusts the marker over the reviewed-ok label, because a label proves nothing on its own. The marker is the contract; labels are for people.
The last gate is my merge click. /pr-ship was written to want a code-owner approval on top of the marker, and GitHub won't take one from the account that opened the PR, so for everything the pipeline opens under my name the ship stage reports what's ready and I press merge myself. Of the 227 merges counted below, 215 were mine, and none was automatic. Zakariasson describes Cursor going further, with an agentic code owner that scores each PR's risk, auto-approves the low-risk ones and pulls in past authors on the risky ones. He says their old human code owners were right "like 80% of the time but for these 20% of the time they caused a lot of bottlenecks". Kelly's guide puts a risk analyzer at the front of its PR-to-merge loop too. I understand the appeal. I haven't done it. By the time a PR reaches me it has been reviewed in three places, through a full test run and a mechanical gate check, so my merge is cheap to press, and it's the one gate an agent can't satisfy for itself. Zakariasson draws his own line in the same place I would, keeping humans on security, payments, auth and database decisions: "don't outsource important decisions."
One trap from Roberson's guide is worth checking in your own setup today. Pushes made with GitHub Actions' default GITHUB_TOKEN don't trigger other workflows, so a factory that pushes with it opens PRs that never run CI, the policy gate or the reviewer. She calls it "the difference between a factory with gates and a factory with the appearance of gates."
After the merge: QA, monitoring, and the way back in
Most factory guides stop at merge. Roberson's is the exception: her small factory runs a smoke check against the new revision after merge and opens a revert PR if it fails. Mine goes further after merge, and stops short of reverting.
/qa-focused-test takes an issue number, and the number is required, because which change gets attacked should be a decision someone made, not whatever the board happened to hold when a timer fired. It waits until the QA environment is running a build newer than the merge, replays any saved regression cases for the areas the PR touched, then launches an adversarial agent that tests the way a manual tester with Postman would: real HTTP, no mocks. It goes after tenancy first (can one tenant read another's data?), then state transitions, contract conformance against the published OpenAPI document, and anything that returns a 500. It uses its own limited QA account and logs every write it makes. A defect only counts if it reproduces twice more on a fresh token and a fresh record, because one false defect report costs a human more than three missed ones. Each confirmed defect becomes a permanent regression case.
In production, a release-health skill compares telemetry against measured baselines after each deployment slot swap, the moment a new build takes production traffic, and it can't roll anything back. That's deliberate. I watched a rate-based threshold trip overnight on a long-standing, harmless burst of 401s that only looked like a spike because traffic had fallen. An armed version would have swapped production back over noise, with nobody watching. The reasoning I wrote into it: a missed detection costs minutes of a degraded release, and a false rollback takes a healthy release down. Recommend clearly, escalate loudly, and let a human pull the lever. Roberson's automatic revert PR is a better fit for her case, a small app with a smoke test that's either green or red. Real traffic is noisier than that.
The hourly sre-sweep closes the loop. A production failure becomes a p0 issue, grooming marks it ready, and the factory picks it up like any other. As built, nothing human stands between that telemetry and a builder with push rights, which is the first thing I'd change.
The loop that holds it together
The orchestration is the least glamorous part and the part I'm proudest of. There are four stages after grooming, each its own command, each run under Claude Code's /loop, which reruns a command on a timer:
| Stage | Command | Picks up |
|---|---|---|
| Implement | /dev-manager |
ready-for-agent issues → build engine → PR |
| Unblock | /pr-unblock |
conflicts, review feedback, red CI, draft findings |
| Review | /pr-review |
green CI + unreviewed head SHA → sha-bound verdict |
| Ship | /pr-ship |
verdict ok + green + clean → squash-merge, issue → QA |
No stage calls another. They find their work by labels, marker comments and board columns, and none of them keeps state. Every tick re-derives everything from GitHub and the filesystem, so the loops survive restarts, crashes and machine sleep. I can close my laptop mid-run, and when it wakes the loops pick up where the evidence says they are.
App Vitals make the same choice for the same reason: their loop is deterministic "cuz why burn tokens to do something code can do". I got there slowly. /dev-manager started in August as 19 KB of prose instructions and grew to 41 KB as I added a paragraph after every failure: branch-name normalisation, shell quoting traps, the three possible values of GitHub's mergeable field. In one day I moved all of that into a Node script with unit tests, and the command shrank to 11 KB. Each of those paragraphs was a post-mortem for an error a script cannot make, so they're gone. The model now does only what needs judgment. The script decides what to dispatch.
Two smaller rules in the loop cost me a lot to learn. First, escalations go last. When a run needs a human answer, the manager records the question, schedules its next wake-up, and only then asks, because under /loop there may be no human for hours, and a manager that asks before scheduling its wake-up never schedules it, so it stops for good. Second, the dispatcher must launch the build engine itself and never hand that to a subagent, because subagents can't launch workflows, so a dispatcher moved into a subagent silently stops dispatching.
What 227 pull requests cost
None of the sources I read put a price on their factory, so here is mine. The pipeline numbers come from GitHub, and the spend comes from every Claude Code transcript in the repo between 6 August and 28 October, priced at API list rates.
| Merged PRs through the pipeline | 227 (77, 72 and 78 by month, about 19 a week) |
| Open to merge | median 18 hours; a quarter under 6.5 hours; 63% within a day; 9 took over a week |
| Size | median 1,600 lines changed across 15 files (regenerated contract files inflate this) |
| Review rounds, for the 134 PRs since the SHA-bound verdict shipped on 6 September | 89 passed in one round; 42 got at least one needs-work; 5 hit the round cap and came to me |
| Full suite including end-to-end, run on the merge | 120 PRs carry e2e=pass |
| Sent back to draft by the build engine | 7 |
| Who pressed merge | me, 215; a teammate, 11; someone else, 1 |
| Claude spend at list price | about $2,200 to $2,600 in all, $10 to $11 per merged PR, $180 to $210 a week |
The spend is an upper bound for the factory, because the transcripts include my own hands-on sessions in the same repo. It is also list price, which isn't what a subscription costs. The shape of it is the useful part: 3.45 billion tokens went through, 96% of them cache reads, and only 8.4 million were output. Opus took 65% of the bill, Fable 19% on the issues I routed there, Sonnet 15%, and Haiku a rounding error. A factory is a prompt-caching workload before it is anything else, and the model split is where the next saving is.
The missing row is the one that matters most: defects per merged PR. I have incident counts and QA findings, but not a denominator that would survive a sceptic, and I'd rather give no number than a flattering one.
Where it breaks
This is far from solved. Here's what the sources and my own logs say goes wrong.
Agents fail in ways tests don't catch. One change shipped with passing tests and clean responses: a refactor silently dropped an input across a group of endpoints, every request kept succeeding, and wrong results went out before anyone noticed. The fixes were a contract regeneration step that the agent must read, a dedicated reviewer for that kind of migration, and a monitoring rule that treats new client errors on migrated routes as a lead. The lesson went into the wrap-up command in a sentence: CI catches drift, not wrongness.
Your tests are weaker than you think. App Vitals ran mutation testing on the suite they'd built in their first lesson and reported "our score was 68%". They also point out that the evidence an agent writes into a PR is "self-reporting by the LLM, so the LLM could just hallucinate the evidence." That's why my ship gate checks a marker the review stage wrote after running the tests itself, and never reads the PR body.
The factory needs maintenance. Every rule in my pipeline encodes a past failure, and the list keeps growing. Zakariasson says "storing the context and building the tools and like keeping them up to date is is more important than actually doing the work", and I've found that to be true, sometimes uncomfortably.
The evidence for factories is thin. No source I read gives a defect rate, a cost per merged PR or a controlled comparison. The LeadDev numbers (66% faster time to merge, 81.3% of incidents handled by agents) are a vendor's claims about its own product. App Vitals' 240 PRs in a week is self-reported and told with two slightly different timeframes. My own numbers above say the pipeline runs and what it costs. They don't say how good the code is, and I don't have a number for that.
It's also one person's pipeline. Zakariasson names the problem I haven't faced: on a team, engineers keep their rules to themselves, so each builds a private factory, and he calls it "a human problem and a human change that needs to be made." Mine is checked into the repo, so the team gets it, but it was designed by one person's taste.
And a factory ships wrong code faster when the plan is wrong. Every gate I've described checks that the code does what the issue says. None of them checks that the issue was worth doing.
Building your own
App Vitals end their first lesson with advice I'd repeat: "build your own software factory, own it end to end, don't copy us." Kelly's version is "You build it one production line at a time." Here's the order I'd build mine in if I started again, smallest useful piece first.
- Make the repo verifiable. One command to run it, one to test it, and CI gates for the rules you care about, including one that stops a new dependency until a human has looked at it. If an agent can't prove a change works, nothing downstream can either.
- Write the intake gate. An issue template or a grooming pass with three or four concrete checks, and a label that means ready. Only labelled issues go in.
- Add a planning step that looks first. Spec Kit is a good start. Add a section that makes the plan name the existing code it follows, keep the spec, plan and tasks in one agent, and put test tasks before code tasks.
- Build one issue at a time in a worktree. Get one issue from label to PR reliably before you run two. Then set a concurrency cap and a disk floor before you need them.
- Separate the checker from the builder. A read-only reviewer with a written rubric, a short list of blocking findings, and evidence required for every finding. Then run the tests again yourself, outside the agent, keep some of them where the builder can't read them, and block any diff that edits a test the plan didn't say to change.
- Give the pipeline one merge path, and keep your hand on it. Mechanical gates checked in one place, a verdict bound to the reviewed commit, and a human on the merge button until you have the data to say you don't need one.
- Loop it deterministically. Move every decision a script can make out of the prompt, keep no state outside GitHub, and schedule the next tick before asking any question.
- Add QA against a real environment, then monitoring that files issues. This is where the factory starts catching what its own tests can't. Treat everything monitoring writes as untrusted input: fence raw telemetry as data, and have a human apply the ready label to every issue it files, so nothing a stranger can shape reaches a builder unreviewed.
- Turn every incident into a rule, then into a check. Your factory is the sum of those post-mortems.
You don't need all nine to get value. Steps one, two, five and six on their own, with a human doing the building, would improve most teams' delivery. The agents make the rest of it possible, and the gates make it safe enough to let them run.
What I'd add next
I haven't built anything in this section yet, though the list above already borrows the cheapest parts. After drafting the rest, I went looking for what my pipeline is missing, and these six held up against someone who had measured the problem or broken a system with it. They're in the order I'd do them.
Cut the path from production to the builder. Simon Willison's "lethal trifecta" is an agent with "Access to your private data", "Exposure to untrusted content" and "The ability to externally communicate", and his advice is to "avoid that lethal trifecta combination entirely". My factory has a chain that adds up to it. sre-sweep reads production telemetry, which carries URLs, headers and error text that anyone on the internet can shape. It writes that into an issue, grooming marks the issue ready, and a builder with push rights reads it. Invariant Labs showed how to "hijack a user's agent via a malicious GitHub Issue". The fixes are cheap: restrict sre-sweep to the tools it needs, put raw telemetry strings in a fenced block marked as data, and make every issue it files wait for a human to apply the ready label. OWASP's rule for excessive agency applies to the rest of the pipeline too: "Implement authorization in downstream systems rather than relying on an LLM to decide if an action is allowed or not." My merge gate would still stop a bad change from shipping, but a hijacked builder can do a lot of damage on its way to that gate.
Keep some tests where the builder can't see them. SpecBench measured this directly and found that "every frontier agent saturates the visible suite, reward hacking persists", with the gap between visible and held-out results growing "by 28 percentage points for every tenfold increase in code size". StrongDM's factory keeps its end-to-end scenarios "often stored outside the codebase (similar to a 'holdout' set in model training)". My saved QA regression cases live in the repo, where the builder can read them. Nothing stops a builder from weakening an existing test to make it pass, either. EvilGenie names both moves, "hardcoding test cases or editing the testing files", and found an LLM judge "highly effective at detecting reward hacking in unambiguous cases". So I'd do both: move the QA scenarios out of the builder's reach, and add a blocking review finding for any diff that edits a test the plan didn't say to change.
Measure the factory. Earlier I admitted I don't have a number for code quality, and that's the gap I'd close first. DORA's 2025 report found AI adoption has a "positive relationship" with throughput and still a "negative relationship with software delivery stability". METR's randomized trial is the warning about trusting how it feels: developers forecast that AI would "reduce completion time by 24%", it actually "increases completion time by 19%", and afterwards they still believed it had sped them up by about 20%. I'd track change-fail rate, reverts and rework within 14 days, cost per merged PR and my own review minutes, with agent PRs split from human ones. I'd also log how often I agree with each reviewer's blocking findings, which gives every reviewer a precision score.
Run mutation testing on the diff. App Vitals' 68% says the tests are weaker than they look, and mutation testing is how you make that visible on every change. Meta's ACH generates mutants and then tests that kill them, and engineers "accepted 73% of its tests". For a .NET codebase I'd run Stryker.NET against changed files only, report-only at first, and send surviving mutants back to the builder as "write a test that kills this".
Test the factory's own prompts. My build engine has dry-run tests for its plumbing, but nothing tells me whether an edit to a command makes plans worse. Anthropic's advice on agent evals is that "20-50 simple tasks drawn from real failures is a great start". Past issues with known-good outcomes are exactly that, so I'd replay a set of them whenever a command or skill changes.
Gate new dependencies. Spracklen and colleagues found invented package names in "at least 5.2% for commercial models and 21.7% for open-source models", and an attacker can register a name a model keeps inventing. My codebase already keeps every package version in one central file, so a single CI check on that file can block any package it hasn't seen before until a human approves it.
Two smaller ones are worth a line each. Headless runs should carry turn and spend caps, so a stuck agent costs a known amount. An OS-level sandbox with a network allowlist limits what any agent can reach, and Anthropic reports it "reduces permission prompts by 84%", measured on its own users.
None of these takes the human off the last gate. They make the gates in front of it harder to fool.
Sources
- Alexis Roberson, Build a software factory small enough to understand, LaunchDarkly, 2 October 2026
- Chris Kelly, The engineer's guide to building a software factory, LeadDev, 10 September 2026 (Kelly is head of developer experience at Augment Code, and the page carries an Augment partner block)
- Eric Zakariasson, Building your own software factory, AI Engineer, 28 April 2026
- App Vitals, How to Build Your Own Software Factory, Lesson 1: Plan, Execute, Loop, 17 October 2026
- App Vitals, Lesson 2: A Plan That Looks First, 23 October 2026
- App Vitals, Lesson 3: Done Means Checked, 30 October 2026
- GitHub, Spec Kit, MIT licence, and its command reference
- Simon Willison, The lethal trifecta for AI agents, 16 June 2025
- Invariant Labs, GitHub MCP exploited: accessing private repositories via MCP, 26 May 2025
- OWASP GenAI Security Project, LLM06:2025 Excessive Agency
- Bingchen Zhao et al., SpecBench: Measuring Reward Hacking in Long-Horizon Coding Agents, preprint, 20 May 2026
- Justin McCarthy, Software Factories and the Agentic Moment, StrongDM, 6 February 2026
- Jonathan Gabor et al., EvilGenie: A Reward Hacking Benchmark, preprint, 26 November 2025
- Google Cloud, Announcing the 2025 DORA report, 23 September 2025
- Joel Becker et al., Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity, METR, 12 July 2025
- Christopher Foster et al., Mutation-Guided LLM-based Test Generation at Meta, 2025
- Anthropic, Demystifying evals for AI agents, 9 January 2026
- Joseph Spracklen et al., We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs, USENIX Security 2025
- Anthropic, Making Claude Code safer with sandboxing, 20 October 2025