Spec-Driven Development Prompts: Discovery, Formulation, and Phased Execution
The missing piece of spec-driven development
I wrote a whole post about spec-driven development — the five-phase workflow I use to stop vibe coding and start shipping. But after using the workflow for a while, I noticed a pattern: the three hardest phases are the ones where I do the thinking, not the AI. Discover, Formulate, Direct. Those are the phases where people get stuck, cut corners, or produce output too vague to be useful.
So I built prompts for each one.
These three prompts cover the front half of the spec-driven workflow — the part that determines whether the back half (Validate, Refine) goes smoothly or turns into a debugging marathon. They’re designed to work together in sequence, but each one stands on its own if you only need one phase.
Here’s the order:
- The Discovery Prompt — finds the gaps in your problem understanding
- The Specification Formulator — turns discovery notes into a concrete spec with examples
- The Phase Director — breaks a spec into reviewable implementation phases
Each prompt below includes the full text, then a breakdown of why it’s shaped the way it is.
Prompt 1: The Discovery Prompt
This is the prompt you use after you’ve written your initial discovery document — that rough collection of questions and observations about what you’re building. You hand it to the AI and say: “What am I missing?”
The spec-driven development post mentions this trick in passing: asking the AI to poke holes in your discovery. For the rate limiter example, this step surfaced the “what if Redis goes down?” question — which turned out to be the most important design decision in the entire feature.
But “poke holes” is vague. This prompt makes it systematic.
The full prompt
# Discovery Review — Find What I'm Missing
You are a senior engineer reviewing a discovery document for a feature that
hasn't been built yet. Your job is NOT to propose solutions. Your job is to
find the questions the author hasn't asked, the assumptions they haven't
examined, and the failure modes they haven't considered.
## How to Analyze the Discovery Document
Read the document carefully, then evaluate it across these dimensions:
### 1. Missing Failure Modes
For every component, dependency, or integration mentioned, ask:
- What happens when this is unavailable?
- What happens when this returns unexpected data?
- What happens when this is slow (not down, just slow)?
- What is the blast radius if this fails?
### 2. Implicit Assumptions
Look for things the author assumes without stating:
- Are they assuming a specific scale? (10 users? 10,000? 10 million?)
- Are they assuming certain infrastructure exists?
- Are they assuming a specific user behavior pattern?
- Are they assuming data is always clean/valid/present?
- Are they assuming operations happen in a specific order?
Flag each assumption explicitly. Don't judge whether the assumption is
reasonable — just surface it so the author can decide.
### 3. Missing Stakeholders and Perspectives
- Who uses this feature that the author hasn't mentioned?
- Who operates/maintains this feature?
- Who pays for the infrastructure this feature needs?
- Are there upstream or downstream systems affected?
### 4. Edge Cases and Boundary Conditions
- What happens at zero? (No data, no users, empty state)
- What happens at the limits? (Max size, max count, timeout)
- What happens with concurrent access?
- What happens during deployment/migration?
- What about timezone, locale, or encoding issues?
### 5. "What Would You Bet?" Test
For each major decision or direction implied in the document, ask yourself:
would you bet your weekend that this is the right approach? If not, explain
what makes you hesitate.
## Output Format
Structure your response as:
**Gaps Found** — Questions the author needs to answer before writing a spec.
Number each gap. For each one, explain WHY it matters, not just what it is.
**Assumptions Surfaced** — Implicit assumptions that should be made explicit.
The author may choose to keep these assumptions, but they should be conscious
choices.
**Risk Flags** — Anything that could cause significant rework if not addressed
early. These are the "I wish someone had told me" items.
## Rules
- Do NOT propose implementations or solutions. Only ask questions.
- Do NOT rewrite the discovery document. Add to it.
- Be specific. "Have you considered error handling?" is useless.
"What happens when the payment provider returns a 200 status but the
charge actually failed?" is useful.
- Prioritize. Put the gaps that could cause the most rework first.
- If the discovery document is already thorough, say so. Don't invent
problems to seem useful.Why this prompt works
The five dimensions are ordered by impact. Failure modes come first because they cause the most expensive rework. I can live with a missing edge case. I can’t live with discovering my feature has no fallback when a dependency goes down — after I’ve already built and deployed it.
“Flag each assumption, don’t judge it” is important. The natural instinct for an AI is to tell you your assumptions are wrong and propose alternatives. But at the discovery stage, I don’t want alternatives. I want to see what I’m assuming so I can decide whether each assumption is acceptable. Sometimes the answer is “yes, I know I’m assuming fewer than 1,000 users, and that’s fine for a side project.”
The “What Would You Bet?” test is my favorite section. It forces the AI past polite uncertainty and into actual risk assessment. Models tend to hedge everything equally. This framing asks them to differentiate between “this is a minor concern” and “this could ruin the project.”
“Do NOT propose implementations” is the most important rule. Without it, the AI will spend 80% of its response suggesting solutions instead of asking questions. Discovery is about expanding the problem space, not narrowing it to a solution.
Prompt 2: The Specification Formulator
After discovery is done and your questions are answered, you need to turn that messy pile of notes and decisions into a proper specification. This is the prompt that does the heavy lifting.
The key insight from the spec-driven development post is that examples are the actual specification, not decoration. “Support different limits for logged-in vs anonymous users” is ambiguous. But “user-123 authenticated, 50 requests made, limit 100, tracked by user ID, request succeeds” is a contract.
This prompt encodes that principle and enforces the structure I’ve found most useful.
The full prompt
# Specification Formulator — Turn Discovery Into a Spec
You are helping the author turn a discovery document (and any follow-up notes)
into a formal specification. The specification must be detailed enough that
a developer who has never seen the discovery document can implement the feature
correctly using only the spec.
## Specification Structure
Generate the specification using this structure:
### 1. Problem Statement
2-3 sentences. What problem does this solve and for whom? No solution details.
### 2. Requirements
A numbered list of what the system must do. Each requirement should be:
- Testable (you can write a pass/fail check for it)
- Independent (changing one doesn't force changes to others, where possible)
- Specific enough to implement without guessing
Bad: "The system should handle errors gracefully."
Good: "When the payment API returns a non-2xx status, the system retries
once after 2 seconds, then returns an error to the user with the message
'Payment failed. Please try again.'"
### 3. Examples (THIS IS THE MOST IMPORTANT SECTION)
For every requirement, write at least one concrete example. Use this format:
---
**[Short descriptive title]**
[Setup — what state exists before the action]
[Action — what the user or system does]
--> [Result — what happens, including specific values]
---
The examples should cover:
- The happy path (normal, expected usage)
- Each meaningful edge case
- Each failure mode identified in discovery
- The boundary between "allowed" and "not allowed" for any limit or rule
Write examples in plain language. Do NOT use Gherkin (Given/When/Then) unless
the author specifically requests it. Plain language examples are easier to
read, easier to argue about, and easier to turn into tests.
Each example should include concrete values — real numbers, real strings,
real status codes. Not "an error message" but "the message 'Invalid email
or password'". Not "the request fails" but "returns 429 Too Many Requests
with header Retry-After: 45".
### 4. Key Decisions
For each significant technical or product decision, document:
- **Decision**: What was decided
- **Why**: The reasoning (1-2 sentences)
- **Alternatives considered**: What else was on the table
- **Trade-off**: What you're giving up
This section exists so that future-you (or a teammate) doesn't reverse a
decision without understanding why it was made.
### 5. Out of Scope
Explicitly list what this feature does NOT do. This is surprisingly important
for AI-assisted development — without it, an AI agent will often "helpfully"
implement things you didn't ask for, creating code you have to understand,
test, and maintain.
Be specific. Not "advanced features" but "request queuing, dynamic rate
adjustment, IP whitelisting."
### 6. Open Questions (if any)
Anything the author still needs to decide. These should be resolved before
implementation begins.
## Rules
- Every requirement MUST have at least one example. A requirement without
an example is not a requirement — it's a wish.
- Examples should be written from the user's or caller's perspective, not
the system's internals.
- Use concrete values everywhere. Placeholder text like "[some value]" or
"appropriate error" is not allowed.
- The spec should be self-contained. A reader should not need the discovery
document to understand the spec.
- If the discovery document has contradictions or gaps, flag them in
Open Questions instead of guessing.
- Keep the language simple. If a requirement takes three readings to
understand, it needs rewriting.
- Do NOT include implementation details (which library, which data structure,
which algorithm) unless they were explicitly decided during discovery. The
spec says WHAT, not HOW.Why this prompt works
“Every requirement MUST have at least one example” is the single most important rule. I cannot overstate how many specification documents I’ve written (and seen others write) where the requirements sound clear until you try to implement them. The examples are what force precision. If you can’t write a concrete example for a requirement, you don’t understand the requirement well enough to build it.
The example format is intentionally simple. I tried Gherkin for months. It added structure but reduced clarity. The plain format — setup, action, result with --> arrows — reads like a conversation. “Client has made 10 requests, makes another one, gets a 429.” Anyone can read that. Anyone can argue about whether it’s right. That’s the point.
“Concrete values everywhere” eliminates the most common spec failure mode: vagueness that feels like precision. “Returns an appropriate error message” sounds specific. It’s not. “Returns 429 with body { error: { code: 'RATE_LIMIT_EXCEEDED' } }” is specific. The AI can implement that without guessing.
Out of Scope is for the AI, not for you. You already know what you don’t want to build. But your AI agent doesn’t. Without an explicit out-of-scope section, I’ve had agents implement caching layers, admin panels, and analytics dashboards I never asked for — because they seemed like logical extensions. The out-of-scope section is a fence.
“Do NOT include implementation details” keeps the spec honest. The moment you put “use Redis with a sliding window” in the spec, you’ve made a technology choice that belongs in the implementation phase. Sometimes that choice is already made (it was in the rate limiter case, during discovery). But the default should be to keep the spec technology-agnostic.
Prompt 3: The Phase Director
You have a specification. You could paste it into your AI agent and say “build this.” Don’t. That’s how you end up with 400 lines of untested code, a renamed database column, and a Friday night spent reverting commits.
This prompt takes a specification and breaks it into implementation phases — each one small enough to review, small enough to revert, and each one building on the last.
The principle from the spec-driven development post is simple: small phases beat big prompts. This prompt automates the phase planning.
The full prompt
# Phase Director — Break a Spec Into Implementation Phases
You are a senior engineer planning the implementation of a feature. You have
a specification document. Your job is to break it into sequential phases that
a developer (or AI agent) can execute one at a time, with a review checkpoint
after each phase.
## Phase Design Principles
### 1. Each Phase Must Be Self-Contained
After completing a phase, the project should:
- Build without errors
- Pass all existing tests
- Pass all new tests written in that phase
- Be in a committable state
Never leave the project in a broken state between phases.
### 2. Phase Order Follows Dependencies
Organize phases so that:
- Types and interfaces come first
- Core logic comes before integrations
- Happy paths come before edge cases
- The simplest working version comes before optimizations
### 3. Each Phase Is Reviewable
A phase should be small enough that a human can review the diff in under
10 minutes. If a phase touches more than 5 files or adds more than 200 lines,
consider splitting it.
### 4. Tests Travel With Implementation
Every phase that adds functionality must include tests for that functionality.
Tests are not a separate phase — they're part of the same phase as the code
they test.
## Output Format
For each phase, provide:
---
### Phase N: [Short title]
**Goal**: One sentence describing what this phase accomplishes.
**Spec coverage**: Which examples from the specification this phase implements
(reference them by title or number).
**Tasks**:
1. [Specific task]
2. [Specific task]
3. [Specific task]
**Tests to write**:
- [Test description mapping to a spec example]
- [Test description mapping to a spec example]
**Review checklist**:
- [ ] [What to verify before moving to the next phase]
- [ ] [What to verify before moving to the next phase]
**Prompt for AI agent**:[The actual prompt you would paste into your AI agent to execute this phase. Include a reference to the spec file location, the specific tasks, and end with “Stop after this phase so I can review before we continue.”]
---
## Phase Sequencing Guidelines
A typical feature breaks down roughly like this (adapt as needed):
1. **Foundation**: Types, interfaces, configuration validation. No business
logic. This phase catches misunderstandings early — if the types don't
match the spec, the spec needs revision.
2. **Core logic**: The main functionality, happy path only. This is the
minimum viable implementation. If you had to ship something tomorrow,
this phase gives you something that works for the normal case.
3. **Edge cases and error handling**: The failure modes and boundary
conditions from the spec. This phase often reveals gaps in the spec
that need to be addressed (which is expected — update the spec).
4. **Integration**: Connecting the core logic to the rest of the system
(middleware, routes, UI, etc.). Keep this thin — a wrapper, not a
rewrite.
5. **Refinement**: Performance, logging, monitoring, cleanup. Only do
this phase if the spec calls for it or if issues surfaced during
earlier phases.
Not every feature needs five phases. A simple feature might need two. A
complex one might need seven. Use judgment.
## Rules
- Reference specific spec examples by name in each phase. This creates
traceability from spec to implementation.
- The "Prompt for AI agent" section should be copy-pasteable. Don't make
the user rewrite it.
- Every phase prompt MUST end with an instruction to stop and wait for
review. This is non-negotiable.
- Include a review checklist that a developer can run through in 2 minutes.
Think "does it build? do tests pass? does the diff make sense?" — not
a 30-minute code review guide.
- If the spec has Open Questions, flag which phase is blocked by which
question. Those questions must be resolved before that phase begins.
- Do NOT add features, optimizations, or "nice to haves" that aren't in
the spec. If you think something is missing, say so explicitly instead
of silently adding it.
- Suggest a git commit message for each phase that references the spec.
Format: "feat(component): what was done [spec: spec-name]"
Why this prompt works
“Each phase must be self-contained” is the rule that prevents the most common failure mode of phased implementation: a phase that leaves the project in a broken state. If Phase 2 fails and I need to revert, I should land back on a working Phase 1 — not on a half-finished pile of code that doesn’t compile.
“Tests travel with implementation” fights the temptation to push testing into a final phase. I’ve done this. You end up with an implementation phase that feels fast and a testing phase that reveals the implementation is wrong. Writing tests alongside code means each phase is verified before you build on top of it.
The “Prompt for AI agent” section is the killer feature. Without it, you have a plan but you still need to write the prompts yourself. With it, you get copy-pasteable instructions that include the spec reference, the specific tasks, and the “stop after this phase” guardrail. It removes the friction between planning and execution.
Review checklists are deliberately short. I tried detailed review checklists early on. Nobody uses a 15-item checklist between implementation phases. A 3-item checklist — does it build, do tests pass, does the diff make sense — actually gets used.
“Do NOT add features that aren’t in the spec” mirrors the Out of Scope principle from the specification prompt. AI agents want to be helpful. Helpfulness without boundaries means scope creep. Every phase prompt needs this fence.
Using the three prompts together
The workflow looks like this:
- Write your discovery document (15-20 minutes, pen and paper or a blank markdown file)
- Feed it to the AI with Prompt 1 (Discovery). Read the gaps. Answer the questions. Update your notes.
- Feed your updated notes to the AI with Prompt 2 (Specification Formulator). Review the spec. Argue with the examples. Make sure every requirement has a concrete illustration.
- Feed the finished spec to the AI with Prompt 3 (Phase Director). Review the phases. Adjust the order if needed.
- Execute each phase by copying the generated prompts into your AI agent, reviewing after each one.
The front-loading feels slow — maybe an hour before you write any code. But the implementation phases go fast because the AI knows exactly what to build, exactly what to test, and exactly when to stop.
The alternative is typing “build me a notification system” and spending your Friday night reverting commits. I’ve done both. The spec takes less time.
Adapting these prompts
If you use Gherkin: Swap the example format in Prompt 2. Replace the plain-language instruction with Given/When/Then structure. The rest of the prompt still applies.
If you work in a team: Add a section to Prompt 2 asking for role-based examples (“As an admin…”, “As a viewer…”). The single-developer version assumes you’re all the roles.
If your features are small: Skip Prompt 3. If the spec has fewer than 5 examples, you probably don’t need phased implementation — just hand the spec to your agent and review the result.
If your features are huge: Add a “Phase 0: Spike” to Prompt 3’s sequencing guidelines. Some features need a throwaway prototype before you can write a real spec. That’s not vibe coding — that’s exploration with intent.