AI Joe
← Blog· Engineering Reality

The Layers Look Clean Until a Bug Crosses Them

October 20, 2026

AI-written code often passes review because it mimics the shape of good architecture: controllers, services, mappers, repositories, all present and accounted for. The shape is not the substance. A layer only matters if it protects something, and most AI-generated layers just forward calls with renamed methods, adding ceremony without adding any actual boundary.

The Details:

  • Test any layer by making a trivial change, like renaming a field, and counting how many files have to change with it. If one edit ripples through four files, those files were never separate concerns. They were a relay passing the same idea along in different costumes, and that ripple is the tell that the structure was never load-bearing.

  • Bugs that cross layers expose the illusion fastest, because now you need the controller's assumptions, the service's retry behavior, and the repository's transaction scope in your head at once. AI assistants typically see only the file where the symptom shows up plus a few neighbors, not the full call path, so they patch at the nearest convenient point instead of the actual point of failure.

  • A classic version: one layer trims whitespace, another normalizes case, a third compares values inconsistently between reads and writes. Each piece looks fine alone. A user with a stray space in their email signs up fine and then can never log in again, because three layers each assumed someone else owned the rule.

  • The fix is not another defensive check bolted on wherever the trace lands. It is naming the invariant once, writing it directly in the file where the next change will happen, and deleting the redundant logic everywhere else so only one layer owns the rule.

Bottom Line: Architecture that nobody can explain in one sentence will not survive the first bug that tests it.

Enjoy this article?

Listen to the Claude Code Conversations radio show or join the community.