SDD: From Vibe Coding Chaos to Architectural Rigor
2026-05-17 · [ leer en español ]
In the beginning, the programmer wrote code by hand, line by line. And the software was without form, and full of bugs. And darkness was upon the face of the Friday deploy, for the legacy code lurked there. Then came the language models and the AI agents, and the community cried out: "Let there be prompt!" And all of a sudden we found ourselves in the wonderful world of vibe coding: toss three casual sentences at Cursor or Claude, watch five hundred lines of code autocomplete themselves like magic, and pray it compiles on the first try.
I'm going off on a tangent again... Back to the present.
The harsh truth is that coding by riding an AI's momentum works great for a weekend prototype, but in a medium or large project it turns into a nightmare you can't sustain. Today's AI agents are incredibly fast and efficient, but if you don't give them clear limits, they drift toward improvised results, create coupling nobody asked for and end up making a mess of your architecture. SDD (Spec-Driven Development) was born out of the need to tame these intelligences and put development back in charge.
A bit of history: from tests to behavior, and from there to the spec
To see where SDD fits, it helps to take a trip back in time and remember its better-known cousins:
- TDD (Test-Driven Development): Popularized by Kent Beck in the early 2000s, it taught us the holy trinity of Red, Green, Refactor: write the unit test before the code. It was a revolution for guaranteeing low-level technical quality, though it sometimes made us lose sight of the product as a whole because we were so focused on the function in front of us.
- BDD (Behavior-Driven Development): A few years later, Dan North decided we should speak a language the business could understand. He brought along the Given-When-Then scenarios. So we went from testing isolated functions to testing how the system behaves.
(Both links go to older articles of mine, which are in Spanish.)
What about now? In an era where we hand the mechanical work of writing code to autonomous agents, testing or describing behavior in isolation falls short. Before touching a single file, you need to define the constraints and the context the agents will work with. That's how you avoid mistakes like the ones in the next section.
What goes wrong with vibe coding: when the AI is the one leading
Don't get me wrong, vibe coding saves us a lot of time and lets us focus on what matters. Few things are as satisfying as throwing a prompt at an agent and watching it spit out in seconds what used to take you a whole afternoon. The trouble starts when we let the AI make every decision:
Silent architectural drift
You ask the agent to implement feature A, and it works. Then B, and that works too. But when you get to C, it turns out A and B left the code in such a state that you have to rewrite half the project to fit the new one in. The agent has no big picture, since it solves whatever you ask for here and now, and the overall design starts to rot.
Frankenstein's monster syndrome
Every prompt produces code with its own style, its own abstractions and its own idea of how the project should be structured. A few weeks later you have a monster stitched together from scraps, where three different ways of handling errors live side by side with two data access patterns and a service the AI suggested that you can no longer tell is a repository, a use case or who knows what.
Invisible coupling
When you don't set some clear boundaries, the agent starts taking shortcuts. Needs data from another module? It imports it directly. A utility function? It drops it wherever is closest. Before you know it, you have dependencies crisscrossing everywhere and one refactor burns through your tokens in no time.
The illusion of speed
This one is the sneakiest. For the first few weeks everything flies: features shipping at breakneck speed, impressive demos, productivity metrics through the roof. But the technical debt piles up quietly, and when it blows up (always at the worst possible moment, of course), you pay back the time you "saved" with interest.
A simple "let users sign up" will probably get you code that works... and that's a pain to maintain.
So what is SDD, anyway?
To steer clear of the little problems above, SDD (Spec-Driven Development) comes knocking (ding dong, Avon calling). In this methodology, the main artifact and the "single source of truth" is an executable, versioned spec in your repository (usually structured Markdown). You design the architecture, the use cases, the system boundaries and the acceptance criteria. From that documentation, the agent can draw up a plan and generate code that sticks to those rules.
There are patterns for writing that Markdown, like EARS. That's practically a post of its own. Luckily, Oguz Senna already wrote this article breaking down the main points.
How to apply SDD step by step
I'm sure the previous section gave you the general idea. The theory sounds good. But the abstract concept is not enough. What matters is knowing where to start, or SDD becomes one more pretty acronym for the collection. So let's get to it: how do you apply this day to day on a real project?
1. Create a specs directory
First, your specs need a place to live. As simple as creating a specs/ folder (or docs/specs/, whatever you like, the name hardly matters). The key is that the specs live next to the code and get versioned with it. Avoid having documents scattered across Confluence, OneDrive, Google Drive and friends.
2. Define the architecture before writing code
Before you fire the first prompt at the agent, sit down and design. That doesn't mean writing a hundred-page document. It means making clear:
- The main modules or components and what each one is responsible for.
- The public interfaces between them: what data goes in, what comes out and which contracts hold.
- The technical constraints: which database you use, which framework, which architectural patterns you follow (hexagonal, layered, microservices...).
- The system invariants: the rules that can never be broken, no matter what.
This is the step nobody feels like doing, but trust me, it's the one that will spare you the most grief.
3. Write the specs by use case
This is where SDD gets interesting. For each feature or use case, create a structured Markdown file that includes:
- Context: what problem it solves and why the feature exists.
- Functional requirements: what it has to do, step by step.
- Acceptance criteria: how to tell it's done right (yes, the good old Given-When-Then from BDD).
- Constraints: what it must not do, what its limits are, which modules it can't touch.
- Dependencies: which other components or services it needs.
The spec is the contract between you and the agent. The clearer it is, the less room the AI has to improvise and the more predictable the result.
4. Feed the spec to the agent
When you ask the agent to implement something, don't just throw a prompt into the void. Point it straight at the spec: "Implement the use case described in specs/user-signup.md, following the architecture defined in specs/architecture.md". That way the agent has a clear frame and doesn't need to make anything up.
A lot of the time you'll already have a file that defines part of the architecture and the most important bits. For example, CLAUDE.md in Claude Code. Just remember that file shouldn't be War and Peace, because it gets loaded into the context with every request.
5. Validate against the spec
Once the agent generates the code, don't review it with a "let's see how it looks" attitude. Compare what it produced with what you specified, point by point: does it respect the interfaces? Does it meet the acceptance criteria? Did it skip any constraint? If something doesn't add up, you'll either have to fix the implementation or, if you find the spec was incomplete, update it and ask the agent to review whatever changes apply.
6. Iterate and keep the specs alive
Specs aren't static documents you write once and forget. In a living project, the domain may change, new requirements show up, or you discover an edge case you hadn't thought of. When that happens, the spec has to be updated. If the code evolves but your spec is still a Pikachu, you'll end up in the same place as with traditional documentation: stale files that raise more questions than they answer.
The danger of the floating blueprint: why SDD needs DDD
Handing code generation over to an SDD spec sounds idyllic, but it has a weak spot when it's applied in a conceptual vacuum. An AI agent can read your purely technical spec, assume it has followed it to the letter and hand you a whole set of flawless files... that, when push comes to shove, don't work together or fall over on the edge cases.
That's why combining SDD with DDD (Domain-Driven Design to its friends) is what keeps you from ending up with software that may be technically spotless but conceptually very fragile. In short:
Writing SDD without DDD is like sketching a blueprint freehand. At first glance you can tell what's supposed to be built, but once construction starts, structural inaccuracies will show up, and sooner or later the building will come down.
When you combine both methodologies, the specs the AI reads get a semantic frame that can't be broken. The process stops being "writing code from some random technical spec" and becomes a much smarter flow:
1. Model the domain (DDD)
- Draw the bounded contexts.
- Define the ubiquitous language with the business team.
- Protect the rules with aggregates, entities and value objects.
2. Specify (SDD)
- Turn the strategic design into clear, structured specs for the AI.
- Use the exact domain terms you've just pinned down.
3. Implement
With the two previous steps done, the agent should generate the technical solution while strictly respecting the context boundaries and the invariants of your model.
If you don't apply DDD first, SDD becomes a hyper-speed machine cranking out orphaned, coupled code with mutant models that don't even talk to each other. DDD lays the groundwork so you have the right language and the right rules, and SDD keeps the AI from improvising the architecture and the invariants.
When NOT to use SDD (or the art of not swatting flies with a bazooka)
Like any tool, SDD has its time and place. And what happens when you don't use the right tool? Ask your neighbors next time you hang a picture with a jackhammer. There are scenarios where setting up all the paraphernalia of specs and domain modeling is a monumental waste of energy:
Small, localized changes
If you need to add a field to a form, change the text on a button or tweak a one-off validation, today's LLMs are perfectly capable of figuring out the project structure on their own. Give them the file for context and a clear instruction, and the agent will know what to touch without a ten-page spec. Save the bazooka for targets that deserve it.
Fixing bugs
Here my recommendation is a sort of express TDD that works beautifully with any AI agent:
- Write the test first: write the test case that reproduces the wrong behavior and will therefore fail. If it's red (remember TDD), the bug is properly reproduced.
- Give the agent its instructions: describe the problem, point it at the red test and let it track down the root cause and propose a fix.
- The test has to go green: if the agent did its job, the test will pass. If not, you'll have to dig in (unless you'd rather declare that it's not a bug, it's a feature...).
What I like about this flow is that the test itself becomes the spec for the bug: what was supposed to happen, what was actually happening and when it got fixed.
Prototypes and experiments
If you're putting together a PoC (proof of concept) or exploring whether something is technically feasible, the spec can wait. In that context, vibe coding is perfectly legitimate. The trouble comes when the prototype, instead of being thrown away after it's validated, ends up becoming the product.

Wrapping up
As I keep saying until I'm blue in the face about SOLID, DDD and other patterns: "they're not religions or absolute truths". You always have to weigh how and when to apply them depending on the case.
Because if you overdo the definition, you can fall into the trap of trying to document every last detail of the application before writing a single line, which will raise the ghost of Christmas past, better known as the good old waterfall model (I still get chills just thinking about it).
SDD is a fantastic tool for working hand in hand with today's AI tools without losing control of your architecture. Because yes, the AI brings the speed, but you still bring the technical judgment. Remember: power is nothing without control.
All of this is turning into a book: AI-Assisted Development in a Zombie Apocalypse, the third in the series. I'm still writing the Spanish edition, and the English one comes after it. If you want to hear when it ships, follow the author on Amazon: the shelter doesn't send email, but Amazon does.