Markdown is a great spec, so the AI always follows it, right?
TL;DR: Turn each requirement into an executable acceptance test, and let a red test tell the AI it missed the spec.
Common Mistake ❌
You write a clean spec in Markdown and hand it to the AI.
The AI writes the code.
Then you run the system by hand and compare it with the spec, line by line.
The AI skipped a line this morning.
You miss the same line on Friday afternoon.
You automated everything except the checking.
Problems Addressed 😔
The AI skips or misreads a line of the spec, and you find out in production.
You verify by hand, so every change costs another manual round.
The Markdown stops being true, and you don't notice.
You read the diff and guess the requirement behind it.
You stop trusting the AI and recheck everything.
How to Do It 🛠️
Pick one requirement from your Markdown spec.
Write it as an acceptance test that fails today, before the AI writes any code.
Name the test after the behavior in the spec, so the failure message reads like the requirement.
Show the AI the failing test, and ask it to make it pass without touching the test.
Run the suite inside your harness and let the AI read every red test.
End every task with a criteria check that fails while a spec test is red.
Review the tests yourself, line by line, since the AI can misread the spec in a test as easily as in the code.
Keep the Markdown, and update it together with the tests when a requirement changes.
Add a regression test every time production teaches you a case the spec forgot.
Benefits 🎯
Verify without you: The test tells you if the AI followed the spec, and you stop clicking through the system.
Catch misreadings early: A red test shows the gap before the release.
Let the AI retry alone: It reads the failure, fixes the code, and runs the test again.
Keep the spec alive: A spec that can fail can't quietly go stale, and specs aren't carved into stone.
Review the requirement: You check the test against the requirement before you open the diff.
Context 🧠
Spec-driven development has a gap.
A Markdown spec only asks for something, and nothing checks the answer.
The AI can skip a line or misread it, like any developer whose story the testers send back.
An executable spec is an acceptance test that stays red until the system does what the spec says.
It's test-driven development (TDD): red test first, code second.
TDD isn't a testing technique, and neither is this.
Human review is the most expensive resource you have today.
You can't speed it up, so you automate the criterion it applies.
A test is that criterion, and it runs on every change.
Prompt Reference 📝
Bad Prompt 🚫
Read SPEC.md and implement the checkout feature.
Make sure it follows the spec.
Test it when you finish it.
Good prompt 👉
Read SPEC.md, requirement 4: free shipping over 100 dollars.
Write an acceptance test for it first.
Name the test after the requirement.
Run it and show me the red failure.
Don't write any production code yet.
Wait for my review of the test.
After I approve it, implement the code.
Don't edit the test to make it pass.
Use an adversary agent to run the full suite and fix every red test.
Stop when all the spec tests are green.
Then list each requirement and the test that proves it.
Considerations ⚠️
A test only covers what somebody thought to write.
The expensive failures live in the cases nobody listed, like a retry or a half-finished payment.
If the AI writes the tests from the Markdown, its misreading lands in the test too, and the test passes.
The AI can also cheat when it weakens the test until it goes green.
I'd rather read the tests myself, or ask a second model to write them.
The Markdown stays.
It still says why.
Not every line of a spec deserves an acceptance test.
You should start with the requirements that cost money when they break.
Type 📝
[X] Semi-Automatic
Limitations ⚠️
Writing good acceptance tests takes work, and the first ones are slow.
A flaky test teaches you to ignore red.
Some requirements, like look and feel, are hard to automate.
Level 🔋
[X] Intermediate
https://coderlegion.com/12228/ai-coding-tip-008-use-spec-driven-development-with-ai
https://coderlegion.com/25361/ai-coding-tip-033-protect-yourself-against-ai-cheating
https://coderlegion.com/20462/ai-coding-tip-024-force-a-criteria-check-before-the-task-ends
https://coderlegion.com/19374/ai-coding-tip-022-give-ai-a-harness-to-work-with
https://coderlegion.com/27776/ai-coding-tip-037-stop-patching-blind
Conclusion 🏁
Your spec finally has a way to say no.
Which line of yours did the AI skip last?
https://en.wikipedia.org/wiki/Acceptance_testing
https://en.wikipedia.org/wiki/Behavior-driven_development
Also Known As 🎭
Spec-As-Test
Executable-Specification
Acceptance-Test-First
Test-Judged-Specs
Disclaimer 📢
The views expressed here are my own.
I am a human who writes as best as possible for other humans.
I use AI proofreading tools to improve some texts.
Most AI detectors will flag this article as AI-generated. That's expected. It's a technical article. It has a rigid format and clear steps to follow.
That's exactly the pattern those tools are trained to catch. I've apparently been "writing like an AI" for decades, long before AI existed. This is a technical article, not a novel.
I welcome constructive criticism and dialogue.
I shape these insights through 30 years in the software industry, 25 years of teaching, and writing over 500 articles and a book.
Credits 🙏
Photo by Markus Spiske on Unsplash
This article is part of the AI Coding Tip series.
https://coderlegion.com/12469/ai-coding-tips