Building a Software Factory With Claude Code
Introduction
I ran every step of my Claude Code workflow by hand. The social broadcasting feature in the Codyssey backend took three review rounds and 19 fix commits that way. The og_image bug in it passed every gate, a gate being a check command that has to exit 0 before the next step, such as Pint for formatting or PHPStan for types. I found it only by reading the code, because the field it returned existed nowhere in the codebase.
So I built a software factory: a loop where agents take a labeled GitHub issue to a merged pull request, and I step in at five points, which I call stops. I raised the idea on November 18, 2026, and the first feature went through it and merged on November 19, 2026.
The agent is the easy part. The work is making an unattended run safe to trust: a claim on one issue, evidence from the exact commit, a way to stop and ask, and a decision about where a person still has to look.
What a software factory is
A software factory is a setup where a person supervises the agents instead of typing each command. Mine runs as Claude Code sessions on my Mac. One Claude Desktop scheduled task per lane, a group of repositories (backend, frontend, tools or projects), wakes up every hour, picks up at most one issue and starts a session on it. I planned to run it on a hosted agent service and reversed that the same day, because the gates need a Docker stack that sits on my Mac.
The choice that splits factories is what happens at the end. StrongDM's three-person team lets agents write and test code that nobody reviews. Simon Willison's write-up of their approach quotes the rule "Code must not be reviewed by humans", and describes scenarios stored outside the codebase like a holdout set. I kept five stops where a person looks. Gates catch what someone thought to check, and a factory that removes the reader keeps only those checks.

The diagram has three swim lanes. The first holds what runs once per product: the brief, the domain design, the repository setup and the backlog of issues. The second is the loop that runs per issue: pick up, plan (stop), implement, gates, review (stop on a rule conflict), pull request, then read the diff and merge (stop). The third holds what surrounds every run: the product brain (the product's notes, read before planning and written back after), the rule catalog, the dashboard of what waits on me, the failure simulator (a release gate that replays a bad day) and the build log.
An OpenSpec change is a folder of files in the repo (proposal, design, spec and task list) that the agent writes before any code, so the plan exists as a diff you can read. The Kanon is my own Laravel rulebook, a set of MUST and SHOULD rules for how code gets written, which a separate auditor checks the finished diff against.
The five stops
Each issue pauses at five points.
Stop | When | Why it stays human |
|---|---|---|
Brief and scope | Once per product, and when a phase changes | Scope cuts decide what gets built at all |
Plan | After the OpenSpec change is written and the diagrams are synced, before any code | A wrong plan is cheap to fix here and expensive later |
Rule conflicts | When two project rules disagree during the fix loop | No rule says which one wins |
ADRs | When a decision outlives the change | An ADR is a short dated file that records one decision and its reason. It is never edited afterwards, so I approve it with the diff read |
Read the diff and merge | After the last gate passes | Gates miss things like the |
The brief stop does not apply to an existing issue, so the first run reached four of the five.
The rule conflicts row changed on November 21, 2026. Before that, a conflict between a Kanon rule and a rule in the project's own .ai/rules/ folder was a stop. One backend run stopped on three such conflicts, and I answered "project rules win" each time. A question I always answer the same way is a rule, so I wrote it down: in factory runs, project rules win over the Kanon. The PR's merge assessment, a section at the top of the PR body, lists each Kanon rule the run set aside.
This reverses part of what I wrote in Claude Code Review With a Rulebook and a Separate Auditor. That piece says the Kanon deliberately overrides the host project's conventions, which suits a project of your own. Factory runs now let the project's rules win, and the Kanon fills only what the project leaves out.
Claiming one issue at a time
An unattended run needs to know which issue is its own, and nothing else may touch that issue while it works. I use seven labels for this.
Label | Meaning |
|---|---|
| An issue the loop may take |
| The plan is posted and the run is waiting for me |
| I approved the plan, so the next run implements it |
| The run posted a question with options and stopped |
| A run failed. Pick-up skips the issue until I remove the label |
| A run has claimed the issue |
| The run is waiting for me to read a PR |
Change REPO and run this script to create them.
#!/usr/bin/env bash
set -euo pipefail
# Change this to your repository (owner/name).
REPO="acme/storefront"
gh label create factory --repo "$REPO" --force --description "An issue the loop may take"
gh label create needs-plan-approval --repo "$REPO" --force --description "Plan posted, waiting for the owner"
gh label create plan-approved --repo "$REPO" --force --description "Plan approved, implement it"
gh label create needs-decision --repo "$REPO" --force --description "Question with options, run stopped"
gh label create factory-failed --repo "$REPO" --force --description "Run failed, skipped until the label is removed"
gh label create factory-running --repo "$REPO" --force --description "Claimed by a run"
gh label create needs-pr-read --repo "$REPO" --force --description "Run is waiting for the owner to read the PR"A label alone is not a safe claim, because two runs can read an issue, see no factory-running label and both set it. The claim is a local mkdir of a folder named after the issue in ~/.factory/locks/. mkdir fails when the folder already exists, so of two runs racing for one issue exactly one gets it. The same step sets the factory-running label and posts a comment on the issue. Releasing the claim removes all three, and only the run id that made the claim can release it. This works because one machine runs everything, and a second runner would need a different lock.
A run only claims issues from trusted authors, because it reads the issue body and one of my repositories is public.
The projects lane covers products outside my own GitHub org, and its task is disabled for now. Each wake-up (a tick) first lists the lock folder and ends if its lane already holds a claim younger than 4 hours. That keeps two backend runs from sharing the Docker stack, and two frontend runs from sharing the dev server on port 3000.
Two rules stop a bad run from looping. A lock older than 4 hours means the run died, and its issue is marked factory-failed. Three failed fix rounds on the gates end the same way.
The scheduled tasks do nothing until a file exists, which gives me one switch:
mkdir -p ~/.factory && touch ~/.factory/armedrm ~/.factory/armedEvidence at the head commit, not CI
GitHub Actions never started a job on the first PRs: "recent account payments have failed or your spending limit needs to be increased". On November 20, 2026, I made that a standing rule: "We cannot use GitHub Actions, we don't have enough minutes for it to work reliably." Cloudflare Workers Builds handles deploys.
The local run is the CI. The gates run on the exact commit that was pushed, from a clean tree. The PR records the sha, each check and its exit code. A PR is offered to me for merge only when its head is verified, and a new push needs new evidence. On the first run the record read: Pint, PHPArkitect, PHPStan, 8,622 tests and the API version check, all exit 0 at head 47fed70c1.
Each repository commits a recipe naming its setup and checks. This is the Laravel template's, with {{PRODUCT_SLUG}} filled in when a product's repository is created.
# laravel-template/template/.factory/recipe.yml
version: 1
setup:
- name: build
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml build php
- name: services
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml up -d --wait mysql
- name: install
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml run --rm -T --user "$(id -u):$(id -g)" php composer install --no-interaction --no-progress
- name: env
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml run --rm -T --user "$(id -u):$(id -g)" php sh -c "cp -n .env.example .env; php artisan key:generate --force"
- name: migrate
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml run --rm -T --user "$(id -u):$(id -g)" php php artisan migrate --force
checks:
- name: pint
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml run --rm -T --user "$(id -u):$(id -g)" php composer pint
- name: arkitect
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml run --rm -T --user "$(id -u):$(id -g)" php composer arkitect
- name: phpstan
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml run --rm -T --user "$(id -u):$(id -g)" php composer phpstan
- name: rector
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml run --rm -T --user "$(id -u):$(id -g)" php composer rector
- name: tests
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml run --rm -T --user "$(id -u):$(id -g)" php composer test
teardown:
- name: down
run: docker compose -p {{PRODUCT_SLUG}}-factory -f docker-compose.factory.yml down -v --remove-orphansPHPArkitect enforces architecture rules as tests, and Rector applies automated refactors. On a clean clone of a sample product the checks ran like this:
Check | Time | Exit code |
|---|---|---|
pint | 1.40 s | 0 |
arkitect | 1.11 s | 0 |
phpstan | 3.30 s | 0 |
rector | 3.34 s | 0 |
tests | 1.64 s | 0 |
The gates' evidence now comes from a clean clone of the pushed commit, not from the agent's worktree, its separate working checkout of the repo. The change came from a new product outside Codyssey. A PR there reported "All five recipe gates pass, with 80 tests" from its worktree. A clean clone of the same commit failed with 16 failures and 1 error, because the worktree kept a git-ignored .env that predated a config line the PR added.
An agent that writes code can also write its way past the checks, so one guard watches what the gates depend on. A PR that edits phpstan.neon, the PHPArkitect config, phpunit.xml, the composer scripts or .ai/rules/ is flagged for a careful read even when every gate is green.
For bug fixes, the first commit of the PR is the failing test alone. A gate checks that this commit touches only test files, fails for a real reason, and passes at the PR head.
What the first run asked of me
The first run was the backend issue that exposed an estimated_reading_minutes field on course payloads. It needed me 34 times. That count is 1 manual step (adding the factory label), 3 answers outside questions (swapping the plan label, and two "merge it for me" messages for two PRs), and 30 questions in 11 rounds. The 30 split into 18 at the plan stage, 7 during review, 1 at the ADR stop and 4 at archive. Of the 18 plan questions, 9 came from the OpenSpec draft meeting the code: four of my first design answers did not hold once the agent read the real classes, and I reversed one of them.
The takeaway I logged: "Put the plan's answers against the code before asking for approval, because that is where most of a first run's questions come from and where changing an answer is still cheap."
Later runs are counted the same way. They are different issues of different sizes, and several counts were rebuilt from issue timelines, so read the table as four separate data points.
Run | Date | Manual steps | Answers outside questions | Questions | Total |
|---|---|---|---|---|---|
Reading time on course payloads | November 19, 2026 | 1 | 3 | 30 in 11 rounds | 34 |
Stale lock in the pick-up script | November 21, 2026 | 1 | 2 | 0 | 3 |
Claim killed mid-sweep | November 22, 2026 | 1 | 2 | 10 in 1 round | 13 |
Cache and location data on Worker traces | November 26, 2026 | 1 | 3 | 0 | 4 |
On the stale lock run the plan stage decided its 9 open decisions itself without asking me. On the mid-sweep claim run, the 10 questions were the plan's 10 decisions, asked in one round. All three older runs opened a separate archive PR. Only the Worker traces run's archive PR was merged, so only its count includes that second merge; the other two were closed unmerged as superseded. Since November 29, 2026, the implementation PR archives the plan in its last commit, so each issue needs one merge.
Four failures that became rules
A run that looked finished. The scheduled task showed one run as "succeeded" at 00:36 while its background subagents were still working. The lock and the factory-running label were the only signs the run was alive. The claim script now posts its own run events (claimed, released, and expired from the 4-hour stale sweep) to the dashboard. The rule is that a run's state comes from its claim, not from the scheduler's "succeeded".
Sleep. Ticks went missing overnight. pmset -g log showed that every long overnight sleep from November 15, 2026, to November 19, 2026, was a clamshell sleep on battery, so the Mac skipped the scheduled ticks. The rule is that the laptop stays on AC power with the lid open overnight.
A merged fix that did nothing. I merged a change to the factory's own playbook and nothing changed, because the scheduled task runs the installed copy, not the repository. The rule is that every tick runs an install step first, which copies the playbook, the skills and the task prompts from the main branch.
Gates that had never failed. The Laravel pack's self-test used one product name, "Gate Check", which sorts before Illuminate\. Pint's import-order check sorts the product namespace on a different side of Illuminate\ for each product, so the test never saw it fail, and the next product I bootstrapped got 5 files rejected. The self-test now generates three products whose namespaces sort before and after Illuminate\, and each one has to pass every gate. When I built the Symfony pack, a separate reviewer planted architecture violations, PHPStan type errors and failing tests by hand, and each of those gates caught its violation. A gate only counts once you have watched it fail.
I also ran the factory on a first product outside Codyssey, a small invoice tracker. The brief interview took 4 rounds and produced 11 requirements, and 11 factory issues were filed with dependencies. The gaps it found are being fixed upstream, in the templates and the public rule catalog, so the next product does not repeat them.
What I haven't measured
I measured the start-up load on November 26, 2026: about 79k tokens per session or subagent before any work begins. I filed four cost issues in the factory's public skills repository. The lean session profile, which added the lean factory-shell subagent, cut CLI start-up load for the main session from 70,837 to 47,681 tokens, and for a subagent from 39,099 (general-purpose) to 5,012 (the lean factory-shell). Stage events now carry cost_usd, and I have no run totals yet. Model tiers, which put routine steps on a cheaper model and size the checks to the change, have merged with no measured effect yet.
My own hours are not measured either: the owner counts above count interruptions, not time spent reading.
The strongest argument against all of this comes from Dex Horthy of HumanLayer. Alex Salkever, reporting on his interview with Horthy, sums it up: "One poor decision becomes precedent, and precedent becomes architecture." HumanLayer ran a lightly supervised software factory for three or four months and then archived the whole codebase, 30,000 to 40,000 lines, after leaving questionable code in on purpose to see whether the agents would recover. My stops answer part of that, since a person reads every diff. They do not answer the slow version of the problem, where each merged PR is individually fine and the pattern they set together is not. I have no data on that yet.
Where to start
The smallest piece is a factory label and a plan stop. Label an issue. Let the agent read the codebase, write its plan into the repo and post it as a comment, then add needs-plan-approval and stop. You read the plan, swap the label to plan-approved, and the agent implements it. Add the claim, the evidence and the other stops only after that loop has run on a feature you care about.
If you have not yet run the workflow by hand, start with part 1 of the series: My Claude Code Workflow for Laravel, From Idea to Merged PR.
Related Links
- How StrongDM's AI team build serious software without even looking at the codeSimon Willison on StrongDM's no-review approach, which I chose not to copy.
- Anthropic: long-running application development with agentsAnthropic's planner, generator and evaluator setup, where the evaluator clicks through the running app with Playwright MCP.
- Understanding Spec-Driven-Development: Kiro, spec-kit, and TesslBirgitta Böckeler on spec-first, spec-anchored and spec-as-source tools, and how heavy they get for a small bug.
- marshal-factorya factory that turns Linear issues into pull requests with Claude Code as its default runner. It has no license, so I rebuilt ideas and copied no code.
- PStackan MIT-licensed set of playbooks, skills and agents that installs as a Claude Code plugin, which the factory builds on.
- Dex Still Thinks Long-Running Coding Agents Stinkthe counter-view on long-running agents.