An AI-assisted delivery pipeline, from zero to hero

The problem
Two mobile apps, roughly a year apart, on different stacks.
The first was a native iOS app built by a team over twelve months: 844 commits, 389 Swift files, 48,762 lines. The second was a Flutter app for a restaurant ordering system: nine sprints, one engineer on mobile, a second writing the Go backend in parallel. One binary, four kinds of user: a customer ordering from a phone, a waiter at a table, a bar tablet printing kitchen labels over Bluetooth, and a courier.
The risk in both was the same, and it is not that an AI assistant writes bad code. It writes plausible code, quickly, and plausible is the problem. Ask for a screen and you get a screen. Ask for forty over a few sprints and you get forty that each look reasonable on their own and no longer agree about where a repository lives, who may read a token, or whether money is an int or a double. The drift never shows in a single diff, so reviewing diffs will never find it.
The zero on the second project was literal: an earlier attempt at the same app, 22 commits, 103 Dart files, no CI, no tests, and a layering rule that existed in a document and nowhere else. It compiled. Nobody could have inherited it.
Our approach
The pipeline has four parts, and each has exactly one job.
A constitution the assistant reads before every change. CLAUDE.md sits in the repository root and is not documentation. It is read first on every task, and its rules are deliberately checkable rather than tasteful. The entire layering rule is this:
presentation → domain ← data
grep -rn "^import" lib/domain --include='*.dart' | grep -E "data/|presentation/|core/|package:flutter/"
grep -rn "package:app/data/" lib/presentation
Both must print nothing, in two seconds, in any week of the project. A rule that reads well but cannot be executed gets negotiated away by week four, usually by someone in a hurry with a good reason.
Specialists invoked at named checkpoints. Instead of one assistant that knows everything slightly, the repository holds five narrow ones: architecture for any layer boundary; contracts for every endpoint and DTO change; realtime and offline for the WebSocket, outbox and idempotency; test strategy before every pull request; and release compliance before a store submission. Each carries one instruction that matters more than its lane: if the work needs a decision from a human or from the backend engineer, say so and stop. An assistant that guesses at a contract question produces a confident answer and a day of rework.
A gate that does not care what passed locally. CI runs on every pull request into dev, from a clean checkout: install, generate code, generate localisations, check formatting, analyze, test. Generated files are gitignored on purpose, so CI regenerates them, catching the class of bug where a build works only because of a stale artifact on one machine.
A ledger of disagreements. docs/api.md records what the backend actually serves today and where it differs from what the app was written against. Twelve endpoints exist; everything else the app calls returns 404. That turned a recurring conversation into a file both engineers could read.

The hard decisions and trade-offs
Ten agents became five. The first generation of this pipeline had ten: five backbone roles and five domain experts, plus a synchronisation gate that blocked implementation until the ticket existed in both trackers. It shipped a year of work. It also carried an agent for test strategy while the project had no test target at all, which is the whole lesson in one line. An agent invoked at a checkpoint you genuinely reach earns its place. An agent that names a responsibility nothing routes work to is documentation wearing a job title. The second generation kept the five checkpoints that were actually reached, deleted the rest, and moved the weight from advice to gates a machine can decide.
We refused to let a feature reshape the architecture. The constitution says it plainly: do not restructure the layers to make a feature fit. An assistant will always offer the local shortcut, because for that one screen it genuinely is simpler. It only gets expensive later, and only in aggregate.
We left out the use-case layer on purpose. Textbook Clean Architecture wants one; ours would have forwarded a single repository call each, forty files of indirection buying nothing.
We kept the live API tests out of CI. Thirteen of them check the app against the deployed backend, skipped unless explicitly enabled. A job that depends on someone else's deployment goes red for reasons unrelated to the change under review, and a CI that goes red for unrelated reasons stops being read.
The outcome
The Flutter app, nine sprints after the scaffold commit:
- 120 commits across 14 feature branches, merged through 13 pull requests into
dev - 197 Dart files, 42,402 lines in
lib - 67 test files, 13,509 lines, 630 tests green plus 13 opt-in live ones skipped
- 89 to 100 percent coverage on the five subsystems that fail silently rather than loudly: the auth interceptor, the resync protocol, the outbox, token storage and the permission table
- All four roles built, and both layering greps still print nothing
The honest framing is not that an assistant produced 42,000 lines. The first project produced 48,762 and had no test target at all. It is that half the agents and twice the automation delivered work whose verification greps still come back empty.
What broke along the way
This happened on the mature pipeline, not the immature one, which is why it is worth writing down.
The app sent and expected four role values on the wire: KUPAC, KONOBAR, MANAGER, DOSTAVLJAC (Bosnian for customer, waiter, manager, courier). The backend sends customer, worker, admin, courier.
Nothing failed. No exception, no log line, no failing test. The role parser falls back to the customer role on any value it does not recognise, which is correct and deliberate: you never grant staff access on a string you do not understand. So the first real staff account, the bar tablet's, signed in, was not recognised as staff, and landed in the customer app. The bar tablet looked like a guest's phone, and the app reported no error to anybody.
CI was green. All 630 tests passed. The wire contract had a dedicated test file asserting those four literal strings, and it passed too, because it asserted the strings the app had invented.

The enum carried a comment naming this exact risk and asking for the values to be confirmed against a real staff token before the first staff account existed. The account arrived first.
That is the boundary of the whole pipeline: it enforces what lives in the repository, and a wire value does not live in the repository. It lives on another engineer's server. Every rule we wrote is decidable by a grep, a test or a CI job, and none of the ones that run on every change can reach across a network to find out what a string is called on the other side. The opt-in live API tests can, but until the first staff account existed there was no staff token for them to check.
The fix touched four files and changed no design. The fallback stayed, and stayed the customer role. The contract test now feeds it MANAGER, one of the strings the app used to send, on purpose, so an invented value can never quietly become a staff role again.
Stack & takeaways
Stack: Flutter 3.44.8 pinned, flutter_bloc, get_it registered by hand in one readable file, go_router with a permission-based redirect, dio, drift, freezed, mocktail and bloc_test, GitHub Actions. The earlier generation ran on SwiftUI, xcconfig-based environments and SwiftLint.
- Write rules a grep can decide, not rules that read well. Every rule that survived the project was executable. The ones phrased as guidance went by week four.
- Count the checkpoints you actually reach, then keep that many agents. Ten roles on paper became five in practice: the five that work was genuinely routed through.
- Give the assistant explicit permission to stop. The most valuable line in five agent definitions tells it to halt when a decision belongs to a human, instead of producing a confident guess that reads like an answer.
- Silent fallbacks outlive loud failures. The role bug survived green CI and 630 passing tests because the app's behaviour on an unknown value was correct in isolation and wrong in context.
- A test that asserts your own assumption is not a contract test. Ours asserted four strings with real conviction. A contract has two sides and only one was in our repository.
- The pipeline's reach ends at the repository boundary. Everything inside can be enforced automatically and should be. Everything outside needs a human to go and ask, and that question is worth scheduling rather than hoping for.
Related: Offline-First on Android, Part 2 — The Outbox Engine: Architecture & Draining

