AI-tooling

Is your codebase ready for an AI software factory? Three checks before agents open pull requests

Blazity team

10 min. read

Your codebase is ready for an AI software factory when an agent can build and test it where the factory runs and loads your instructions. A failing required check must also stop its change from being merged. If one is missing, the work stalls, someone fixes it by hand, or the problem gets merged.

What does an AI software factory add to a coding agent?

An AI software factory adds stations around the step in which a coding agent writes code. Each station has a condition the work must meet before it moves on. An AI software factory is a set of repeatable workflows, called lines here. In each line, agents take a ticket to a pull request, and machine checks decide whether it may be opened. A person reviews and merges it.

The stations before the pull request exist because a diff on its own says little about how it was made. Take a ticket asking for a CSV export on the orders page that does not name the columns. If the line makes the agent ask at Clarify, the run waits. The agent's stated assumption then shows whether it read the ticket as the team did. Plan then shows how it intends to change the code, and Check runs the repository's scripts, which catch what the tests cover. Without Clarify, the columns may be wrong, and the first to catch that is the reviewer before merge, after a full build.

The stations follow the line in AI Workflow, Blazity's open-source software factory. Merge is added because AI Workflow leaves merging to a person. A problem is caught at the first station whose condition it fails.

StationWhat happensPasses when
IntakeA ticket enters the lineThe ticket states acceptance criteria
ClarifyThe agent asks what the ticket leaves open and states its default assumptionA person has answered on the ticket
PlanThe agent writes what it will change and how it will test itA person approves, where the line requires it
BuildThe agent changes the code in an isolated environment without production accessThe change builds
CheckThe line runs the repository's scripts and any review agents before opening a pull requestAll of them pass
DeliverThe line opens a pull request and updates the ticketThe pull request carries the results
ReworkReview comments and failing checks go back to an agent, which pushes fixes to the same pull requestThe line's scripts pass and, where the branch requires it, a person approves the latest commit
MergeA person reviews and mergesThe branch's required checks pass and a person approves

The three readiness conditions act at specific stations. Build and Check need an environment where the agent can build and test the code. Every agent step depends on the instructions it loads, and Merge depends on checks the branch enforces. Review comments and failing checks on an open pull request skip Intake, Clarify and Plan and go straight to Rework.

If a station's pass condition amounts to "the code looks right", keep a person there and record their decisions until the condition becomes clear. If agent pull requests already stall in review, Blazity's Delivery Review can help. It is part of the AI Software Delivery service and looks at where that work stalls and which decisions need an engineer.

Can an agent build and test your repository where the factory runs it?

It can if everything the run needs, from a fresh clone to passing tests, comes from the repository or the line's environment. No manual step may be needed in between.

Write down that environment first: image, reachable hosts, services, secrets, and what it must never reach, starting with production. Then:

  1. Start it exactly as the line would, from a fresh clone of the default branch, with no caches.
  2. Run only the documented commands for setup, build and tests, and record each exit code.
  3. Note every manual step you needed, such as a VPN, a seeded database or a colleague's variable.
  4. Turn each item into a script or a documented step, or keep tickets that touch that area out of the line.
  5. Repeat the run with production hosts blocked. A test that fails only then depends on production.
  6. Revert a recent bug fix and run the suite again. Something must turn red, or the tests would not catch a wrong change either.

If an integration test needs a staging API reachable only over a VPN, the agent sees a failure it cannot fix. Depending on the agent and the line, it may report the failure, skip the test or mock the call. It may also mark the test flaky or change it until it passes. All but the first can look like a fix.

Parallel agents that share a database or port can break each other's runs; Git worktrees are not enough explains how to separate them. The decision rule: the line takes only tickets whose tests pass in this environment.

What should agents read before they change your code, and how do you know they read it?

Agents should read a short instructions file with the commands, the boundaries and the team's vocabulary. Confirm that your tool loads it, because tools differ in which files they read and when.

The following test covers files loaded when a session starts, which is why it uses the root file. Run it in the directory where the line starts the agent:

  1. Add one line to the root instructions file with a string that appears nowhere else, for example Sentinel: 7f3a-orders-check.
  2. Start a new session and, before the agent reads any file, ask it for the sentinel value.
  3. Check the transcript. The answer counts only if the agent did not open the file to find it.

If the agent cannot answer, a session started this way, on this tool version and with these settings, did not load the file at start.

Claude Code lists the instruction files it loaded under Memory files in /context all, and an AGENTS.md it reads directly in /memory, per its documentation.

For Codex, its documentation suggests running codex --ask-for-approval never "Summarize the current instructions." from the repository root.

Anything a linter or test can enforce belongs in a check, which fails the run, rather than in an instruction the agent may skip. Keeping an inventory of instruction files, each with an owner and a review, is covered in agentic context engineering.

Which checks should block an agent's pull request?

On GitHub, an agent's pull request should be blocked by the same checks that would block a person's. The line runs them before it opens the pull request, and the branch requires them before merge. Among checks, only those the branch requires stop a merge. One that turns red and stops nobody is information, not a gate, as the AI governance maturity model also argues about evals.

A required check is a gate only when it runs on every pull request and delivers a real verdict. Ask someone without bypass permission to merge a deliberately red pull request. That shows that a red check blocks the merge. A documentation-only pull request shows whether the required check still reports a verdict.

Protected branches block a merge until all required status checks pass, and they count a skipped or neutral status as passing. Under classic protection, they do not bind admins unless bypassing is disallowed, as About protected branches describes. A workflow whose checks are required but which path or branch filtering skips leaves its checks pending, and that pull request cannot be merged. A job skipped by a condition, by contrast, reports success for that pull request, according to Troubleshooting required status checks.

To see which rules apply to main:

gh api repos/OWNER/REPO/rules/branches/main

Each entry is an active ruleset rule. Look for one of type required_status_checks that names your CI check. Classic branch protection does not appear in this output.

Example: AI Workflow's own main branch

Blazity's open-source AI Workflow repository ran an aggregate ci job on every pull request, but nothing required it before merge. The fix, recorded in ADR-004, made ci deliver a verdict on every pull request. It runs with if: always(), checks each job's result by name and has no path filter. Since 9 September 2026, a ruleset has required ci on main. This matters because a required check skipped by path filtering stays pending and blocks that pull request.

When can you take a person out of the loop?

You can remove a checkpoint for one line and one type of ticket once an agreed count shows that it no longer changes the outcome. Two of the three human checkpoints qualify. At Clarify, count answers that change the assumption the agent stated with its question. At plan approval, count plans a person edits or rejects. Before the first run, agree on what counts as a change and how many runs the decision needs. For example, a team might drop plan approval for dependency updates after 30 unchanged plans in a row, a number it set beforehand. Count only runs of the current version of the line. A new prompt, model or sequence of steps restarts the count, and one change in the current version means the checkpoint stays. The owner of the code those tickets touch decides, not whoever built the line. They read a sample of approvals first, since zero changes can also mean unread approvals.

Review and merge stay with a person, including on lines where the agent answers review comments and failing checks on its own. On GitHub, two settings help here when the branch requires pull request approvals, as About protected branches describes. "Dismiss stale pull request approvals when new commits are pushed" removes an approval once the diff changes. "Require approval of the most recent reviewable push" requires the latest push to be approved by someone other than the person who pushed it. In a factory, that pusher is often the line's bot or app account. Without either, the person who merges has to check the agent's last fixes themselves. Whether the line pays for itself is covered in ROI of AI coding agents and cost per accepted task.

When is an AI software factory not worth building yet?

When fixing the readiness checks costs more than the line saves, typically when:

  • tickets rarely state acceptance criteria, so Clarify turns into a design discussion;
  • no check blocks a merge, and the team is not ready to make one required;
  • most of the work is product decisions, so most runs would stop at Clarify or Plan;
  • nobody can own a line, its counts and its instructions.

In those cases, fix the ticket template, the test environment and the branch rules first; they help your engineers with or without agents.

Start with one supervised line on one repository

Pick one repository, run the environment test, the sentinel test and a red pull request against it, and fix what fails. Then start a line with every human checkpoint in place and remove one only when the agreed count supports it. The start is slower, and every checkpoint you remove is backed by your own runs.

To find out where agent pull requests stall in review and which decisions need an engineer's attention, talk to Blazity about AI Software Delivery.

FAQ on AI software factory

Does an AI software factory replace CI/CD?

No. Before it opens the pull request, the line runs its configured checks in its sandbox. CI then runs the repository's pipeline on the pull request, and that is what the branch requires. A red CI after a green line means CI ran something the line does not reproduce. Deployment stays in your existing pipeline.

Can an AI software factory work with an existing codebase?

Yes, if the codebase passes the three checks. An agent must be able to build and test it where the line runs. The agent must load your instructions, and the branch must enforce required checks. Where setup depends on manual steps or shared services, the line should take only tickets whose tests pass in the agent's environment.

What is a dark software factory?

A dark software factory ships code that no person has read, and only other machines check it. The term follows Addy Osmani, who calls a factory where a human reads what comes out before it ships a lit factory. StrongDM's CTO, Justin McCarthy, published Software Factories And The Agentic Moment on 6 February 2026. It describes the factory StrongDM built, with the rule "Code must not be reviewed by humans".

Which coding agent should run inside an AI software factory?

Use any agent that runs unattended in your line's environment and loads your instructions file in a way you can confirm. It should also work without production access and exit with a status the line can read. Standardizing the tool is covered in choosing an AI coding harness.

Who should own an AI software factory?

Each line needs a named owner, usually an engineer on the team whose repository it works in. The owner keeps the line's instructions and scripts in step with the code and reads failed runs and reviewer comments. They also decide which tickets the line may take.

Sources

TABLE OF CONTENTS