# Fast, slightly wrong code is the most expensive

> Source: <https://mahmya.io/blog/idea-to-main-why-every-change-takes-22-steps/>
> Published: 2026-12-02 10:51:27+00:00

**Recommendation:** Have a different model family review each agent-written change against a written brief with exact passing commands, and cut the change after three failed review rounds instead of patching further.
More in the playbook "Working with AI coding agents": <https://wpnews.pro/playbooks/coding-agents>

Engineering · AI agents · Quality المدونة

# Idea to main: why every change takes 22 steps

Falak is built by a fleet of AI agents, supervised by one person.

Every change passes 22 steps, three phases and three gates.

People ask why we do not make it shorter. This is the answer, in pictures.

- Written for
- Engineering leaders and clients who ask why software built by AI agents needs this much process.

## 01The short answer

**AI agents write code fast. The process exists because fast code that is slightly wrong is the most expensive kind of code.**

An agent can write a feature in an hour. It can also write a feature that passes its own tests and breaks a rule in a part of the system it never opened.

So every change travels the same road, from idea to `main`, the branch that holds the accepted code. The road has 22 steps in three phases. Each phase ends at a gate: a point where work stops until a check passes.

The question we hear most is "why can't you optimise this?" The direct answer is in [Why not optimise the process?](https://mahmya.io/blog/idea-to-main-why-every-change-takes-22-steps/#why-not-optimise-the-process) The sections before it show what each part is for.

## 02What makes this hard

**The platform is large, every part must agree with every other part, and each agent starts with no memory of the last one.**

These numbers were counted in the code base on 2 December 2026.

| What | How many | 
|---|---|
| Age of the code base | six weeks | 
| TypeScript files | about 3,700 | 
| Automated tests | about 13,000 | 
| Test files | about 1,400 | 
| Database migrations | more than 120 | 
| Design records | more than 50 | 
| Written briefs for agents | more than 200 | 

A person on a team remembers last month's decision. An agent does not. It starts each task with what is written down, and nothing else.

Give the same rule to three agents and you can get three answers.

This slow separation of the code from the design is called architectural drift. Bad agents do not cause it. Many fast writers with no shared memory cause it.

The process is the shared memory.

## 03Who does what

**Nobody checks their own work, and the one person in the process does 4 of the 22 steps.**

| Role | Who | Job | 
|---|---|---|
| Owner | A person | Decides, opens the gates, pushes | 
| Integrator | An AI agent | Supervises: decides, cuts, merges, verifies | 
| Writer | An AI agent | Builds one brief on one branch | 
| Reviewers | AI agents of another model family | Read a read-only copy of the code and try to break it | 
| Scripts | Automation | Create the workspace, run the gates, run the whole chain | 

The fleet uses models from four vendors. One rule holds for every change: the writer and the reviewer never come from the same model family. The integrator writes no large code, so it never reviews its own work either.

## 04Phase 1: decide on paper

**A wrong idea costs one page to fix on paper. In code it costs days.**

Two details carry most of the weight.

**The design stays "proposed".** A design record does not become "accepted" because someone likes it. It names a proof test. Until that test passes on a real run, at step 22, the status does not change.

**A brief is a contract.** It gives the goal and the reason, the order in which to read the existing code and notes, and the exact commands that must pass. "Done" means those commands pass. It does not mean the agent says so.

## 05Phase 2: build, check, review, repeat

**The loop is the process. It is not a sign that something went wrong.**

The gates are the automatic checks: types, code style, the rules for which package may use which, the tests of each changed package, and the platform's own guard tests.

Three rules keep the loop honest.

- **Fix the class, not the example.** The reviewer shows one bad input. The writer fixes every input of that kind and adds a test for it.
- **Cut after three rounds.** When the same part fails review three times, more fixes are patches. The integrator removes that part from the change and records it for the owner.
- **Stop at security.** A fix that needs a security file changed stops and waits for the owner.

## 06Phase 3: land and prove

**An agent's report is a claim. The diff and the tests are the evidence.**

When a test of the full suite fails, the failure is compared against `main`. That shows if the change caused it. When the checks on the shared copy fail, the agent reports the log and waits. It does not push a fix and it does not run the checks again.

## 07Why not optimise the process?

**We did. The machine part already runs without anyone watching. What is left are the checks, and each one catches something the others cannot.**

One script runs the build, the commit, the gates, the review and the fix rounds, up to a set number of rounds. It sends one message at the end. Nobody sits and waits between those steps.

So the time that remains is the time the checks take. Here is what each one is for.

We did not design these checks in advance. We found the need for each one by running without it, or with a weak version of it.

| What we did | What happened | The step that guards against it now | 
|---|---|---|
| Ran a narrow list of gates, twice | Three defects reached `main` | Gates cover every package, guard test and script | 
| Called a failing test a flake | It was a real regression | Every failure is compared against `main` | 
| Called a test "proof" before review | The proof was claimed too early | A design stays "proposed" until the proof run | 
| Built a branch on unmerged work | It drifted when the base was cut | Each brief is checked against merged code first | 
| Took green gates as enough | Many more review rounds followed | Review runs on every change, gates green or not | 

A shorter process is not an optimised one. It is the same process with one of these rows waiting to happen again.

## 08What happens when an agent stops

**Nothing important lives in an agent's memory.**

Agents stop. A usage limit runs out, a tool crashes, a run takes too long.

The same holds for a reviewer that stops: another reviewer model takes the review. And it holds for the person. Decisions, notes and results are files in the repository, so a new session starts from them and not from a conversation that is gone.

## 09Common questions

**Short answers to what people ask most.**

**Why not let one strong model do everything?** Because no writer finds its own blind spots. A model reads its own code the way it wrote it.

**Why must the reviewer be another model family?** A model of the same family tends to make the same kind of mistake and to accept it. A different family reads the code cold.

**The tests pass. Why review as well?** Tests check what the writer thought of. A reviewer looks for what the writer did not think of. Green gates and a long list of review findings on the same change are normal.

**Why does only the owner push?** A push is the moment the work leaves one machine and becomes the shared truth. It is the hardest step to take back, so a person takes it.

**Why a fresh database for every gate run?** Data left from an earlier run can make a broken change pass. A fresh database removes that excuse.

**Why cut scope and not try a fourth time?** Three failed rounds on the same part mean the design of that part is the problem. A fourth fix adds a patch. A cut sends the question back to the owner.

**Does all this slow delivery down?** One change takes longer. The platform does not. Several briefs run side by side, each on its own branch with its own database, and `main` stays in working order while they do. The code base in this post is six weeks old.

**Is the process finished?** No. The table above holds five failures. We expect a sixth, and it will become a step too.

## 10What to ask of any AI-built system

**The question is not whether agents wrote the code. The question is who checked it, and what the evidence is.**

Four questions work for any supplier that builds with AI agents.

- Who reviews the agent's work? Is it another model, a person, or the same agent?
- What must pass before a change is accepted? Does it run on a clean setup?
- Where are the decisions written down, so that the next agent or person starts from them?
- Which steps may only a person take?

**What to do next:** ask these four questions about any software built with AI agents. Ask us first.
