40 days building a game with a team of AI agents: 10 lessons from 322 failures

Ranse Biyori is built by Claude Code and Codex agents running side by side. In 40 days I logged 322 failures. These are the 10 lessons that helped most.

An Imagawa banner at the gate of Narumi Castle.

I’m making Ranse Biyori, a game about walking through Owari province in Sengoku-era Japan, in Unreal Engine 5. The people making it are me and a team of AI agents.

The team is several Claude Code sessions running at the same time: one for the game side (screens and controls), one for the map and visuals, one for tests and tools, and three Codex workers writing the game rules and their tests. A coordinator session talks with me and hands out work to each agent. Everyone pushes from their own branch to the same main branch of one Git repository.

Nakamura village in the morning. The game starts here.

Hand the missing hands over to agents, and the work moves fast. So do the failures. From mid-October I started writing every failure into a “failure log” on the same day. Each entry has four fields:

  • What happened
  • Why it happened (marked “guess” if we don’t know)
  • The underlying shape (the habit of the system that will cause it again)
  • What we do from now on

After 40 days the log has 322 entries. Reading it back, it is full of holes that anyone building with AI agents will probably step in. Here are the 10 lessons that helped most.

When and what kind

The worst stretch was October 16–19: 83 failures in four days, about a quarter of the total. That was when a full code audit, a rebuild of the map data, and a switch to “enforce rules with tools, not documents” all landed at once. Big changes to how things work bring failures with them.

By kind, roughly (the counts are approximate):

Kind Count Example
Not enough tests; broken code reaches main ~70 The Shipping build failed for four days and nobody noticed
A check tool stops things wrongly, or lets them through silently ~50 The LFS check read a 51 MB file as “0 targets” and let it through
Saying “fixed” or “it’s on main” without checking ~50 Reported “landed on main” when the push had been rejected
Fighting over the same file or machine ~40 One tool held a build slot and froze; everyone waited 35 minutes
Agents sitting idle ~40 Codex stopped itself and nobody restarted it for about 34 hours
Two places owning the same data ~35 A banner script read its own previous output, doubling every run, until there were 1.27 million banners
Things not passed on or not written down ~25 A decision never made it into the task list; an agent waited 25 minutes
Tests that give different results each run (flaky) ~12 The same code failed the nightly tests only three times

When the banners hit 1.27 million, I did laugh.

The banners at Narumi Castle. Now there is exactly the right number, one each.

The 10 lessons

1. Say “it’s on main” only after checking it yourself

AI agents say “done” and “fixed” very naturally. Whether it is actually done is another matter. Three times, an agent read part of the output and reported “it’s on main” when the push had been rejected.

Now, after every push, git fetch and git merge-base confirm that the commit is really in origin/main. Every “done” in the task list carries the main commit hash. A “done” without a hash counts as not done.

2. Rules in documents don’t hold. Stop it with structure first

At first I thought writing a rule in AGENTS.md was enough. At the end of September I decided that “only the rules code (Sim) may change game state.” By mid-October there were about 210 places where the game-side code wrote Sim state directly.

An agent session only remembers the rules it read when it started. On the day I edited AGENTS.md 16 times, every agent was still running on an old version.

Now the ways of enforcing a rule have an order:

  1. Make the bad state impossible to build (closed types, one owner per piece of data)
  2. Only what can’t be made impossible gets a check tool (lint, guard)
  3. Only what can’t be checked gets a human review

AGENTS.md changes at most once a day.

3. Adding a check for every failure builds a pile of patches

Each time something failed, we added “a check that catches this failure.” In 47 hours we had 8 new checks. The word that came out of me was “patchwork.”

A check plugs one hole. A hole of the same shape opens somewhere else. Now, when the same failure happens twice, we fix the underlying shape before adding a check. That is why the failure log has a field for it.

4. Auto-play tests don’t find bugs

At first I relied on scenario tests that play the game automatically. We ran them once an hour, 78 times, and they found 0 real bugs. Around the same time, a single playtest by me found 18 to 23.

Auto-play only walks the path you wrote. People click odd things and walk odd ways. Auto-play is no longer a pass/fail gate. It is a tool for taking the camera to a scene for a screenshot, and for reproducing a bug we already found.

The first night: fighting the bandits who raid the village. Auto-play never found bugs in scenes like this.

5. Don’t pass a test on “arrived at the destination”

The test before a playtest build passed on “reached the first barn.” When I actually played, the hero couldn’t take a single step out of the barn. A jail-escape test passed with the character standing inside the cell.

Now we check whether the hero can walk out through the door. Pass or fail is judged by the screenshot, not by a line in the log.

The villagers gathered in the barn after the bandits are driven off. We now check past “reached the barn.”

6. Keep the AI that builds and the AI that reviews separate

Whoever designed something can’t see the holes in their own thinking. A separate model that only reads reviewed a plan for about 13 minutes and found 3,725 pieces of data the plan had missed.

Now there is a “design reviewer” that never writes code and only reads. Before a big decision, the first question to it is whether we need it at all.

The Imagawa main camp at Okehazama. We are checking how this battle is built together with the reviewer.

7. Make a number the goal, and reducing the number becomes the goal

We were counting “backdoors that change state without going through the rules” and driving them to zero. The count went down nicely and every check passed. Later we found that functions doing the same job as the removed backdoors had been copied, under other names, into 42 places.

A number only stands in for the problem you actually have. Now, before a big refactor, we first write down one problem that really happened.

8. Whoever stops a process doesn’t know how to clean up after it

Builds stopped on a timeout kept leaving files read-only. A game we thought we had killed from outside stayed alive for two hours, holding a build slot the whole time.

Now the tool that starts a long-running process writes an “owner tag” (a record of its pid), and you may only kill processes you started yourself. Cleanup is done by a different tool from the one that stopped the process.

9. Count the task queue by “ready to start,” not by “how many are in it”

There were three tasks in the Codex queue, and all three Codex workers sat idle. Every one of the tasks was waiting behind another task that had not reached main yet.

Now we always keep at least two tasks whose prerequisites are done and that can start right away. Before I go to bed, at least six.

10. “0 found” doesn’t mean “no problems”

The LFS check that watches for large files couldn’t read its input because of a BOM (a byte-order mark at the start of the file). It answered “0 targets” and let a 51 MB file through. A screenshot tool once returned “success” after taking 0 pictures.

Now, reading 0 items stops as a failure. Tools write out what they excluded and what they skipped.

The patterns that kept coming back

The same shape of failure happens again and again. These three came up most:

  • A missed test selection lets failing tests into main (about 15 times). Running every test every time is slow, so we only run the tests related to a change. The selection had gaps. We kept adding to it: tests that call a changed function, tests that read a changed data file. The last net is running every test overnight.
  • Merging main brings in C++ changes, and we push without building (about 8 times). We stopped chaining “merge” and “push” into one command. The push script now looks at what the merge brought in and builds before pushing.
  • Two scripts own the same data (about 8 times). The 1.27 million banners were this. Instead of writing “the order to run things” into a manual and hoping it is followed, each piece of data now has exactly one script that owns it.

In closing

The best thing about keeping the failure log is that I now notice the second time. The first time might just be bad luck. When it happens a second time, it is a habit of the system.

Last, here are the lines from the log that I reread most often:

  • Auto-play passing and the game actually being fixed are different things
  • A rule in a document works only when it was read and remembered
  • Put a number on something, and reducing that number becomes the goal
  • A check nobody uses rots
  • 0 found is not 0 problems