The same two prompts (build a Tower of Hanoi game with OpenTUI, then add an AI mode) were given to Qwen3.8-27B in the Pi coding agent under nine setups, three times each. Every setup produced a game that starts and solves the puzzle. Only the setups with the quality gates produced clean code, and they took about half again as long. Splitting the work between an architect and Qwen coders kept the code clean and added tests, but did not make it faster.
Every setup is plain Pi (the coding agent) with Qwen3.8-27B, plus some of the pieces below. All of them are Pi extensions or settings installed root-owned in the sandbox, so the agent can use them but not change them.
Standing working rules in Pi's agent directory, read at the start of every task: use Bun, run all tests with bun test through npm test, test the UI with OpenTUI's headless renderer, keep probes out of the project, run the real program early. Parts that only apply to some setups (codemode, code-map, gates) are included only there.
Instead of one tool call per action (read a file, run a command, edit), the model writes a short TypeScript script that calls the tools (tools.read, tools.edit, tools.bash, …) and prints only what it needs. One script can do several steps, so there are fewer round trips and less output in the context. Enforced notes (setups 5 to 7): the script must keep a notes entry with store() (plan, files, open problems) and read it back with load() after a context compaction; scripts that ignore this are refused.
When the agent says it is done and the task changed source code, the gate runs Uncle Bob's tools on the changed files and sends the agent back with the findings while anything is red, up to five rounds; after that it must report honestly what is still red. Green means: crapper, every function's CRAP score (complexity² × (1 − coverage)³ + complexity) below 10; coverage, every changed source file executed by a test (only a launcher of at most 2 lines may stay untested); dryer, no pair of code blocks at similarity 0.8 or more; mutator, every mutant killed (each small code change must make a test fail). Lint (setups 4 and 7) adds ESLint with typescript-eslint. The agent may not run the tools itself; the gate does.
Three orientation tools built on the TypeScript compiler: api_outline and api_detail list a library's exported API and one symbol's signature and docs (instead of reading .d.ts files or bundled JavaScript), and repo_map gives an overview of the project's files and declarations. The repo map is shown again after each context compaction.
After Skeleton Coding: Program Structure as a Specification for Agents (AWS Agentic AI), in setups 8 and 9. The main agent is an architect: it writes the program's skeleton, real TypeScript with all exported types, signatures and short contracts (Ensures: clauses, invariants), with every body a stub, and locks it. It then delegates one component at a time to a coder, a sub-agent on the local Qwen that fills the stubs and writes the tests behind the usual gate. The coder's gate also checks the skeleton: every locked signature unchanged, no stub left in its files. The architect is Claude Opus 5.5 (setup 8) or Qwen itself (setup 9).
All runs also had a 120 s default timeout on every bash command and system-wide Bun. Notes means enforced working notes in codemode (store/load across compactions). In setups 8 and 9 the coders are always the local Qwen.
Time is prompt 1 sent to prompt 2 finished. Tokens are the tokens the models generated; in 8 and 9 they and the gate rounds count the architect and its coders together. Gate-clean: the project, re-measured after the series with the gate's own checks on all its sources, passes the gate its setup had (lint counts only in 4 and 7). The games were checked frame by frame in recordings in an 80×24 terminal (see the videos per setup).
Setups 8 and 9 compared with Qwen working alone in setup 4 (Plain + Quality + Lint), and with each other.
Each bar is one run (a, b, c). The tick on each setup's row is its mean. Hover a bar for its numbers.
Every stretch between two tool calls is attributed to what the next call did. Waits over 90 s without a tool call (long thinking, compactions, the gate running) are grey. In codemode one script often does several things, so its split is rougher. In 8 and 9 the coders' time is included and split the same way.
CRAP: the worst function's CRAP score (gate limit 10). Mutation: share of mutants killed in the files mutator tests; "–" means no file qualified (all logic sat in files that import the UI library, which mutator skips). Files tested: source files executed by at least one test. Lint: ESLint errors (typescript-eslint, recommended, type-checked); only setups 4 and 7 had lint in their gate. s3b's 342 lint errors are mostly a side effect of its package.json no longer listing @types/bun, so test globals typed as any.
Sources: the runs' timing logs, Pi session logs and project archives, and one re-measurement of every project with the gate's own checks after the series. Activity categories are approximate. Three runs per setup show the spread, not a precise average.