Deep Modules and AI-Ready Codebases

Matt Pocock's latest video makes the case that your codebase, not your prompt or AGENTS.md, is the biggest influence on AI output. He suggests applying deep modules, from John Ousterhout's A Philosophy of Software Design. Big chunks of implementation behind simple interfaces. He treats AI as a new start joining his team with no memory, dropping into a codebase fresh every time.

Again, I recognise this as something software engineers have been doing for decades. Good software design has always included making intent obvious for the next person. Just now, the "next person" just happens to be an agent. Good code that teaches AI is also good code that teaches humans.

An example is CQRS. My service layers are essentially a collection of commands and queries. Commands tell you exactly what is needed to perform a behaviour. Queries tell you exactly the data you can get. Humans have always been able to skim this and immediately know what the service does without knowing any another details. Agents consuming these services can also quickly understand what it does and how to do it. There is no need for documentation because the interface is the documentation, with each service boundary being akin to a deep module.

I think this is the whole point Matt's making. If your codebase lets agents read the interface first and only dig into implementation when they need to, they spend less context figuring out where they are and more on the actual work. He touched on this in his subagents video too.

I've also been thinking about how all this pairs with Domain-Driven Design and Event Sourcing, more practices we've been doing for decades with similar benefits. These patterns aren't new, but we do have a new lens to consider them.