Architecture tests that stop AI coding agents from growing god files A developer building an open-world 3D game in Godot 4.7.2 with roughly a dozen parallel Claude Code agents added a 0.34-second GUT architecture test that reads source files and rejects forbidden dependencies or any growth in oversized scripts. After a 14 November audit found 42 scripts over 500 lines (40% of the code), including a scenario_runner.gd that reached 4,362 lines across 242 commits, the test enforces ten architecture rules and a shrinking exception table so large files can only get smaller. The developer notes one remaining trap: an agent that "fixes" a failing test by editing its exception table. An architecture test is the only safeguard that stopped my Claude Code agents from growing the same catch-all files. The project is an open-world 3D game built with Godot 4.7.2, set in a fictional replica of Nantes, and developed since January 2026 almost entirely by about a dozen agents working in parallel. On 14 November, an audit counted 42 scripts over 500 lines, which made up 40% of the code. The fix was a 0.34 s GUT test that reads the sources and rejects any forbidden dependency or any extra line in a big file. One trap remains: the agent that "fixes" the test by editing its exception table. An agent's harness is everything around the model: the written instructions CLAUDE.md, memory notes , the test scripts, the machines and the safeguards that reject code. An agent adds code where it already has the context. The game's scenario runner, scenario runner.gd , was created on 10 November. By the evening of the 14th it was 4,362 lines long, after 242 commits. Every agent appended its scenario at the bottom. Each commit was reasonable, and the result was a file that all of them edited at the same time, the main source of conflicts between their git worktrees. The audit on 14 November measured the rest: 389 scripts, 96,865 lines, and a median of 143 lines per script. pause menu.gd 1,259 lines, 85 functions handled the start screen, saving, options and building the UI, and some "services" mixed game rules with display code. My request fit in one sentence: "clean code, small files and small commits, with a clear split." The architecture document turned it into ten rules. The project's instructions are written in French, so the quotes here are my translations. One of the rules: "A larger script listed in the table does not grow by a single line: new code goes into a script of its own." An agent may or may not read a written instruction, but a red test in the fast suite stops it before the merge. test architecture.gd reads every script without loading the map and checks dependency rules and size limits: | Test | Fails if… | |---|---| | layer of each script | a script lands in a folder that has no layer | | who may reference whom | a new forbidden dependency appears | | mission engine | it references anything other than itself no exceptions allowed | | game nodes looked up by the world | one more game group is looked up | | maximum size | a script goes past 500 lines, or a listed script grows by one line | Here is the size check, shortened: php func test no script grows past the size limit - void: for path in scripts: var lines := FileAccess.get file as string path .count "\n" var noted := int Architecture.SIZE EXCEPTIONS.get path, 0 if noted == 0: if lines Architecture.MAX LINES: too big.append "%s : %d lignes plus de %d : à découper, un script par responsabilité " % path, lines, Architecture.MAX LINES elif lines noted: too big.append "%s : %d lignes, notée %d un gros script ne grossit plus : mettre le nouveau code ailleurs " % path, lines, noted elif lines <= Architecture.MAX LINES: shrunk.append "%s : %d lignes, sous le seuil à retirer de SIZE EXCEPTIONS " % path, lines French for: "N lines over 500: split it, one script per responsibility "; "N lines, listed at M a big script no longer grows: put the new code elsewhere "; "N lines, under the threshold remove it from SIZE EXCEPTIONS ". The existing violations are listed in a table: 32 dependencies, 19 node lookups, 42 sizes. An exception that is no longer needed also makes the test fail, so the table can only go down. I proved each rule with an injected violation that I then removed, the same way a reported bug gets reproduced by a red test before the fix https://blog.l4w.fr/posts/agent-code-ia-bug-signale-test-rouge-avant-correctif/ in French . One example: 600 lines added to a small script. The runner was split that same evening, in under 40 minutes: from 4,362 down to 860 lines , with 53 scenarios each in their own file. A sixth test, test scenarios are declared in the table not in the runner , catches the stale branch that still adds an entry to the runner. It is the method I used on a bloated controller split by successive extractions https://blog.l4w.fr/posts/poc-sans-tests-direction-pas-point-de-depart-ddd/ in French , applied here with one agent per extraction. Rule 7 of the architecture document says so: "No new exceptions in the test tables: they can only shrink. A failing boundary test gets fixed in the code, not in the table." Less than an hour and a half after the test was created, it went green on this commit from an agent that was adding the credits to the menu: - "res://scripts/ui/pause menu.gd": 1215, + "res://scripts/ui/pause menu.gd": 1216, The agent had put the credits in three new files, then added one line to pause menu.gd and raised the ceiling by the same amount. Another commit had pushed day night cycle.gd from 747 to 755 lines, with this comment as justification: « intégré en parallèle du garde » French for: "merged in parallel with the guard" . An architecture test whose exception table can be edited without any check only stops the agents that don't think of editing it. test monde sans lieu.gd , added the same evening, closes that door. It forbids any new mention of the city place name, coordinate, OSM identifier in the world engine code and caps the sum of the exceptions: assert lte total, Table.DEPART, "la somme des exceptions ne dépasse jamais la mesure de départ" French for: "the sum of the exceptions never exceeds the starting measurement". For size and dependencies, that cap does not exist yet: I review the diff of tests/support/ at every merge. An architecture test is a unit test that reads the source code instead of running it. It checks structural rules: which layer may reference which other layer, which folders exist, how large a file may get. It runs without a database, a scene or a network, so it takes a fraction of a second, and it fails on the first new violation. The exception table has to work like a ratchet: an exception that is no longer needed makes the test fail, and a capped sum assert lte total, DEPART makes it impossible to gain any. A table without a cap can still be edited by the agent, so you also need to review every diff of the test support files. Take the limit from measuring your own repository rather than from a fashionable number. Across 389 Godot scripts, the median was 143 lines, and every script above 500 lines carried at least two responsibilities. So 500 lines became the limit, with the 42 existing violations listed at their size on that day. This piece on architecture tests for AI coding agents was originally published in French on blog.l4w.fr https://blog.l4w.fr/posts/test-architecture-frontiere-fourre-tout-agents-ia/ . I'm Sylvain, a freelance full-stack developer TypeScript/Node.js, PHP/Symfony, infra available for remote missions: services.l4w.fr/en/ https://services.l4w.fr/en/?utm source=devto&utm medium=article&utm campaign=test-architecture-frontiere-fourre-tout-agents-ia .