Getting my hands dirty with spec-driven development

TL;DR — I built a small SQS DLQ replayer with OpenSpec. I liked being forced to refine the requirements before any code existed, and having specs that stay in the repo and evolve with each change. But for a tool this size it was slower than Claude's plain plan mode, and you have to review everything, not just the specs.


Why I tried it ?

For a while now, I’ve been working with Claude Code using an explore/plan/code cycle, and it works well for me. But I had never really tried spec-driven development. Recently I had a small technical debate about it with a colleague, and I realised I was arguing about something I had never actually used. So I decided to get my hands dirty.

Before starting I read Birgitta Bockeler’s article on Martin Fowler’s website (https://martinfowler.com/articles/exploring-gen-ai/sdd-3-tools.html), which compares Kiro, spec-kit and Tessl. The part that stuck with me is the three levels of SDD:

  • Spec-first: you write a spec before the code, use it for the task, and that’s it.
  • Spec-anchored: the spec stays after the task and is updated as the feature evolves.
  • Spec-as-source: humans only edit the spec, and the code is generated from it, never touched.

Picking a tool

I looked at Kiro, Tessl and OpenSpec, and went with OpenSpec for this experiment for three reasons:

  • It’s very lightweight: It’s a small CLI that instals a few commands in the AI tool you already use. No new IDE, no extra tool.
  • It works on existing projects, not only new ones: Every change is written as a delta
  • Tessl’s philosophy is a level above: it goes for spec-as-source. I’ll get back to that at the end.

The problem

When a consumer behind an SQS queue fails for longer than the retry window, its messages end up in the dead-letter queue.

SQS has a redrive feature, but it moves the whole DLQ back to the source queue. I needed more logic than that: replay only the messages where a given key has a given value, see what’s in the queue before moving anything.

It’s a small, well-bounded tool, but a few nasty details. I thought it was a good candidate.

How OpenSpec works

I won’t go into the details of how OpenSpec works, it’s pretty straightforward and the docs do it better than me. Here is what you need to follow the rest of this post:

  • Two folders: openspec/specs/ describe how the system behaves today, and openspec/changes holds the changes being worked on
  • One loop per change: explore (talk the problem through with the agent), propose (it drafts a proposal, specs a design and a task list), review (this is where you have to review everything), apply (implementing the tasks) and then archive (the change’s specs are merged into openspec/specs/)
  • A config.yaml lets you add your own rules that the agent follows when it writes those files

Two features instead of one

I decided to split the problem into two changes. To be honest, the agent pushed for it during exploration, and the argument was good:

- First, inspect: a dry run that scans the DLQ and shows a histogram of what's inside (which values, how many messages), without moving anything.
- Then, replay: the part that actually sends messages back and deletes them from the DLQ.

The scan loop is where the subtle bugs are (SQS sampling, visibility timeouts, double counting), so it makes sense to find them on a run that can't delete anything.

What happened along the way

  • Exploring: I started with only our small design page as input, and the recommendations were pretty generic. Once I pointed the agent at one of the services consuming the queue, our Terraform repo and how we deploy jobs, it got much more concrete.
  • Reviewing: This took longer than I expected. While going through the design, I found a bug: the spec said a dry run must leave the queue exactly as it found it, but the design would have left some messages hidden. Later I also noticed that a few design decisions never made it into the task list, and the agent simply skipped them.
  • Applying: The first change came back with lots of mocked unit tests and very few integration tests, even though we had agreed on the opposite. I fixed the tests, and added a rule to config.yaml so the plan always says which kind of test each task needs. On the second change, it did.
  • The second change: This is where spec-anchored clicked for me. The agent didn't start from scratch: it updated the specs from the first change, modifying or removing the requirements that no longer held.
  • The result: It works. In our test environment, I filled a dead-letter queue with 25,000 messages, ran a dry run to see what was inside, then a replay with one match. It moved exactly the messages that matched, and every other message stayed in the DLQ.

My takeaways

A word of caution first: this is based on a small technical tool I built, not a real business project with lots of business rules, and on only two iterations. I think that's exactly where SDD could shine: lots of rules to agree on, several people involved, and specs that keep evolving over many changes. So take the following with that in mind.
  • Overall it's impressive, mostly because it enforces a process.
    With Claude Code, planning is optional: nothing stops you from jumping straight into the code and on a busy day, that’s exactly what happens
  • The spec lives next to the code, which is easy for the agents to use. Every new session starts from the same source of truth instead of whatever was in my head that day.
  • Scope matters. After the first exploration I had to make several changes to the artifacts, with a lot of back and forth, and when I ran apply a lot of the coding principles we had agreed on were ignored. I think I should have gone even smaller.
  • It's a light framework, but it adds a lot of orchestration. The first change produced about 1,000 lines of production code. The replay is a small feature on top of that, on paper one new class and a few hooks in the scan loop. Yet its plan was around 8,400 words of markdown to review. For a tool this size, I'm pretty sure Claude's plain explore / plan / execute cycle would have been at least faster.
  • The agent still drifts from the plan. Writing the spec didn't stop apply from ignoring principles we had agreed on. Specs don't replace code review, they move part of it earlier.
  • The cognitive debt is real (but that's an AI thing, right?). the skill I mentioned earlier is my way of paying it back before I archive.
  • What plan mode doesn't give you is memory. Plan mode's plan dies with the session. OpenSpec's specs stay in the repo, and every change updates them. The question is whether that's worth the ceremony ..

What about spec-as-source?

In her article, Birgitta compares spec-as-source tools like Tessl to model-driven development (MDD): the code is generated and should never be touched. I tried MDD back at university with the Eclipse Modeling Framework. In theory it was interesting, and I can understand why it never took off. But at least it was deterministic: the same model always gave the same code. With an LLM in the middle, that's not guaranteed anymore.

I still need to explore that properly, and it will be my next exercise.

Paying back the cognitive debt

An agent wrote most of this code from the specs, and I didn't read every line of it. That's a debt: the code exists, but my mental model of it doesn't. So before archiving a change I run a skill I wrote for that, inspired by this article.

It's read-only. It reads the change (proposal, design, tasks and spec deltas), the specs as they were before, and the commits that implemented it. Then it builds a single page:

  • Background and why: what the tool did before, and the problem the change solves, in plain words.
  • Intuition: the core idea on a toy example, a DLQ of five messages walked through end to end, plus every design decision in one line (what was chosen, what was rejected, and why).
  • The code: in the order a run executes it, not in file order, with each step linked to the scenario it serves.
  • Traceability: a table mapping every spec scenario to the code that implements it, the test that covers it and its level. Below it are the gaps: scenarios with no test, code no scenario asked for, code that differs from the design. This part also helps with drift.
  • If it breaks: the three places I'd look first.

Then it quizzes me in chat, Socratic style: five questions, one at a time, answered in my own words. When I get one wrong, it doesn't give me the answer. It asks the question that makes my contradiction visible. I need four out of five before I archive, and it never archives for me.

More reading, yes, but at this stage, I’d rather be quizzed by an agent now than by a production incident later.