Most of my software factory is brakes
Scheduled jobs on my Mac have turned GitHub issues into 573 merged PRs. Most of the work went into the parts that stop it, and the worst bug was a PR that told reviewers the tests passed.
On this page
A pull request is waiting for my approval. I didn’t write it and I didn’t open it. A job on my Mac picked up an issue assigned to me, decided it was clear enough to build, wrote the change in an isolated worktree, ran the tests, opened the PR and answered the first round of review comments. My part is reading it and clicking approve.
Since early September that loop has merged 573 PRs by my count: 293 into a production codebase at work, 267 into its own repository, and a handful elsewhere. The median PR goes from opened to merged in about an hour.
The repository has close to a thousand commits since I started tracking it in git. When I read back through the log, most of them are about stopping the loop: holds, gates, timeouts, spend limits, and checks on what it’s allowed to say in public. This post is about that half.
What it does
About twenty scheduled jobs run under launchd. The main path takes one issue at a time. A judge step reads the issue and decides whether it’s ready to build or needs a question answered first. A build step writes the change in its own git worktree, so nothing touches the checkout I work in. A test gate runs the suite before anything is committed. Then the PR opens, and later passes pick up review comments and CI failures and push fixes.
Nothing merges until I approve it. That was the first rule I wrote, and it’s the one I’d keep if I had to delete everything else.
Two of the seven steps write code. Five of them can stop the run.
The PR that said the tests passed
Six PRs went to review with a Verification section saying the test command passed in the worktree before the commit. In a narrow sense it had. The command looked for tests covering the changed files, found none, printed a line saying so, and exited cleanly. The build step saw a clean exit and wrote “passed.”
No tests had run on any of the six. Colleagues reviewed them, and every one was authored by me and assigned to me. The automation has no identity of its own, so when it makes a claim in a PR body, I’m the one making it.
The old Verification section was prose the build step wrote about its own work. That was the flaw. I was asking the model to grade itself and then publishing the grade under my name.
Now every Claude phase runs with a hook that records each shell command the model runs. When the repository has a test command configured, the loop runs it itself and pastes the output: how many tests passed, how many were skipped, and which suites were skipped and why. When there’s no test command, the section lists the check-shaped commands that actually ran and the last line each one printed. It never says “passed” in that case, because the record carries no exit code to back the word up. Anything the change claims that the output doesn’t show goes under a heading called “Not proven by this PR.”
The model can still write whatever it likes into a scratch file. That file just never reaches the PR body.
The rule I took from it: if a claim in a PR body can’t be checked from the PR itself, it doesn’t belong in the body.
I also wrote down what to do the next time a false claim gets through. Say so on the PR in one sentence, correct the PR or close it, and add the guard that would have caught it in the same session. The receipts hook exists because of that last step. An apology on the PR would not have produced it.
The gate that failed working code
The test gate kills a run at 1,890 seconds. The unit suite in that codebase had grown past 10,000 tests and needed about 2,000 seconds. So a clean run failed the gate.
One run had reached 96.5%: 10,210 tests run, zero failures, one expected failure. The loop reported it as “failed the pre-commit unit test gate” and filed it as terminal, the same label a real failing test gets. The change was fine and shipped later.
Two problems were hiding in that number. The loop couldn’t tell “ran out of time” from “broken,” so a timeout read exactly like a regression. And even on a good day the gate spent about 33 minutes per issue producing no signal, because CI runs the full suite on the PR anyway.
Raising the limit buys a few weeks, since the suite grows every day. The proper fix is to run only the tests that cover the changed files before the commit and leave the full suite to CI. Until a gate can say which kind of failure it saw, I read the log before I believe the verdict.
The retry that tripped on its own leftovers
A run failed partway through, after it had already pushed its branch to GitHub. The retry started fresh from the base branch, built the change again, and tried to push. GitHub rejected it, because the remote branch had history the new one didn’t. The retry ended terminal on a problem the first attempt had created.
The fix replaces a stale branch, but only when I can state why it’s safe: the remote branch exists, it has diverged, and no PR is open on it. Then it force-pushes with a lease pinned to the exact commit it just read, so it can’t overwrite anything that changed in between. If a PR is open, or GitHub can’t say, it refuses and fails the way it used to.
A retry has to clean up after the run that failed. Starting from a clean base isn’t enough when the first attempt left something on the remote.
The rest of the brakes
The judge can put an issue on hold when it has an open question. The hold clears only when the answer lands in the issue body, where the question was asked. A comment underneath doesn’t count, because the body is where the next run looks for the answer.
Each issue has a spend limit, so one confusing issue can’t burn a day of model usage on its own.
The build runs with a deny list of commands it may not call, plus shell assertions for the cases a deny list can’t express.
And one command stops every scheduled job, at any step.
If you’re building one
Decide early whose name goes on the output. Mine does, so every brake in this post is really a rule about what I’m willing to sign.
Then treat anything the model says about its own work as a claim, and put the evidence next to it. A loop that reports its own success will report it whether or not it happened. A loop that pastes its output lets the reviewer check, and that includes me at the approve button.
Omar ElHawary
Applied AI Engineer. I build and evaluate AI agents that act on real business data.
Working on AI that has to be right?
Let's talk