dotFactory

Software factory patterns for running AI coding agents

By Simone Mosciatti

Software factory patterns are the small, repeatable rules around AI coding agents: triage, locks, honest tests, review, gates, and merges pinned to a commit. This series walks through them one at a time, with a dotFactory snippet for each.

Why is the agent the easy part?

Getting an AI coding agent to write a patch is no longer the hard bit. The hard bit starts when that patch shows up as a pull request.

  • Is CI green?
  • Is this a typo in a README or a rewrite of the auth check?
  • Should it merge on its own, wait for a person, or just sit there with a comment?
  • If two agents grab the same issue, or the coding agent can edit the acceptance tests, how much is that green build worth?

If your agents already open more pull requests than you can review, this is the toolkit for handling them without reading every diff. dotFactory runs these patterns from one .fct file you own.

Most teams answer these questions by hand, in their heads, a few dozen times a week. A software factory is what you get when you write those answers down and let a platform run them the same way every time.

The nice thing is that the answers repeat. The same shapes show up in factory after factory: sort the incoming work, lock what you're working on, check CI, send risky changes to a person. Those are patterns, in the old design-patterns sense. You pick the ones you need and wire them together.

Where does dotFactory fit?

dotFactory runs these patterns from one .fct file you own, whether on hosted infrastructure or with compute in your own AWS account.

Your GitHub Actions workflows can keep running the tests. The factory reads the result and decides what happens next.

What counts as a software factory pattern?

For this series, a pattern is a small piece of the flow with a clear job, a clear trigger, and a clear result. Each post in the series follows the same shape:

  • The problem. What goes wrong when you don't have the pattern.
  • The pattern. How it works, in plain words.
  • When to use it, and when to skip it.
  • A dotFactory snippet. A short .fct file you can read and adapt.
  • A short FAQ. Real questions, short answers.

The snippets use the open .fct format. If you read Put your software factory in a file, you'll feel right at home. Triggers start Runs, steps do work, typed ports carry data between them, and when: guards decide which steps run.

What are the patterns, and which one solves my problem?

We've split the fifteen patterns into four groups, and each group starts with the problem it solves. Jump to the one that sounds like your week.

Getting work in: how do you stop agents from colliding?

These patterns give every piece of work a first look and lock it before an agent starts. You need this group if tickets pile up unsorted, or two agents keep grabbing the same ticket.

  • Pull request triage. Every new or updated PR gets a first look from an agent, which labels how big and how risky it is. That label drives everything downstream.
  • Issue to pull request. An issue opens, an OpenCode agent writes the change, and a PR appears for review. The classic factory loop, and where most people start. Growing a software factory tells that story.
  • Lock what the agent is working on. Before an agent starts, it takes a lock on what it will touch: a GitHub issue, so two agents don't grab the same ticket; a shared staging or test database; even a CI runner or environment. The factory holds a lease for the work and releases it when that work is done.

Deciding what happens next: who signs off on code an agent wrote?

Let low-risk changes that pass CI merge on their own, and stop the risky ones for a person. You need this group if agents open more PRs than your team can review. We wrote about that question in Who signs off on code an agent wrote?

  • Risk-based review routing. The one we're most excited about. Low-risk changes that pass CI can merge on their own. Changes that need a real review either pause at a human gate or stay open with a comment explaining why.
  • CI-gated auto-merge. Only merge after CI has finished and passed, and only the exact commit that was checked. The trick is knowing that a ci_status read doesn't wait for CI to finish.
  • Human approval gate. A kind: gate step that pauses the Run until a person fills in a form. Simple to describe, easy to get wrong with timeouts and stuck approvals.
  • Adversarial reviewers. A second agent reviews the change, prompted to find problems or break the work, preferably with a different model. It comments or requests changes. It never merges.
  • Hold and kill switch. Anyone can add a :hold to a review and github_merge refuses. Useful when you want a brake that doesn't live in the agent.

Agents working together, honestly: can you trust a green build?

Keep the coding agent away from the tests that judge its work, and make agents hand each other answers you can check. You need this group if you're not sure a passing build means the change is good.

  • Typed handoffs between agents. One agent hands the next a value with a declared shape, like { needs_review: bool, reason: text }, instead of a paragraph the next step has to parse.
  • Keep acceptance tests away from the coding agent. At least the UAT or acceptance tests. If the coding agent can see and edit them, it can game a green build. A later, separate step owns and runs those tests, often with a Docker workdir (RepoMount include and exclude) so the coding agent never sees them.
  • Fan-out and fan-in. Several adversarial reviewers look at the same change in parallel, say one for security and one for tests, and a final step combines what they found.
  • Retry and repair loop. Tests fail, the agent gets the failure, fixes the patch, and tries again, with a limit on attempts.
  • Cheaper models in a loop. Don't start with the expensive frontier model. Let a cheaper one generate, get checked, and retry with feedback, and escalate only if that loop is exhausted.

Keeping the floor tidy: what happens to the PRs nobody closes?

Have a scheduled agent revive or close the PRs your factory left behind, and keep a record of what every agent step was asked and answered. You need this group if agent PRs pile up and go stale, or you can't tell what an agent was asked when something odd happened.

  • Monitor, revive, or clean up agent PRs. A scheduled agent watches the open PRs your factory left behind, revives the ones worth keeping, and closes the abandoned ones and their branches. The same timer can pick up small chores, like dependency bumps.
  • Audit trail of LLM inputs and outputs. Every Run keeps what each step received and what it produced, so you can see what the agent was asked and what it said back.

Which pattern should you start with?

Start with the one pattern that matches the problem you have today.

  • Your agents already open PRs. Start with risk-based review routing, so low-risk changes merge on their own and the rest wait for a person. For anything that doesn't auto-merge, an adversarial reviewer is the natural next step.
  • You're starting from zero. Start with issue to pull request, plus a lock on the issue so two agents don't take the same ticket. The repair loop comes close behind.
  • You don't trust the green build. Start by keeping acceptance tests away from the coding agent, so a passing build actually means something.

Pick your pattern, copy its snippet into a .fct file, and run it on dotFactory. The Getting started guide walks you through your first factory.

Frequently asked questions

What are software factory patterns?

Software factory patterns are repeatable ways to organize the work around AI coding agents: how a change gets triaged, locked, checked, reviewed, approved, and merged, and how leftover PRs get revived or cleaned up. Each pattern solves one small problem. A factory is usually a handful of them wired together.

What's the best way to manage pull requests from AI coding agents?

The best way is to write down the rules for what merges on its own and what waits for a person, and let a platform apply them the same way every time. In practice that means triaging each PR, auto-merging only the low-risk ones that pass CI on the exact commit that was checked, and sending the rest to a human gate or a reviewer.

Software factory platform or GitHub Actions?

Use GitHub Actions for CI/CD: builds, tests, and deploys. Use a software factory platform like dotFactory for the decisions around the agent: when it works, what gets reviewed, and what merges. We compare the two in dotFactory vs GitHub Actions for AI agent workflows.

Do I need every pattern?

No. Most teams start with one or two. If agents already open pull requests for you, risk-based review routing and CI-gated auto-merge pay off first, because they decide what lands without you. Adversarial review, locks, and keeping acceptance tests out of the coding agent's hands are what keep that automation honest.

What is the difference between a software factory and CI/CD?

CI/CD builds and tests a change, while a software factory sits around that and decides what happens to it.

CI/CD Software factory
Main job Builds and tests a change Decides when agents do work and what happens to their changes
Reads the CI result Produces it Uses it to route the change
Review and merge Usually left to people or branch rules Routes the change to a person or to an automatic merge
Record Build and test logs What each agent step was asked and what it produced

Can I self-host dotFactory?

No. dotFactory is a hosted service, and the platform isn't open source. You can run the compute in your own AWS account, and the .fct specification is open if you want to implement a different platform yourself.

Portrait of Simone Mosciatti

Written by

Simone has spent more than 10 years building software, from research at CERN to big tech at AWS and fast-growing startups like Rippling. These days he's building dotFactory, because he thinks writing software should feel a lot more like running a well-oiled factory.