Every developer who tries modern AI coding assistants—Cursor, Claude Code, GitHub Copilot—goes through a honeymoon phase. Coding speed shoots up. In a single evening, you can scaffold a service that used to take a week. The model happily generates typed schemas, wires up validators, and writes green unit tests.
But what happens to that codebase after 6 to 12 months of active growth?
Systems architect Timur Shemsedinov (creator of the Metarhia ecosystem and lecturer at KPI) recently gave a detailed video lecture on a quiet but deadly threat: architectural erosion driven by large language models (LLMs). His breakdown echoes what we explored in Architectural Erosion: Why Vibe-Coding Breaks Long-Lived Systems.
Local Optimization vs. the Global Graph
The root cause of AI-driven architectural decay lies in the math behind generative models.
An LLM optimizes the likelihood of the next token within a local context window. When you ask it to "add an order checkout method to the controller," the model doesn't see your project as a strict graph of abstractions. Its goal is to solve the immediate request as fast and compactly as possible.
What does it do in practice?
- It grabs an ORM database entity and returns it straight from an HTTP handler, coupling your storage schema to your public API contract.
- For convenience, it imports a helper from a neighboring module, creating a hidden circular dependency that the compiler never flags.
- When a business rule requires a discount check, the model inlines the formula right at the call site, duplicating domain logic inside the transport layer.
Locally, everything works and tests pass. Globally, your layers fuse into a monolithic "big ball of mud." Six months later, adding a simple feature costs several times more, and tweaking one database column breaks half your services.
Why Text Prompts Aren't Enough
Many teams try to fight this with "AI rules": huge CLAUDE.md manifests, custom system prompts, and editor config files.
Timur Shemsedinov makes a clear case for why that fails: natural language is too ambiguous. Models happily cut corners and ignore declarative guidelines just to output working code. The only reliable defense is machine-readable formal contracts and automated static checks:
- Strict layer isolation: Your Core Domain should have zero external dependencies. It shouldn't know anything about databases, HTTP, or gRPC.
- AST validators in CI/CD: Architectural linters (such as
dependency-cruiseror Metarhia's AST-based tools) must hard-block forbidden imports on pull requests. If an infrastructure module tries to reach into the domain, the build fails. - Formal interfaces over prose: Data contracts must be defined with strict schemas (TypeBox, Protobuf, or Metacom protocols) using independent SemVer versioning.
An LLM is a great executor for routine coding, but it cannot enforce system invariants. Architecture remains strictly a human responsibility, and enforcing it belongs to impartial static analyzers.
Timur Shemsedinov's lecture is essential viewing for any tech lead planning to roll out AI tools across a team.


