How I Built Lodestar: 48 Messages, One Page of Rules, and an AI Agent

Intro

On 11 November at 23:12 I typed one long sentence into a terminal. Twelve days later there is a game called Lodestar: a first-person infiltration game that runs in a browser tab, is on the App Store, is in a closed test on Google Play (sign up here), and is open source on GitHub under the MIT licence.

I did not type its code. An AI coding agent did: GitHub Copilot CLI, running Anthropic’s Claude models. My part was 48 messages and one page of standing rules. The rule this post is about fits in a line: every loop says, before it starts, when it stops, how many rounds it may take, and what happens when they run out.

This post is the practical sequel to AI Coding with Spec-Driven Development and Context Engineering. There the unit of work was the spec. Here it is the loop.

TLDR: Getting an agent to write code is the easy part. Getting code you can trust takes loops with declared exits: a plan that a second agent attacks before anything is built, a failing test before the code, a review before the commit, a gate before anything goes public, and a report that says what was not checked. Run that way, my 48 messages, and the 139 briefs the agent wrote to helper agents behind them, became a game of 47,000 lines with about 900 tests, shipped four ways.

Counts of code, tests and documents in this post are of the public repository at commit d2968ab.

Lodestar: a first-person infiltration game that runs in a browser tab

What I asked for

That sentence asked for a game in which you infiltrate a uranium enrichment facility as special forces, eliminate its AI guards and drones, blow the place up, and plant a beacon for the strike that follows. Everything was to be made from scratch: graphics, sounds, name, controls. It ended: “don’t stop and ask me question just run until completion”.

The agent wrote a design, had a second agent criticise it, and split the build among five helper agents working in parallel. Its first commit is stamped 02:14 that night, and its log has the game deployed at 02:36 with 123 tests passing. The public repository starts later, with a fresh history, so those two times are from my own records. My next message, in the morning, asked for better graphics.

From then on my side of the work looked like this, typos included:

  • “I want it clear that this is a hidden centrifuge site inside a mountain, underground, not just a hangar.”
  • “the game is still too easy to shoot down drones and robots make it more difficult …”
  • “just go wild and make it maximum fun of a game and maximum creative don’t holdback and don’t ask me questions until you are done, but allow me to rollback if i wouldn’t like it”
  • “i like the go wild example make it the main …”
  • “this is pretty amazing publish it to the app store for real”

That is what the interface looked like. The repository quotes messages like these as dated decisions, 67 passages in all, next to the code and the tests each one caused: see the design and the design of the wild build.

One page of rules

Copilot CLI reads my standing instructions at the start of every session. They are a page long. Here are four of them, word for word. They are the part of this post you can reuse.

Declare the execution graph up front. For any non-trivial task … state the task’s graph in one compact line before executing … Example: repro ✅ → failing-test ▶ → fix ─ → suite-green ─ → commit ─ → dev-deploy ─.

Loops declare their contract before entering: exit condition + max iterations + exhaustion behavior (e.g. “retry deploy ≤2, then ⛔ and report”).

Test first, then code, then docs. … update or add the contract test (red) → implement (green) → update the design doc in the same commit. Never weaken a contract test to make code pass without an explicit, documented decision.

End every response with a short TLDR block: Problem … Implemented … Verified … Graph … Now …

In the examples, ✅ is done, ▶ is current, ─ is pending and ⛔ is blocked. What each rule did here:

  • The graph. Before a task of any size the agent writes its steps as one line of nodes and marks where it stands. The game came out the same way: its README lists test suites beside the behaviour each one locks, among them “every edge of the mission graph” and “every edge of the guard graph; every state ends by the clock” (README, Tests).
  • The loop contract. Before a word of the Hebrew voice-over was recorded, the agent’s plan said: “voice lines: each line at most 3 takes until what is heard is the script; exhausted: reword once, else deliver it flagged.” The first take doubled a syllable in one word. The second, with that sentence reworded, passed.
  • The contract tests. On the first day I wrote that the place is not “a plant but rather uranium enrichment facility”. That sentence is now a test that fails if the word “plant” appears anywhere in the game. For the parts that face the outside world, the tests are then proven the hard way: the agent breaks the code on purpose and checks that a test goes red.
  • The report. Every reply ends with what was implemented, what was verified and where we are. The longer reports also list what was not checked, which no test can tell you.

Two more habits come with the tool. A second agent attacks every non-trivial plan before it is built, and another reviews the change before it is committed. Each starts with an empty context and sees only what it is handed, which is the point.

The loop

The loop behind every change: my message, a plan, a critique, a failing test, the code, a review, a commit, a gate, a report, with three ways back

Behind my 48 messages the agent wrote 139 briefs to 112 helper agents: critics for plans, reviewers for changes, builders for parallel work. It made about 26,000 tool calls, most of them shell commands (12,000), file reads (5,900) and edits (5,200), and 170 commits in my private repository. I saw almost none of that. I saw the report at the end of each loop, and the game.

What is in the game, and where it came from

  • The stack is three.js and Vite, with one runtime dependency.
  • Nearly everything is code: the site, the machines, the guns, the menus, most of the sound. That is 47,145 lines of JavaScript in 136 files, held by 898 tests.
  • Models made the rest, once, and the files are kept: ten surface textures from Google’s Gemini image models, eight pieces of music from Lyria, 41 voice lines from a Gemini speech model, and six sound effects cut from the soundtracks of clips made by a video model.
  • All of it is credited in the README, and the words each model was given are in the repository, for the pictures and for the sound.
  • The design is written down: about 75,000 words in twelve documents. Their first reader is the agent itself. They are what lets a fresh session pick up where the last one stopped.
The game's title screen, captured in a browser tab

Shipping it four ways

One codebase, four ways out: browser, iPhone, Android, open source
  • Browser. The game is a Microsoft Fabric app built with Rayfin: static hosting, plus a small database for the shared scoreboard. In front of it sits a Cloudflare Worker on my own domain. I was uneasy about handing out the app’s own address, and I wanted my DNS records managed somewhere independent of any host.
  • iPhone. The same build runs inside a Capacitor shell, with a small native bridge so that the phone’s haptics work. It went to TestFlight first, and Apple’s record gives 21 November as its release date. The agent drove App Store Connect in my browser and asked before each step. Signing in was mine.
  • Android. The same shell, as a signed bundle, is in a closed test on Google Play, which Google approved within a day. A new personal developer account needs twelve testers for fourteen days before it may ask for a public release, so there is a sign-up form, with a small Apps Script behind it that sends each tester the way in.
  • Open source. The public repository is not the one I work in. It is exported from a single commit by a tool with a gate, and the gate refuses keys, e-mail addresses, identifiers and home-directory paths.
Three of the game's seven App Store screenshots

Promo, made the same way

The trailers are the game itself, recorded frame by frame, plus some shots generated from the game’s own frames by image-to-video models (LTX and MiniMax, served by fal through Azure AI Foundry). In the English trailers each shot carries a small label that says which it is. They were cut and mixed with ffmpeg, and the Hebrew narration is from ElevenLabs.

An agent can neither watch a film nor hear a narrator, so it used stand-ins. Whisper transcribes the mix on my own machine. A listening model writes down the sounds it hears without being told the script. A watching model goes through the finished cut and lists faults. Then the agent told me to listen before posting, because it cannot.

What went wrong

  • The first public copy said more than I wanted. I asked for a second check. It found no secret, but it did find documents that described things I had meant to leave out. By then the copy had been public for two and a half hours. The agent did not force-push over it, because overwritten commits can stay reachable on GitHub by their hash. It set that repository aside and published a fresh one, and the old one is deleted.
  • A loop without an exit. Reviewing the English trailers, the agent ran twenty review passes, and reported afterwards that it had never declared a limit. Its plan for the Hebrew film, three days later, capped the same loop at three.
  • Pointed questions get pointed answers. Told how a word should sound, the listening model reported faults that a blind write-down of the same sounds did not show. Asked only for its opinion of a whole take, it smoothed over a real slip, a doubled syllable that the transcriber caught. Use blind checks, and more than one checker.
  • A test that pinned the wrong sentence. The Android sign-up form thanked everyone with “An e-mail is on its way”, while a rule elsewhere sent each address one e-mail a day at most. My address had been used in a trial run the evening before, so when I signed up, nothing came. The test was green, because it pinned the sentence and not whether the sentence was true.
  • Hands on my accounts. Driving my browser, the agent sent a stray key press into the editor of the script behind the sign-up form, split a line of its code and broke it for three minutes. No sign-up arrived in that time.

Two of these I caught: I asked for the second check, and the unanswered sign-up was mine. The other three the agent reported on itself. Each one ended with a new rule or a new test, not a cleverer prompt.

What I actually did

  • Decided what the game is, and said “too easy”, “too difficult” and “make it the main”.
  • Played the builds, on my phone and on my laptop, and said what was wrong.
  • Approved what went out: store submissions, content declarations, e-mails sent in my name. The sign-ins, the two-factor codes and a CAPTCHA were mine.
  • Wrote the rules once, and asked for a second look when it mattered: “check again”, “triple checking”.

A quick checklist

  • Write your standing rules once, and stop repeating them in prompts.
  • Make every retry loop declare its exit, its cap, and what happens when the cap is reached.
  • Have a second agent attack the plan before the build, and review the change before the commit.
  • Turn your sentences into tests, and prove the important tests by breaking the code.
  • Never let the agent weaken a test to get to green.
  • Put a gate in front of anything public, and test the gate with a planted secret.
  • Ask what was not checked, every time.
  • Keep the sign-ins and the approvals for yourself.

Try it

References and further reading