The agentic software factory: Building the floor

The agentic software factory: Building the floor

Part 2 of 5: The Agentic Software Factory


In Part 1 I laid out the premise: humans own intent and design, agents own throughput, and the factory is the set of stations and checks that connects the two. That is a nice paragraph. Nice paragraphs have never once shipped software. This post is the part where we pour the concrete.

The steps below are in the order I actually do them, and the order matters. Every team I have watched try this out of order ends up with fast agents producing fast inconsistency, because they automated the line before the line existed. Automating chaos just gets you chaos with better uptime.

Step 0: Pick one repo and one kind of work

Do not start with the whole organization. I know. The slide deck says “enterprise-wide transformation.” Ignore the slide deck.

Pick one repository that matters, has a reasonable test suite, and has a team that actually wants this. Then pick one class of work to run through the factory first. Bug fixes with a reproduction are a great start. So are small, well-understood features like “add a field end to end” or “add an endpoint that follows the existing pattern.”

The goal of the first few weeks is not throughput. It is finding out where your line leaks.

Step 1: Make the repo bootable

An agent cannot verify anything it cannot run. Before anything else, the repository needs a single, documented, boring way to install, build, test, and run the application locally. If a new human hire needs a Slack thread and a senior engineer’s afternoon to get a passing test run, an agent is going to burn an hour of tokens rediscovering the same tribal knowledge, and then guess. Confidently.

I wrote a whole post on agent-ready local environments, so the short version here:

make setup     # dependencies, local services, seed data
make test      # the fast suite, under a couple of minutes
make check     # lint, types, format, the stuff CI will yell about
make run       # the app, on a port you can configure

Whatever your stack calls these, they need to exist, work from a clean checkout, and be the same commands CI runs. If they are not the same commands CI runs, the agent will pass locally and fail in CI, and you will spend your review time on the difference. Ask me how I know.

Step 2: Write down the context

This is the step people skip, and it is the one that makes the biggest difference to consistency. Agents start every session with no memory of your team. None. Whatever they need to know about how you build software has to live in files they will read.

I have been on about this for a while: AI is forcing docs to finally grow up, and the teams that treat documentation as a product are the ones whose agents behave. Turns out writing things down was a good idea all along. Who knew. (Everyone. Everyone knew.)

I keep four kinds of context:

  • An agent guide at the root. AGENTS.md, CLAUDE.md, or whatever your tooling picks up automatically. Keep it short. What the system is, how to run it, the five or six rules that get broken most, and pointers to everything else. If it is longer than a couple of screens, agents and humans both stop reading it carefully. Humans just stop sooner.
  • Conventions with reference implementations. “Use the repository pattern” is weak. “New repositories look like src/orders/OrderRepository.ts, including how errors are mapped and how tests are structured” is strong. Point at real code. Agents copy examples far more reliably than they follow prose.
  • Architecture decision records. Short documents that say what was decided, why, and what was rejected. These are what keep an agent from “helpfully” introducing a second HTTP client or a shiny new state management library. If your team does not write ADRs, start with the three decisions you have had to re-explain most often. You know the ones.
  • A domain glossary. The words your business uses, what they mean, and which ones are easy to confuse. “Account” versus “customer” versus “tenant” causes more agent mistakes than any language feature ever will.

I like keeping the cross-repo parts of this in a notes repo for shared project context and the repo-specific parts right next to the code.

Step 3: Define the unit of work

Every task that enters the factory needs the same shape. I use an issue template along these lines:

## Goal
One or two sentences. What is true when this is done?

## Acceptance criteria
- Observable behaviors, each one testable.

## Scope
- Paths, modules, or contracts this task may change.

## Out of scope
- Things that look related and must not change.

## Decisions that apply
- Links to ADRs and conventions.

## Stop condition
- When to stop and ask instead of continuing.

This is the input spec for the build station. It is also a gift to the human reviewer, who now knows exactly what they are checking the diff against instead of reverse-engineering intent from the code. Most of the time an agent can draft this from a rough request and a human tightens it. That draft-then-approve pattern is the ask, plan, confirm loop applied at intake, and a close cousin of the chat-first spec method I wrote up last year.

If a task cannot be written in this shape, it is not ready for the factory. Send it to a human for design, or split it. “Make checkout better” is a wish, not a task.

Step 4: Isolate every writer

Each implementer agent gets its own workspace: its own worktree or clone, its own branch, its own ports, and ideally its own database or schema. Shared mutable state between parallel writers is where most of the confusing failures come from. Two agents pointing tests at the same local database will each conclude the other one’s data is a bug, and then they’ll both “fix” it. Delightful.

Isolation also means scoping. The task’s “Scope” section in Step 3 is not decoration. In Part 3 we will have the harness enforce it, but even before that, it tells the reviewer what a suspicious diff looks like.

Step 5: Build the gates

Gates are the checks a change must pass to move to the next station. They need two properties: they run automatically, and they cannot be talked past. Not by the agent, not by a deadline, not by “it’s just a one-liner.”

I split them into two tiers:

  • The fast gate runs inside the build station, as often as the agent wants. Format, lint, type check, and the unit tests for touched modules. Under a couple of minutes. This is the agent’s own feedback loop, and the faster it is, the less the agent guesses.
  • The full gate runs before a change is handed to review. The whole test suite, integration and contract tests, a dependency and secret scan, a build of the deployable artifact. This is the same thing CI runs.

Then add the checks that encode design, not just correctness. These are the ones that hold consistency at scale:

  • Contract tests for every API and event other code depends on, so a “small refactor” that changes a response shape fails loudly instead of in production.
  • Architecture tests where your stack supports them, like “the domain module does not import from the web module.” Cheap to write, and they catch a whole category of agent drift.
  • Migration checks that run schema changes forward and back against a copy of realistic data. Agents have a well documented fondness for the destructive change at 2:13AM. Gate it.

A test an agent wrote and then quietly deleted is not a gate. The gates live in the repository and in CI, and changes to them get the same human approval as changes to a contract.

Step 6: Define the stations as files

This is where it starts feeling like a factory. Each station gets a definition: what it receives, what it does, what it produces, which tools it may use, and when it stops. I keep these in the repository so they are versioned and reviewed like code, because they are code. Just written in English.

.factory/
  stations/
    intake.md        # turn a request into a scoped task
    planner.md       # turn a task into an approved plan
    implementer.md   # build one slice in an isolated workspace
    reviewer.md      # read a diff against plan + conventions
  gates/
    fast.sh
    full.sh
  register.md        # who is working on what, right now
AGENTS.md
docs/adr/
docs/conventions/

A station definition is short. Here is roughly what my reviewer looks like:

# Reviewer station

Input: a branch, the task issue, the approved plan.
Read: AGENTS.md, the ADRs linked in the plan, docs/conventions/.

Do:
- Compare the diff to the plan. Flag anything outside Scope.
- Check new code against the reference implementations.
- Check tests cover each acceptance criterion.
- Report findings with file and line, severity, and the rule broken.

Do not:
- Edit code. A fix is a new implementer task.
- Approve. A human integrates.

Output: a review report on the pull request.

Notice the reviewer does not fix things. Keeping the writer and the checker separate is the whole point of a second station. If the reviewer fixes things, you have one agent with extra steps and a fancier name.

Step 7: Give each station the least it needs

The planner needs to read the code and the docs. It does not need to write files or run migrations. The reviewer needs to read a diff and maybe run the tests. The implementer needs to write inside its workspace and run the gates. Nobody in the line needs production credentials. Nobody. Not even “just for this one debugging session.”

Write these permissions down per station. Right now they are policy. In Part 3 the harness turns them into enforcement, which is a much stronger guarantee than “the prompt said not to.”

Step 8: Keep a register

The last piece is a visible list of what is in flight: task, station, owner, workspace, the paths and contracts it owns, state, and the next decision. I described this in the post on keeping long-running agents on track. A markdown table in the repository works to start. A label scheme on your issue tracker works too. The point is that anyone, human or agent, can answer “is somebody already changing the orders contract?” before starting, not after the merge conflict.

Step 9: Run it by hand for a week

Here is the step that feels slow and saves the most time. Before automating anything, run the line manually. A human picks a task, starts a planner session with the station definition, approves the plan, starts an implementer, runs the gates, starts a reviewer, and integrates. Like an animal.

You will find out fast where it leaks. The conventions doc is missing the thing every agent gets wrong. The fast gate takes eleven minutes. The issue template has no place for “this endpoint is called by the mobile app, which we cannot redeploy for two weeks.” Fix the line each time. That is the Learn station doing its job before the factory even has a conveyor belt.

Where we are

At this point you have a factory floor: a bootable repo, written context, a standard unit of work, isolated workspaces, gates that cannot be skipped, station definitions, permissions on paper, and a register. Agents can run in it. Humans are still turning every crank.

Tomorrow in Part 3 we add the piece that turns stations on paper into stations that actually behave: the agentic harness. Then on Monday, in Part 4, we make the whole thing start up on its own.