Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 7 min read

Was the Agent Fast, or Was the Spec Already Done?

An agent can turn a feature request into a working change in minutes. That makes it tempting to credit the agent for the speed. But look at what happened before the prompt: someone decided what "done" means, which behavi

An agent can turn a feature request into a working change in minutes. That makes it tempting to credit the agent for the speed. But look at what happened before the prompt: someone decided what "done" means, which behavior must not change, and why the old code looked the way it did. If that work already existed, the agent had an easy job. If it didn't, the minutes you saved were spent later, in review.

I can't give you a speedup figure for this, and I won't invent one. What I can show is where the work moves when you write the spec and its checks first, using a small example I ran on this machine.

This isn't the one-page spec template. An earlier article covered that, with EARS requirements, and another covered Spec Kit's converge step. This one is about two narrower habits: write the acceptance checks before you prompt, and keep the reasons in the repo.

Spec-driven means the spec comes first

Spec-driven development puts a written specification ahead of the code. GitHub's Spec Kit README describes it as: "Define what to build and why, then turn the specification into a plan, tasks, and working code." Its minimal flow runs a constitution, specify, plan, tasks, implement and converge, "one at a time, reviewing each result before continuing".

Kiro's specs documentation has the same shape with different names. A spec produces three files: requirements.md (or bugfix.md) with user stories and acceptance criteria, design.md for architecture and testing strategy, and tasks.md with trackable tasks. Both tools put a human review between phases.

Notice what is in both: a place for "what must be true when this is done" that exists before implementation. That's the part you can do without any tool.

Habit 1: write the checks before you prompt

Kiro's best-practices FAQ has a useful structure for bug fixes. It asks you to state the current behavior, the expected behavior, and any constraints, meaning code or behavior that must not change. In its Bugfix Specs, the "unchanged behavior" gets its own statement, in the form "WHEN [condition] THEN the system SHALL CONTINUE TO [existing behavior]".

That third part is the one most prompts leave out, and it's what stops a fix from quietly breaking something nearby. Here is a bug small enough to show completely. A profile form rejects the name "O'Brien" with "invalid name". Before prompting anything, I wrote this as spec.md:

# Bugfix spec: names with apostrophes

## Current behavior
Saving a profile with the name "O'Brien" is rejected with "invalid name".

## Expected behavior
- WHEN the name is "O'Brien", THEN save_profile SHALL accept it.
- WHEN the name is "Anne-Marie", THEN save_profile SHALL accept it.

## Unchanged behavior
- WHEN the name contains a digit or "<", THEN save_profile SHALL CONTINUE TO reject it.
- WHEN the email has no "@", THEN save_profile SHALL CONTINUE TO reject it.

## Why (stays in the repo)
Names with apostrophes are real names. The old pattern allowed only letters, spaces and hyphens.
Keep it an allow-list: add the apostrophe, do not switch to "reject only known-bad characters".

Then I turned each line into a check using Python's standard unittest, five tests in all: two for expected behavior, three for unchanged behavior. This is the step to do before you open the agent, because the checks are now the definition of done, and they don't depend on how convincing the agent's summary sounds.

Run the checks against the old code first

A check you've never seen fail proves little. So run it against the current code. This is the output, shortened to the key lines (the failure detail and timing lines are in the full output.txt from the same run):

$ IMPL=profile_v1 python3 test_spec.py
test_apostrophe_name_is_accepted (__main__.Expected.test_apostrophe_name_is_accepted) ... FAIL
test_hyphenated_name_is_accepted (__main__.Expected.test_hyphenated_name_is_accepted) ... ok
test_digit_in_name_still_rejected (__main__.Unchanged.test_digit_in_name_still_rejected) ... ok
test_email_without_at_still_rejected (__main__.Unchanged.test_email_without_at_still_rejected) ... ok
test_markup_in_name_still_rejected (__main__.Unchanged.test_markup_in_name_still_rejected) ... ok

FAILED (failures=1)
exit code: 1

Exactly one check fails, and it's the one the spec says should. The four others pass, which tells you the "unchanged" checks are really testing current behavior, not wishes. Now you have a precise target for the agent: make the failing check pass and keep the other four green.

I then wrote the fix by hand, not with an agent. It is one character in the pattern:

$ diff profile_v1.py profile_v2.py
3c3
< NAME_RE = re.compile(r"^[A-Za-z][A-Za-z \-]*$")
---
> NAME_RE = re.compile(r"^[A-Za-z][A-Za-z '\-]*$")
$ IMPL=profile_v2 python3 test_spec.py
Ran 5 tests in 0.000s

OK
exit code: 0

A caveat worth stating plainly: this demo used no AI agent. I wrote both versions of the code myself, and it says nothing about how fast or how accurately any agent would do the same job. What it shows is the review. Whoever or whatever writes the fix, you read a pass/fail result against criteria you set in advance, instead of reading a diff and hoping.

Habit 2: keep the "why" in the repo

Look at the last section of the spec: "Why". It looks like a comment, and it does a real job. The first rule says to keep an allow-list. Without that line, a reasonable agent, or a reasonable colleague, might "fix" the bug by switching to a deny-list of bad characters. The five checks would still pass for the inputs they cover, because they test a few cases and not the principle.

Checks catch the regressions you thought of. The reason catches the ones you didn't. That's why it should live in the repo as a file, not in a chat history.

Kiro's FAQ makes the same point about where specs belong: they are "designed to be version-controlled", and it recommends storing them "directly in your project repository alongside the code they describe", which "keeps all project artifacts together and maintains the connection between requirements and implementation". The same holds if you aren't using Kiro. A specs/ folder with one Markdown file per change is enough.

For later changes, update the spec first. Kiro's documentation describes its own version of this: for a Requirements-First spec, you update the requirements, ask for the design to match, then sync the tasks. The order is the point.

Right-size it

Not every change needs this. Kiro's own guidance is that a Bugfix Spec fits when the bug is in a critical code path, when earlier fix attempts caused regressions, when the root cause isn't obvious, or when you need documentation for compliance or team knowledge. It says a quick fix in chat is fine for typos, simple logic errors and well-understood one-line changes. The O'Brien bug above is, honestly, small enough for a quick fix. I used it because it fits on a screen, not because it needs ceremony.

A rule of thumb of mine, not a standard: if you couldn't explain in one sentence how you'd know the change is correct, you're not ready to prompt yet.

Checklist before you prompt

  1. Write the current behavior in one or two sentences, including how to reproduce it.
  2. Write the expected behavior as WHEN/THEN statements.
  3. List the behavior that must stay unchanged, as WHEN/THEN ... SHALL CONTINUE TO statements.
  4. Turn each statement into a check you can run.
  5. Run the checks against the current code and confirm that only the expected ones fail.
  6. Add a "Why" line for any decision a future change could undo.
  7. Commit the spec next to the code, then prompt.
  8. After the change, accept it when the checks pass and every diff line traces back to the spec.

Where to go next

If you'd rather start with a few pages, the free Spec-Driven Development Quick-Start Cheat Sheet covers the method in 6 pages.

For the full method, Spec-Driven Development: The Complete Guide to the AI Coding Method is a 40-page PDF with thirteen chapters. Per its product page, it covers the four-phase loop (Specify, Plan, Tasks, Implement) with review gates, what belongs in a spec, the five EARS requirement patterns, the three levels of rigor (spec-first, spec-anchored, spec-as-source), the Constitution, a tool map (GitHub Spec Kit, AWS Kiro, OpenSpec, Tessl, BMAD and more), how SDD compares with TDD and plan mode, and team adoption, plus three worked walkthroughs: a full-rigor feature, a fast-lane fix and a brownfield adoption. It's $9.90+, pay what you want from that price up.

When you last used an agent for a fix, could you have written the "unchanged behavior" list before you prompted?

This article was written with the assistance of AI and reviewed by the author.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.