A developer asks their AI coding assistant to add a discount calculation to the payment module. Simple enough. The AI reads the module. Then it pulls in the order module for the shared types. Then the inventory module for the stock check. Then the notification module for the event contracts. Then the configuration module for the feature flags.
By the time it has enough context to write one function, it has ingested tens of thousands of tokens of cross-module code. It produces something that compiles, passes the existing tests, and introduces a subtle dependency on an inventory function that was deprecated last quarter. Nobody documented the deprecation. The module boundary didn’t enforce it. The AI couldn’t know.
A new developer would face the same problem. To understand this module, they’d need to read five others. That’s not a tooling failure. It’s a structural one.
In Navigating Complexity of Cognitive Load in Software Product Development, Viktor and I described extraneous cognitive load as the effort required to read and understand what needs to change before you can change it. It is the single highest contributor to cognitive load in software development. We spend significantly more time reading existing code than changing or adding code. Everything that makes code easier to read, from design patterns to SOLID principles to continuous refactoring, serves the same function: reduce the effort of comprehension so that more mental capacity is available for the actual work.
AI has the same bottleneck. With one critical difference: it’s worse.
A human developer builds germane knowledge over time. Through repetition and active recall, they anchor familiarity with a module into long-term memory. That accumulated expertise progressively lowers the working memory needed to navigate familiar code. AI has none of it. No germane cognitive load. No accumulated expertise. Every interaction with a module is a first encounter, mediated entirely by whatever context it can ingest in the moment. The extraneous load of reading the code is the only thing standing between AI and a useful output.
How many of your modules can be understood without reading five others? That answer determines how well AI will work in your codebase. It also determines how well your next hire will work. The question is the same. AI just makes the consequences visible faster.
Context Length Is the AI’s Working Memory
Working memory is the limited resource that cognitive load consumes. For humans, when extraneous load is high, working memory gets consumed by comprehension, leaving less capacity for the actual change. AI has an equivalent constraint: the context window. When the context is long and entangled, output quality degrades. Not gradually. Catastrophically.
On coding tasks, one model’s performance fell from 29% to 3% as context expanded from 32K to 256K tokens. Across 18 frontier models tested with nearly 200,000 LLM calls, every model degraded at every context length increment. No exceptions. Focused context of a few hundred tokens dramatically outperformed full context of over 100,000 tokens, with accuracy drops exceeding 30%.
Three mechanisms compound. The lost-in-the-middle effect: information in the center of long context gets overlooked. Attention dilution: 100,000 tokens means 10 billion pairwise attention relationships, and the signal drowns in the noise. Distractor interference: semantically similar but irrelevant code actively misleads the model. That last one matters most for entangled modules. When a payment module shares type definitions with the order module, and the order module has its own discount logic that’s subtly different, the AI doesn’t distinguish. It reads both and averages.
The escape hatch you’re thinking of doesn’t work. Research published at EMNLP 2025 tested what happens when retrieval is perfect. All relevant information present. No noise. No distractors. Performance still degraded 13.9% to 85% as input length increased. Even when irrelevant tokens were replaced with whitespace. Even when models were forced to attend only to relevant tokens. The sheer length of the input alone hurts. Independent of retrieval quality.
Translate this to module design. A well-bounded module provides focused context. A few hundred tokens of self-contained code with a clear API. An entangled module forces the model to ingest everything it depends on. The module boundary is the context boundary. Draw it well, and AI gets a focused prompt. Draw it badly, and AI gets a soup of cross-module dependencies where the signal degrades with every additional file.
When AI Can’t See Across the Boundary
Half of real-world coding tasks require understanding code in other files. When cross-file dependency information was available, one leading model achieved a 41.1% pass rate. Without it: 20.3%. A 2x performance gap determined entirely by whether the model could see across module boundaries. On repository-level tasks, the gap between no retrieval and perfect retrieval was 27 percentage points. Perfect retrieval doesn’t exist in practice. Current retrievers miss a substantial portion of relevant context.
And retrieval can make things worse. When retrieval pulls in similar-looking code from coupled modules, it degrades AI output by up to 15%. The model gets confused by implementations that look alike but differ in ways it can’t distinguish. This is exactly what entangled modules produce: code that’s superficially similar across boundaries but semantically distinct. The retrieval system finds the wrong “right” code, and the model treats it as context.
The hallucination data tells the same story from a different angle. Across over a thousand annotated code samples from six LLMs, a quarter of all hallucinations were classified as “Project Context Conflicts.” The model hallucinated dependencies, called functions that don’t exist in the local architecture, or misunderstood module-specific conventions. Seventy percent of functions in the studied projects depended on entities defined elsewhere. When most functions are non-standalone, and the model can’t reliably see or retrieve those dependencies, it invents them. The best retrieval-augmented mitigation improved pass rates by 3%. Three percent. The problem is structural, not retrievable.
Simpler, more self-contained modules reduce the dependency surface AI needs to comprehend. Clean APIs at module boundaries produce the kind of context that retrieval can usefully provide. Entangled modules produce noise that actively misleads. As an earlier article in this series noted, retrieval mechanisms are “easily fooled by pieces of code that are doing the same thing but look different.” That’s a coupling problem, not a retrieval problem.
The Complexity Ratchet
Everything above explains why module complexity hurts AI output. The next finding explains why it gets worse over time.
Carnegie Mellon researchers studied 806 repositories that adopted an AI coding assistant, compared against 1,380 matched controls. The velocity burst was real: lines added surged 281% in month one. It was also transient. By month three, velocity had returned to baseline. The significant development gains lasted only two months.
The complexity increase was not transient. SonarQube cognitive complexity rose 41.6% and stayed elevated. Static analysis warnings accumulated. Velocity came and went. Complexity stayed.
The panel analysis quantified what this costs: a doubling of code complexity causes a 64.5% decrease in development velocity. If a module’s cognitive complexity doubles, future work in that module slows by nearly two-thirds. For humans and for AI alike, because both depend on comprehensibility.
This creates a vicious cycle. AI generates code that is measurably more complex than what a human would have written. The module becomes harder to understand. Next time anyone works in that module, they’re slower. Teams respond by leaning harder on AI to compensate. AI generates more complex code. The loop tightens.
It is the exact opposite of what good cognitive load management looks like. The goal, as we framed it in the book, is to reduce extraneous cognitive load so that working memory is freed for the intrinsic load of the actual change and the germane load of building lasting expertise. AI-generated complexity pulls in the wrong direction. It increases extraneous load for everyone who touches the code next. It consumes the exact resource that both human comprehension and AI context processing depend on.
An earlier article in this series showed that refactored code collapsed from 25% to less than 10% of changes under AI assistance. The practice designed to manage complexity is declining at the same time AI is generating more of it. The ratchet has two directions: complexity accumulates faster while refactoring declines.
The Same Structure Serves Both
Here’s the good news. The structural investments that reduce cognitive load for humans are the same ones that improve AI output quality. The investment pays double.
Developers who report high understanding of the code they work with feel 42% more productive than those with low understanding. That’s not a vague preference. The DevEx framework identifies cognitive load as one of three core dimensions of developer experience, alongside feedback loops and flow state. Code comprehensibility is a measurable productivity lever.
Brain imaging research confirms this isn’t perception bias. Using fNIRS (functional Near Infrared Spectroscopy), researchers measured that poorly structured code significantly increases the brain’s processing effort. The effect isn’t local. It spreads beyond the problematic code to the entire surrounding snippet. Structural complexity taxes everything it touches.
The metric that captures this, SonarQube’s Cognitive Complexity, correlates at r = 0.654 with actual comprehension time across 24,000 human evaluations. That’s the same metric the CMU study used when it found AI increasing complexity by 41.6%. What predicts difficulty for humans predicts difficulty for AI. The measurement is the same because the underlying constraint is the same: comprehensibility.
At the architectural level, well-modularized systems have 6-8x lower change propagation costs than tightly-coupled ones. A change in a tightly-coupled system ripples 6-8x further than in a well-modularized one. Under AI acceleration, with several times more changes flowing through the system, that propagation multiplier becomes the difference between a codebase that absorbs AI output and one that cascades failures across modules.
Tidy code. Clear boundaries. Low coupling. High cohesion. Continuous refactoring. These are the practices the book advocates for managing cognitive load in software product development. They are also the structural prerequisites for effective AI-assisted development. Not because AI was designed around them, but because AI and human developers share the same fundamental constraint: comprehensibility determines output quality.
The Readiness Question
Pick a module in your codebase. One that an AI assistant might be asked to modify.
Count its imports. Count the files you’d need to open to understand what it does. Count the functions that reference types, constants, or behaviors defined in other modules. If your IDE can draw the dependency graph, look at it.
If you need to read five modules to understand one, that module isn’t AI-ready. It’s also not human-ready. It’s familiar to the people who built it, and they’re compensating for the extraneous cognitive load with germane knowledge they’ve accumulated over months of working in that code. They’ve memorized the dependencies. They know which inventory functions are deprecated and which notification contracts are current. That knowledge lives in their heads, not in the structure.
AI doesn’t have months. It has one context window. And every module it needs to read beyond the first one degrades its output quality in ways that are now quantified: 29% down to 3% as context grows. A 2x performance gap based on whether it can see the dependencies. A quarter of all hallucinations caused by module boundary confusion.
The organizations that will get the most from AI-assisted development aren’t the ones with the best AI tooling. They’re the ones whose modules can be understood in isolation. The same investment that makes code maintainable for humans makes it comprehensible for AI. The same structural neglect that slows your developers will cripple your AI output.
The book frames the challenge as navigating complexity while building resilient software organizations. AI makes it urgent. Module complexity that accumulated over years is now visible in weeks, because AI fails faster and more obviously than a human developer who quietly compensates through hard-won familiarity.
The complexity was always the problem. AI just runs out of patience first.



Module-level cognitive load is a useful framing because it keeps AI readiness from becoming abstract. In OR-adjacent workflows, I would want the same inventory: which step adds another alert, which step removes coordination work, and where uncertainty still needs a human owner.