Skip to main content
BlogSoftware Development

Spec-First AI Coding: Let the Agent Interview You

Stop prompting once and hoping. Make the AI agent interview you into a written spec first, so misunderstandings surface as cheap words instead of expensive code.

Matthews Wong

Software Engineer

August 20268 min read
Spec-First AI Coding: Let the Agent Interview You

Key Takeaway

Spec-first AI coding flips the usual order: before the agent writes a line, it interviews you, turning vague requests into a written spec you approve. That spec becomes the contract the agent builds and tests against, catching misunderstandings while they are still cheap words instead of expensive code.

The fastest way to get the wrong feature from an AI agent is to describe it in one line and say go. The agent fills every gap you left with a guess, writes hundreds of confident lines on top of those guesses, and you discover the mismatch only when you read the result.

Spec-first coding front-loads the disagreement. Instead of prompting once and hoping, you make the agent interview you until the requirement is pinned down in writing. This guide walks through running that interview, turning the answers into a spec, and handing that spec to a fresh session to build.

Why the interview comes first

A one-line prompt is an under-specified contract, and the agent resolves the ambiguity in the direction of whatever is easiest to generate. The gap between what you meant and what you said does not disappear; it gets baked into code, where it is far more expensive to find and remove.

Making the agent ask questions moves that gap to the front, where it is cheap to fix:

  • Every clarifying question is a decision surfaced before it becomes a line of code.
  • You correct a misunderstanding in a sentence instead of in a refactor.
  • The written answers become a shared reference both you and the agent can point back to.

Run the interview

Start by telling the agent explicitly not to write code yet. Its job is to ask, one focused batch of questions at a time, about scope, edge cases, data shapes, and how you will know the feature works. A good opening prompt makes questioning the agent's only allowed move.

The opening instruction can be as plain as this:

Do not write any code yet.

Your only task right now is to interview me until you can write a
clear spec for this feature. Ask your highest-value questions first,
in small batches, about scope, edge cases, data shapes, and how we
will know it works. When you have enough, write SPEC.md and stop.

Cap the interview. Tell the agent to ask its highest-value questions first and to stop once it has enough to write the spec. Left fully open-ended, some agents will interrogate you forever; the goal is a good-enough spec, not a perfect one.

Turn answers into a spec

Once the questions are answered, have the agent write the spec to a file such as SPEC.md and read it back critically. A useful spec is short and testable:

  • A one-paragraph statement of the goal and who it is for.
  • Explicit scope: what is in, and just as important, what is out.
  • Acceptance criteria phrased so that a test could check each one.
  • Known constraints, data shapes, and any decisions made during the interview.

Build against the spec in a fresh session

Hand the approved spec to a new session with a clean context. The interview transcript is noise now; the spec is the signal. Starting fresh keeps the build focused on the agreed contract instead of the meandering path that produced it.

Because the spec names its own acceptance criteria, the agent can check its work against them and you can review the change against the same list. The spec that started as an alignment tool becomes the test plan and the review checklist for free.

A spec is a snapshot, not a cage. When the build reveals that a decision was wrong, update the spec and note why, then continue. A spec you quietly diverge from is worse than none, because it now lies about what the code is supposed to do.

When spec-first is worth it

The overhead of an interview pays back on ambiguous or high-stakes work, and gets in the way on trivial ones:

  • Worth it for a new feature with unclear requirements, where a wrong guess costs a day of rework.
  • Worth it for anything a teammate will inherit, since the spec doubles as documentation of intent.
  • Skip it for a quick fix or an exploratory spike, where writing a spec costs more than just trying the change.

Spec-first coding trades a few minutes of questions for hours of avoided rework. Tell the agent to interview you, capture the answers in a short testable spec, and build against it in a clean session. The discipline is simple: agree on what done means in words before the agent spends tokens getting there.

FAQ

Frequently Asked Questions

Short answers to what readers ask most about this topic.

What is spec-first AI coding?

It is a workflow where the AI agent interviews you and writes an agreed spec before it writes any code. The spec captures scope, edge cases, data shapes, and acceptance criteria, then serves as the contract the agent builds and tests against, so alignment happens in words before it becomes code.

Why should the agent interview me before coding?

A one-line prompt leaves gaps the agent fills with guesses, and those guesses get baked into code that is expensive to fix. Making the agent ask questions first surfaces each decision while it is still a cheap sentence to correct, instead of a refactor you discover only after reading the result.

What should a good spec contain?

Keep it short and testable: a one-paragraph goal and its audience, explicit scope for what is in and out, acceptance criteria phrased so a test could check each one, and any known constraints, data shapes, or decisions made during the interview. If a criterion cannot be tested, rewrite it until it can.

Should I build in the same session as the interview?

It works best to hand the approved spec to a fresh session. By then the interview transcript is noise, and the spec is the signal. A clean context keeps the build focused on the agreed contract rather than the meandering path that produced it, which reduces drift.

When is spec-first coding not worth the overhead?

Skip it for quick fixes or exploratory spikes, where writing a spec costs more than simply trying the change. It pays off on new features with unclear requirements and on anything a teammate will inherit, since the spec then doubles as documentation of intent and as a review checklist.