Building Lanyard, part 2: running a dozen AI coding sessions on one app

Most of Lanyard's code was written by AI agents working in parallel. What broke when they shared one repo and two Macs, and the rules that fixed it.

Dan Fernández

· 4 min read

Part 2 of Building Lanyard.

AI coding agents wrote most of Lanyard. On a busy day a dozen sessions ran at once, each on its own branch: one on reports, one on the Android port, one chasing a performance bug, one running overnight test suites. I wrote the plan, made the decisions, reviewed the sensitive code and decided what got merged.

The agents wrote good code. Nearly every problem came from the things they had to share, which were one repository, two Macs, a handful of simulators and one on-device AI model.

Shared memory lives in the repo

An agent session starts knowing nothing about what the others did, so the repo has to hold that memory. One shared file, handoff.md, says who is working on what, on which branch, and what’s left. Every session reads it before starting and adds its row and a log line when it finishes. The next jobs sit in a work queue, and a session claims one by pushing a commit that marks it taken; if the push is refused, someone else got there first. Only the main session merges into the trunk.

It works, but the file grew to about 300 very wide table rows that no person wants to read. If I did it again I’d keep one short status file and move the history somewhere else.

A test that passed on another branch’s build

Early on every worktree built into the same temp folder, and one branch “passed” its UI tests on a different branch’s build. Nothing errored; the results were simply wrong. Now every checkout builds into its own folder and tests run against a private copy of the built app. We assume anything two sessions can write to will eventually be written by the wrong one.

Locks and slots

Some things only take one user at a time, or a few. Two test runs using Apple’s on-device model at once slow each other down and fail in odd ways. A 16 GB Mac mini handles two simulators and one build at a time, and past that everything slows. The performance suite measures launch time against a budget, so it has to run alone on an idle machine, and even your own build in the background will fail it.

Each of these has a lock or a numbered slot, and the agents are told to wait for a lock and never kill another session’s process. An agent that “helpfully” stops a stuck-looking process is usually stopping someone else’s test run.

One bash detail cost us a day. In bash 3.2, $$ inside a subshell is the parent’s process ID, so a subshell holding a lock looked like its parent. Subshells that take locks now release them on exit.

Two Macs

A Mac mini is the build and test server, and a MacBook is the backup and the machine I actually work on. The test scripts send themselves to the mini when it has room and fall back to the laptop when it doesn’t. Part 3 covers why we run our own Mac instead of hosted CI, and what that machine needs.

One afternoon ten on-device model tests failed at once, which looked like a regression in the prompts. It was memory pressure from several sessions running model tests together. The test script now waits out memory pressure and reruns once before it calls anything a failure. Before blaming the code, look at what else was running.

The rules the agents kept

No new third-party dependency goes in without my approval. Every allowed package is listed in a file only I edit. Twice an agent needed a new library, wrote down why, and stopped. It didn’t add the line itself, and it pointed out that any line in that file would pass the build check, so the line had to come from me.

Encryption, the Keychain, networking and anything that sends get my line-by-line review. Agents could write that code, but it didn’t merge until I’d reviewed it. And every decision I owed had a default, so no agent sat idle waiting on me.

Where I got it wrong

Agents will happily build what you ask for. One feature, hints to help speech recognition with names, fixed 0 of the 17 misses it was meant to fix, and I merged it anyway. That one’s on me. I should have asked for the measurement first and decided after.

Tests can fool you too. A UI test checking that “debrief saved” appeared was passing because a prefix match found the “Debrief” button instead, and we only noticed when accessibility work changed the labels. When a test has passed forever, check once that it can fail.

Twelve days in, there’s a beta on real phones, an Android port under way and close to 900 automated checks, so yes, I’d do it this way again. The job does change, though. I spent less time writing code and more on specs, rules, reviews of the parts that matter, and keeping the shared state tidy.

Next: why our CI is a Mac mini on a shelf.

Working on something similar?

If this is close to a problem your team has, tell us about it.