Structural Anti-Patterns and How to Spot Them

A photo-renaming script with nine empty folders. A service where business tools open their own database connections. A feature-flag file sitting in the most stable layer of the codebase and being edited every Friday. All three teams thought they were following the model. All three were making system-level mistakes.

Mistakes about the shape, not the code

The earlier anti-patterns in the book concern a file or a function: a bad import, an overgrown tool. Structural anti-patterns are different. They are wrong decisions about how many layers a system should have, which layers it should include, and where each component should be placed. No single line of code is wrong, which is why they survive review.

Too many layers

Over-layering means applying the full nine-layer model to a problem that does not need it. A single-purpose script, a small internal library or a thin service ends up with a skeleton of folders for Tools, API, MCP, Skills and Agents that hold nothing, or one file each. The cost is navigation overhead and a false air of architectural seriousness.

The book's advice is to size the stack to the system, looking at how complex it is and how many outside systems it touches, and it gives suggested layer counts for several kinds of project. Its test is a single question: would this layer hold responsibilities of its own, distinct from its neighbours? A layer that would sit empty is evidence that the model is being applied by rote instead of by judgement.

Too few layers

Under-layering is the opposite error, and the book singles out one omission as the typical culprit: the Resources layer. When it is missing, tools talk to the database or to third-party APIs directly.

// No Resources layer: a tool owns its own connection
const db = new Pool({ connectionString: process.env.DB_URL });
export const getInvoice = async (id: string) => {
  const r = await db.query("SELECT * FROM invoices WHERE id = $1", [id]);
  return r.rows[0] as Invoice;
};

Every tool that touches data now contains connection handling, raw SQL and result parsing, so the database driver becomes a transitive dependency of the whole Tools layer. Moving to another data store means editing every affected tool, and testing requires either a live database or brittle mocks of the driver. Introducing a repository in Resources makes the tool database-agnostic and testable with a simple mock.

The right code in the wrong layer

The third anti-pattern is the one most worth knowing, because it turns the volatility numbers into something you can check. Wrong volatility assignment means a component lives in a layer whose volatility range does not match how often it really changes.

The common form is configuration in Schema. Feature flags, environment-specific settings and frequently changing business rules get parked in the foundation layer (ν 0.3). Because every layer depends on Schema, each edit triggers revalidation across all of them, an excessive response for a value that might change weekly.

The book's detection method is empirical. For each component, count its changes over the past six months from version-control history, then compare that frequency with the volatility range of the layer it sits in. A file edited weekly in a layer meant for rare change is misassigned, however sensible its name looks. The fix is to move it to the layer whose range covers its real behaviour: flags that change at roughly 0.85 belong in the API layer, or in Tools if they govern business logic, while settings that rarely change belong in Schema or Utils. The move still has to respect the dependency rules.

The takeaway

The nine layers are a model to be fitted, not a template to be stamped out. Fit has three dimensions, each with its own check: how many layers, whether any necessary layer is missing, and whether each component sits where its change history says it should. The book says structural issues usually need architecture-level assessment and are tackled in dedicated refactoring effort or as part of a migration. To go further, read how volatility is measured, how to assess a codebase before migrating, and what lvd-metrics reports.

What the book covers

  • Guidance for matching the number of layers to the kind of system
  • The corrected Resources layer that replaces direct database access in Tools
  • The detection procedure for comparing change frequency with a layer's range
  • How structural issues are scheduled alongside migration work