Section650

Writing

TopicAI
Reading8 min

How to Start an AI Software Factory

Make the repository safe for an agent before you automate anything. A readiness check, how to pick the first kind of ticket, the repository instructions to write, a run log, the guardrails, the first automated trigger, and when to stop.

By Ka Lun Chan · AI / Delivery

How do you start an AI software factory?

Make the repository ready before you automate anything: one trusted validation command, a green main branch, no known flaky tests, and branch protection with a human review. Then pick one small kind of ticket, write repository instructions, and run the agent by hand while you log every run. Automate a single trigger only when the log shows it works.

A software factory, as I described in the AI software factory, takes a ticket through to an approved pull request using coding agents inside the checks and approvals a team already has. The factory stack covers the layers and the governance. This post covers the part before both: getting from nothing to a first pilot without automating a mess.

Three things decide whether that first pilot teaches you anything:

  1. The agent can only be as reliable as the checks it runs, so the repository comes first.
  2. A narrow, repetitive kind of ticket gives you enough runs to compare and a small blast radius when one goes wrong.
  3. Running it by hand first shows you where it fails while a person is still watching every step.

Is your repository ready for a coding agent?

It’s ready when a single command tells you whether a change is acceptable and you trust the answer. An agent leans on that command far more than a person does, because it has no other way to know it’s finished.

Fig. 751-1 Readiness check before an agent touches the repository
CheckWhy the agent needs itA quick test
One trusted validation commandThe agent needs a single, unambiguous definition of “done”A new developer can run it on day one and believe the result
Main is greenA red build hides whether the agent broke somethingThe last ten runs on main passed
No known flaky testsAgents retry on red, so a flaky test burns attempts and moneyNothing on the team’s “just rerun it” list
Tests cover the target areaChecks are the only thing standing between a plausible change and a wrong oneBreaking the code on purpose fails a test
Tickets have acceptance criteriaThe agent builds what the ticket says, which may not be what you meantSomeone else could verify the ticket without asking you
Branch protection and reviewNothing reaches main without a person approving itA direct push to main is rejected
No secrets in the repo or environmentWhatever the agent can read, it can leak or misuseA clean checkout runs without production credentials

The first row matters most. On this site, that command is npm run validate: it runs the tests, builds every page and runs the SEO and writing audits. When an agent works on the site, “done” means that command passes, and the review starts from there. Without one command, each agent run decides for itself which checks count, and the results aren’t comparable.

Fixing the rows that fail is useful work even if you never start the factory. Every item in that table also makes the repository easier for a new developer.

Which tickets should a software factory start with?

Small, frequent, well-tested changes with a clear definition of done and little damage if they go wrong. Bug fixes with a reproduction, flaky-test fixes and minor dependency updates are typical first candidates.

The criteria are more useful than the examples, because every codebase has different easy work:

  • The ticket states what should be true afterwards, ideally as acceptance criteria a test can check.
  • The change is usually small and stays inside one area of the code.
  • Tests already cover that area, so a wrong change fails loudly.
  • It comes up often enough to give you a dozen or more runs within a few weeks.
  • If it goes wrong after merge, a revert fixes it and nobody calls it an incident.

Leave authentication, payments, data migrations, infrastructure and anything without tests for later. An agent can work on those areas, but a first pilot should teach you how the workflow behaves, and there every failure is expensive.

What should the repository instructions say?

How to install, test and validate the project, the conventions reviewers enforce, what the agent must not touch, and what to do when a check fails. Keep it short and specific, and grow it from real review findings.

Claude Code and Codex both read an AGENTS.md file in the repository (Claude Code, Codex). A starting version for a typical web project might look like this:

AGENTS.md (illustrative)
# AGENTS.md (example)

## Commands
- Install: npm ci
- Validate before every commit: npm run validate
  (lint, unit tests, build and audits; a change is done only when this passes)

## Conventions
- One ticket per branch and pull request. Keep diffs under ~300 lines.
- Follow the existing patterns in the folder you're changing.
- Add or update a test for every behavior change.

## Don't touch
- migrations/, infra/, .github/workflows/, anything under auth/ or billing/
- Lockfiles, unless the ticket is a dependency update

## When a check fails
- Fix the cause, not the test. Never skip, delete or weaken a test.
- After three failed attempts, stop and write up what you tried.

This site’s own AGENTS.md is mostly editorial rules plus the instruction to run npm run validate after content changes. That’s the pattern I’d copy: the rules your reviewers keep repeating, written down once. When a review finds the same mistake twice, add a line. When a line stops being relevant, remove it, because a long file of stale rules dilutes the ones that matter.

Why run the agent by hand first?

Because the failures you need to see show up in the transcript, and a pull request only shows the result. A developer who starts each run, reads it and logs the outcome finds the missing instructions, weak tests and vague tickets before automation hides them.

Give each run its own Git worktree so the agent’s changes never mix with anyone’s working copy. That’s how agent work on this site runs, and it removes a whole class of “what changed my files?” confusion. Then log every run, including the ones that fail:

Run log (illustrative)
ticket | attempts | checks passed | human edits | review minutes | cost | outcome
-------|----------|---------------|-------------|----------------|------|--------
BUG-412|    1     |     yes       |    none     |       6        | ...  | merged
BUG-415|    3     |     no        |     -       |      15        | ...  | escalated: missing repro
BUG-418|    2     |     yes       |  1 line     |      11        | ...  | merged

Those columns map onto the six measures in the AI software factory, so the log you keep by hand becomes your baseline later. Record the human review time honestly. A run that produces a pull request in four minutes and takes forty minutes to review isn’t a saving.

Read the failed runs most closely. Each one usually points to something fixable: a missing command in AGENTS.md, a test that doesn’t cover the bug, or a ticket that never said what done looks like.

Which guardrails need to be in place before you automate?

Least-privilege credentials, an isolated place to run, a limit on attempts and cost, and a rule that nothing merges without a person approving it. Once runs start without someone watching, these are what contain a bad one.

  • Give the automated run a token that can open pull requests and nothing more. GitHub’s GITHUB_TOKEN permissions can be narrowed per workflow.
  • Keep production credentials out of the environment the agent runs in.
  • Protect the main branch with required status checks and a required review, so the agent can’t merge its own work.
  • Cap attempts per ticket and set a spending limit per run, then escalate to a person when either is hit.
  • Use a separate reviewer, another model or a person, so the same agent isn’t grading its own work. The Claude and Codex review workflow I proposed pairs two models for that reason.

The factory stack post goes through seven governance gates in detail. For a first trigger, the list above is the minimum.

What should the first automated trigger be?

One label on one kind of ticket that starts the agent in CI and ends with a pull request waiting for review. Everything after the pull request stays manual.

With GitHub, that’s a workflow that runs when someone adds a label such as agent-ready to an issue. Anthropic documents a Claude Code GitHub Action for exactly this, and the factory stack post includes its minimal example. The person applying the label is making a judgment call: this ticket is the right kind, and its acceptance criteria are clear.

Keep the manual log going for the automated runs. The trigger changes who starts the run, and you still need the same record of what happened.

When should you expand the factory, and when should you stop?

Add a second kind of ticket only when the first has held steady for several weeks on review time, rework and cost. Pause when reviewing the agent’s work takes longer than doing it by hand, or when merged changes keep being reworked.

Signs it’s working: most pull requests pass every check on the first or second attempt, reviewers rarely edit the code, nothing it merged has been reverted, and the team trusts the label enough to use it without discussion.

Signs to stop and fix the harness: the same kind of mistake keeps coming back, reviewers are rewriting changes after approval, escalations pile up, or the cost per accepted change keeps rising. Automating more won’t fix any of those. Better tests, clearer tickets or a different kind of ticket will.

Either way, the readiness work in the first table pays off. A repository with one trusted check, reliable tests and clear tickets is faster for people too, whether or not the factory grows.

Sources

Tool documentation was checked in November for the factory stack post. The readiness check, the ticket criteria, the example files and the opinions are mine, and the descriptions of this site’s setup come from its own repository.

Short answers

How do you start an AI software factory?

Make the repository ready first: one trusted validation command, a green main branch, no known flaky tests and branch protection with human review. Then pick one small kind of ticket, write repository instructions, run the agent by hand for a few weeks while logging every run, and automate a single trigger only after the log shows it works.

What tickets should an AI software factory start with?

Small, frequent, well-tested changes with a clear definition of done and a small blast radius, such as bug fixes with a reproduction, flaky-test fixes or minor dependency updates. Avoid authentication, payments, data migrations and anything without tests for the first round.

What should go in AGENTS.md for a factory?

The commands to install, test and validate the project, the conventions reviewers enforce, the directories and files the agent must not touch, and what to do when a check fails. Keep it short and specific, and add a rule each time a review finds the same mistake twice.

When should you stop or pause a software factory pilot?

When reviewing the agent’s pull requests takes longer than doing the work by hand, when changes keep being reworked or reverted after merge, or when the cost per accepted change keeps rising. Fix the harness or pick a different kind of ticket before automating more.

Start with the command

If your team can’t name the one command that says a change is ready, write that first. A software factory is built on it, and every developer on the team benefits before an agent ever runs.

How I lead engineering teams