Most of us now work with AI coding agents using Spec-Driven Development (SDD): write clear requirements, let the agent ask clarifying questions, then generate the code. It's far more reliable than vibe coding.
But SDD has a gap. The spec tells the agent what to build. It doesn't tell you whether what was built is correct.
For a to-do app, that's probably fine. For a financial application, it isn't.
Why Financial Code Is Different
Consider a discount calculator with:
- Customer tiers (Standard, Silver, Gold), each with different discount levels
- Promo codes
- Line-level discounts
- Order-level calculations that combine all of the above
If the agent gets one rule slightly wrong, you might be five cents out on an invoice, or a couple of percentage points off in one edge case. Nobody notices until a customer does.
A detailed spec is necessary, but it isn't sufficient. A strong model might produce correct code on the first try, but "probably correct" isn't acceptable when money is involved. You need concrete, automated tests that prove every tier, every promo code, and every combination of rules is calculated correctly.
What Traditional TDD Got Right
Classic TDD forces you to think about each method's behaviour before writing it. Through red-green-refactor, you build a code-level specification as you go.
SDD works at the opposite end. It focuses on the requirements level, making sure the what is clear.
Strict TDD, with its failing-test-first loop, can feel too slow for AI-assisted work. Modern models don't need to circle a failing test to produce working code. Given strong requirements, they can often generate the implementation directly.
So I use a middle path.
Test-First, Not TDD
This is not TDD. "Test-first" here doesn't mean "write an executable test before any production code." It means:
Write the test specification first.
You move the initial test design to a higher level of abstraction. At this stage, you don't need to decide whether a scenario becomes a unit, integration, or acceptance test. You just need clearly stated, human-readable scenarios describing what must be verified.
Here's what a test spec entry might look like:
discount_applicability:
- id: TS-DISC-001
scenario: Gold tier customer receives tier discount on order above minimum
given: customer tier is GOLD and order subtotal is above the minimum threshold
expect: tier discount is applied to the order subtotal
traces_to: REQ-TIER-003
- id: TS-DISC-002
scenario: Promo code does not stack with tier discount
given: customer tier is SILVER and a valid promo code is applied
expect: only the greater of the two discounts is applied
traces_to: REQ-PROMO-007
Notice what's missing: no decision about test type, no test code. Each scenario traces back to a requirement, which is what makes the reviewer's job possible.
The Four Artifacts
- Requirements Specification: What are we building?
- Test Specification: What must be verified?
- Production Code: The AI-generated implementation.
- Concrete Test Suite: Executable tests derived from the approved test spec.
The Workflow
1. Start with a robust requirements spec. It has gone through SDD. The agent's clarifying questions are answered and ambiguities are resolved.
2. Write the test specification. Create human-readable scenarios grouped by area: discount applicability, tier rules, promo handling, line-level discounts.
3. Review the test spec against the requirements using a different model. This is the first checkpoint. A separate model, not the one doing the implementation, checks that the test spec covers the requirements. A human oversees this too. You're confirming the two documents match before any code exists.
4. Generate the production code and the concrete tests. Once the test spec is approved, the executing agent generates the implementation and the test suite. Here I take a little leeway compared with strict TDD: since the test spec is already reviewed, the production code can be generated first so the tests have something to run against. The source of truth throughout is the requirements and the test spec, not the code.
5. Run an independent review. A different model reviews the code and tests against the original specs. Then you run the tests and check the results.
Why a Separate Reviewer Matters
If the same model writes the code, writes the tests, and reviews both, you've built an echo chamber. A misreading of the requirements gets baked into all three. A different reviewer gives you independent verification, the same reason we don't let developers be the only reviewers of their own PRs.
In my demo I used a modest, free model as the executing agent and a different free model as the reviewer. The model choice matters less than the independence of the review.
Takeaway
SDD makes sure the AI knows what to build. Test-first development makes sure you can prove it built the right thing.
For low-stakes projects, SDD alone may be enough. When precision matters, add a reviewed test specification and an independent verification step. It's a small amount of extra work for much more confidence.
Have you added test specifications to your AI workflow? I'd like to hear how it went in the comments.
Top comments (0)