Software Design for AI Agents
With coding agents, many people now feel that code has stopped being valuable: write a good specification, let the model generate the code, and if something breaks, edit the spec and regenerate. You never need to care what the code looks like. Call this view "Spec-to-Code."
But when a codebase gets messy, the agent gets lost too. Once developers stop looking after the structure, local patches pile up and the same logic is written again in several places. Borrowing from The Pragmatic Programmer, the talk calls this drift toward disorder software entropy. A messy codebase does not get better because AI is involved; the agent cannot find its way through tangled dependencies, and the more it changes, the faster the mess grows.
So AI coding has not made classical software engineering obsolete; it has made good architecture worth more. In his AI Engineer Europe 2026 talk (Bilibili re-upload), Matt Pocock lists five common failures in AI-assisted programming and pairs each with a remedy from classic software design.
The five sections below share one imagined scenario: you maintain an e-commerce order system and ask an agent to add a "refund" feature to orders.
If the requirements are not drawn out, the model builds a different feature
You say "add refunds," and what you have in mind is that shipped orders can only be partly refunded and need a support agent's approval. The agent reads it as "any order can be fully refunded in one click," and ten minutes later hands over a refund button, a new table, and changes across twenty files. The code runs, but it is a different feature; the model may even have settled on a plan and written a large batch before you finished explaining.
The trouble is that the rules in your head never entered the conversation. The talk draws on Frederick Brooks' The Design of Design: when several people (or a person and an AI) design together, what matters most is not the text on paper or in Markdown but the shared understanding in everyone's head of how the system works and where its boundaries lie. Brooks calls this the design concept.
To build that shared understanding before any code is written, use grill-me or grill-with-docs from the mattpocock/skills repository (see also its engineering skills index and the AI Hero Skills newsletter) to have the model interrogate you instead:
- The shared
grillingprocedure maps a decision tree and asks the currently unblocked questions in rounds, with a recommended answer for each; grill-with-docscombines that interview with domain modeling: each resolved term goes intoGLOSSARY.mdon the spot, and it offers an ADR (architecture decision record) indocs/adr/only when a decision is hard to reverse, surprising without context, and the result of a real trade-off;- After alignment, the separate
to-specandto-ticketscommands can synthesize the current conversation into a specification or tracer-bullet tickets.
In the refund example, as soon as it asks "can a shipped order be fully refunded?", the disagreement surfaces before the first line of code.
When one thing has three names, the code grows three implementations
You ask the agent to add a refund state to orders. It creates RefundStatus, but the codebase already has OrderState.REVERSED, and from then on two sets of states coexist. It gets worse: you say "refund," the model writes cancel, and the finance system calls it reverse. Three words for one thing become three functions in the code.
Without shared words, the model has to describe "an order whose payment was returned after shipping" with a long phrase every time, so its answers grow longer and its names drift further from the business. The talk cites Eric Evans' Domain-Driven Design and its Ubiquitous Language: domain experts, developers, and code use one set of clearly defined words, and each thing has exactly one name.
The practice is to write that vocabulary down and put it in the agent's context:
- Extract the core concepts of the codebase and the business, by scanning or by hand, into a Markdown domain glossary (such as a
GLOSSARY.mddefining entities, operations, lifecycle states, and explicit definitions; before mattpocock/skills 1.3.0 the file was calledCONTEXT.md). The refund entry could read: "Refund (reversal): the order moves toOrderState.REVERSED; do not create a separate refund or cancel state." - Keep this glossary in the agent's context during conversation, planning, and refactoring;
- Once terminology is consistent, the model's reasoning no longer circles around descriptions, so it gets shorter, and the implementation stays bound to the domain model.
When feedback lags, faster generation means errors travel further
The agent writes 500 lines of the refund flow in one go: endpoints, amount calculation, state transitions, notification emails. The structure looks complete. You run it, and the very first request fails: the front end sends amounts in yuan, while the database stores fen (hundredths of a yuan). The mistake is in the first few lines written, the hundreds of lines after it are built on top of it, and the rework means taking it apart from the start.
The talk borrows a metaphor from Andrew Hunt and David Thomas's The Pragmatic Programmer: don't outrun your headlights. Driving at night, how far your headlights reach decides how fast you can safely go. Software is the same: you can only move as fast as you get feedback.
So make the agent get feedback after every small step:
- Static types and runtime environments: use TypeScript or another strong static type system, and give the agent environments such as a browser or terminal where code runs immediately;
- Test-Driven Development (TDD):
- Write a test first, stating the expected input and output;
- Run the test and confirm that it fails now (red);
- Have the agent write the minimal implementation that just passes (green);
- Refactor and improve the internal design.
- TDD forces the model forward one small step at a time. The first refund test might be "refund 30 yuan; the refund record stores 3000 fen." It fails at step one, the yuan/fen mistake is caught on the spot, and the hundreds of later lines have not been written yet.
The finer the code is cut, the harder it is for the agent to trace the call chain
The refund logic is spread across a dozen small files such as calcRefund, validateRefund, refundHelper, and applyRefundState. Each has a few lines and they call one another. To change one refund rule, the agent first has to read all of them into its context; by the time it has, a large share of the context window is gone and the call chain is still unclear.
The talk brings in John Ousterhout's A Philosophy of Software Design and its two shapes of module. What a module exposes is its interface: everything someone else must know to use it. What it keeps inside is its implementation.
- Shallow Modules: the interface is relatively complex but the module does little inside; learning the interface costs about as much as writing the code yourself, and reading the code means jumping back and forth;
- Deep Modules: a small, stable interface hides a large amount of complex logic and state.
Ousterhout's own example of a deep module is Unix file I/O. A program reads and writes files with just five system calls: open, read, write, lseek, and close. How files are laid out on disk, how directories are looked up, how permissions are checked, which data is cached in memory, and in what order requests go to the disk are all hidden behind those calls.
Different devices such as terminals and disks use the same calls, and device-specific operations go through one extra call, ioctl (see his modular design lecture notes for Stanford's CS190).
The refund logic can be gathered into one module the same way, for example exposing only two entry points, requestRefund and approveRefund:
- Use
improve-codebase-architectureto scan for modules that can be deepened, apply the deletion test, and refactor scattered helpers and intermediate state into deep modules; - Design the module's external interface contract carefully and keep it as small as possible;
- Put clear testing boundaries at the interface and hide internal details. Then, to change a refund rule, the agent reads only this one module and does not need to know the whole repository.
Do this refactoring before handing the agent complex tasks: once shallow modules have become deep ones, the agent finds its way more easily.
When humans cannot keep up with review, review only interfaces and tests
The agent hands over thirty changes a day, each a few hundred lines. If you read every line of syntax and local logic, you are worn out by the fifth; after that you glance at the title and click "approve," and review becomes a formality.
The talk quotes Kent Beck: “Invest in the design of the system every day.” The value of software engineering lies in weighing system boundaries, data flows, and component responsibilities, not in typing code character by character. The time saved from line-by-line review should go there.
The division of work looks like this:
- Gray-box delegation:
- In non-critical modules, treat a deep module as a "gray box": you see the interface but do not read the inside line by line;
- The developer owns the external interface contracts and integration-test boundaries, and hands the module's internal implementation to the agent;
- On high-risk core paths such as financial calculation, security and authentication, and infrastructure, keep strict white-box review, meaning someone reads the implementation line by line. In the refund example, the agent can own how the notification email is laid out, but a person must read every line of how the refund amount is calculated.
- Role separation: the human acts as Strategic Architect, breaking down requirements, designing interfaces, and setting acceptance criteria; the AI acts as Tactical Programmer, filling in code and running tests inside the interface contract.