Here is how most work with a coding agent goes. You describe a feature in a sentence, the agent writes something, you look at it, you say “not like that, the discount should apply before tax”, it rewrites, you notice it broke the export, you ask for a fix, and forty minutes later you have working code and a chat history that nobody will ever read again. The decisions are in there somewhere. Good luck finding them in March.
Spec-driven development is the boring fix for that. You write down what the thing has to do before anyone, human or agent, writes code. The spec lives in the repository next to the code, gets reviewed like code, and the agent implements from it. When something changes, you change the spec first.
It is not a new idea. It is the old idea of writing requirements, picked up again because agents turned out to be the first programmers who actually read them.
What it looks like in a repository
The shape that has settled over the last year is three small documents, usually markdown, usually in a folder per feature:
- A spec. What the feature does and why, in plain language. Who uses it, what it must do, what it must not do, and how you will know it works. No stack, no file names. A product person should be able to read it and say “yes, that”.
- A plan. How it will be built: the parts of the system it touches, the data, the interfaces, the decisions you made and the ones you rejected. This is where “we store it in a custom table, not post meta, because of the query in the report” gets written down once instead of being re-argued every session.
- Tasks. The plan broken into steps small enough that an agent can do one, run the tests, and stop. Ordered, with dependencies. Each one is a session or less.
Then the agent works through the tasks. You review diffs against the spec instead of against your memory of what you asked for. If the agent does something strange, the first question is not “why did it do that” but “what in the spec allowed that”, and you fix the spec.
Tools have grown around this. GitHub’s Spec Kit gives you slash commands that walk a repository through constitution, spec, plan, tasks and implementation. AWS built it into Kiro as requirements, design and tasks files that the editor keeps in step. Others are building registries so a spec can be shared and versioned like a package. None of that is required. Three markdown files and the discipline to update them is the whole method; the tools just make it harder to skip steps.
Why it works better with agents than it did with people
Requirements documents got a bad name because people did not read them, the code drifted away from them within a month, and keeping them current was a job nobody wanted. Agents change two of those three things.
An agent reads the spec every time, in full, with no memory of last week. That is a weakness when the knowledge lives in your head and a strength when it lives in a file. It also means the spec is the only thing that survives a change of model or tool. The chat history from one assistant is useless to the next one. The spec is not.
The other change is where ambiguity gets caught. Agents fail mostly by filling gaps with plausible guesses: a default you never set, an edge case you never mentioned, a library they like. A spec review before any code exists catches those gaps when fixing them costs a sentence. Catching them in a diff costs a rewrite, and catching them in production costs a weekend.
A real-sized example
Take a job I get asked for often: keep the stock of an online store in step with a warehouse system. The prompt version is “sync stock from the ERP to the store every fifteen minutes”. The spec version takes twenty minutes to write and reads something like this:
- Stock flows one way, from the warehouse system to the store. The store never writes stock back. This is a non-goal, written down, because somebody will ask for it in month two.
- A product is matched by SKU. A SKU that exists in the warehouse and not in the store is logged and skipped, not created.
- If the warehouse API is unreachable, stock stays as it was. Nothing is ever set to zero because of a failed call.
- Variations are updated individually. The parent product’s stock is never written.
- Every run writes one line to a log the owner can read: when, how many products changed, how many were skipped, and why.
- Done means: a test suite covering the five cases above, a dry-run mode that reports without writing, and a run in staging against real warehouse data with the owner watching.
Every line in that list is a decision that, left to the agent, would have been made silently and sometimes wrongly. The one about never setting stock to zero on a failed call is the one that matters most, and it is the one a one-sentence prompt never produces. The plan then says which API endpoints, which table holds the run log, how the schedule is triggered and what happens if two runs overlap. The tasks are maybe eight items. The agent does them one at a time and the tests tell both of us when a task is finished.
Where it goes wrong
The failure modes are mostly the old ones wearing new clothes.
- Ceremony for a two-line change. Fixing a typo does not need a spec. If the change fits in a commit message, the commit message is the spec. Save the method for anything that has behaviour.
- Specs nobody reads. A forty-page document is a sign that the feature is too big, not that the spec is thorough. If you cannot read it in ten minutes, split the feature.
- Letting the agent write the spec and nodding. Agents are good at drafting a spec from a conversation, and that draft is a fine starting point. The failure is approving it without reading, because then the agent is checking its own homework and the guesses are now official.
- Drift. The code changes under pressure, the spec does not, and three months later the spec describes a system that no longer exists. The only cure is the rule that a change to behaviour starts with a change to the spec, enforced in review like any other rule.
How I use it on client work
For the projects I take on, the spec does a second job: it is the proposal. The client reads a document that says what will be built, what will not, and how we will both know it is done. They approve that instead of approving code they will never read. The tasks become the lines on the quote, and if the scope changes we change the spec and the quote together, with no argument about what was agreed, because it is written.
It also sets the agent’s limits for anything that keeps running after I leave. A sync job, a chatbot on the product pages, an agent that files tickets: each one gets a short document that says what it may do, with which data, under what limits, and what happens when it goes wrong. I call that an Agent Operating Procedure, and it is a spec for software that acts instead of software that renders. There is a page about it if that is the problem you have.
If you want to try the method without any tooling: next time you are about to type a feature request into an agent, open a new file instead, write the request as five to ten lines of “it must” and “it must not” and one line that starts with “done means”, and paste that. You will notice the difference in the first diff.
Let’s see if we should work together.
Thirty minutes, no pitch.
Or email hello@samuelsilva.pt