DevsAgentic

Developer Workflows

Spec-Driven Development for AI Coding Agents

By Ali Raza • • 8 min read

Updated November 29, 2026

TL;DR — Give an AI coding agent a compact contract before asking it to edit code: the user problem, constraints, acceptance checks, and files or systems it should avoid. Use that contract to make a plan, implement one small slice, and verify the result. A specification is useful when it reduces uncertainty; it is not a reason to document every obvious change.

Why a one-line prompt is a weak engineering contract

“Add search to the dashboard” sounds clear until an agent has to decide what search means. Should it match names, IDs, or descriptions? Is matching case-sensitive? Does it filter the current page or query the server? What should an empty result look like? A person might ask follow-up questions; a coding agent may instead pick an arbitrary interpretation and confidently implement it.

The problem is not that every coding task needs a long design document. It is that unstated decisions become hidden assumptions. A short, reviewable specification makes important decisions visible before they turn into code. It also gives reviewers something more concrete than “the agent says it is done” to compare against.

Start with the behavior, not a file list

Begin by describing who needs the change and what should become possible. Then define observable outcomes. A good acceptance criterion can be checked by a person, a test, or both; “make search better” cannot. Keep implementation details out unless they are real constraints, such as a required API contract or a component boundary that must remain server-rendered.

Feature: Search the saved projects list

User outcome:
  A project owner can find a saved project by its name.

Acceptance criteria:
  - Matching ignores letter case.
  - Leading and trailing spaces in the query are ignored.
  - An empty query shows the full list.
  - No matches show an explicit empty state.
  - Search does not change or delete saved projects.

Out of scope:
  - Searching project descriptions or remote records.
  - Adding a new search service.

This is deliberately small. It clarifies scope without prescribing a specific hook, state library, or component structure. If a team has a required approach, add it as a constraint and explain why it matters.

Give the agent the context it cannot infer

A specification is only part of the task. The agent also needs to find the project’s conventions: where the list comes from, how empty states are presented, which tests cover the feature, and whether the app uses server or client components at that boundary. Useful context is specific and local. Point to the relevant route, model, test, or documentation rather than pasting the entire repository into a prompt.

Keep durable rules in repository instructions and task-specific facts in the task description. For example, “run the existing unit tests and do not add a dependency” belongs in the task if it is specific to this change; naming conventions or security requirements can be maintained as project guidance. Repositories evolve, so periodically check that persistent instructions still match the code.

Anchor the request in the project’s current behavior

Before describing a new behavior, establish what happens today. Ask the agent to find the relevant route, component, data source, and tests, then summarize the current behavior with file references. This is a useful discovery step because a feature request may be based on an outdated assumption. It also discourages the agent from creating a second implementation when a suitable helper already exists.

For the project-search example, the current list might already be filtered by an owner selector. The contract should say whether name search composes with that filter, how clearing search restores the current filtered list, and whether the empty state means “no projects exist” or “nothing matches.” Those distinctions affect the behavior a user sees, even though they may not be obvious from the phrase “add search.”

Turn the contract into a bounded plan

Before coding, ask the agent to identify the likely components and tests it will touch. A plan is particularly useful when the task crosses a UI, an API, and stored data. It exposes a misunderstanding early and makes it easier to split work into independently reviewable changes. For a one-line copy edit, the same ceremony may cost more than it saves.

Keep the implementation sequence small: locate the existing behavior, make one cohesive change, run the focused check, and inspect the diff. If the agent discovers that the specification conflicts with existing behavior, pause and revise the contract instead of letting it silently expand the scope.

Make acceptance criteria verifiable

A criterion such as “works on mobile” needs a viewport and a concrete expectation. “A query with no results displays the message ‘No projects found’ at 375 pixels wide” can be checked. For API work, specify response shape, status codes, and failure behavior. For data changes, describe compatibility and migration expectations. Prefer assertions about behavior over assertions about the exact files the agent must edit.

Tests should cover both the requested path and the boundaries that could regress: blank input, mixed-case input, empty results, authorization, and error handling as appropriate. The agent should run the smallest useful test first, then the broader project check if the change warrants it. A green test suite cannot prove every requirement, so compare the implementation and user-facing behavior to the written acceptance criteria as well.

Review the diff, not just the summary

Ask for a concise report of files changed, checks run, and anything not verified. Then inspect the actual diff for unrelated edits, new dependencies, accidental secret exposure, and success-shaped fallbacks. Treat generated code as a proposal. A clean summary is useful for navigation, but it is not evidence that the implementation is correct.

The final review can follow a simple traceability loop: take each acceptance criterion, identify the code or test that addresses it, and note any criterion that still needs a manual check. That gives the human reviewer a focused job and gives the agent a clear definition of “finished.”

If an acceptance criterion has no matching implementation or verification, treat that as an open item rather than assuming it is covered by the overall test result. If the implementation adds behavior that has no criterion, ask whether the scope should change. This small reconciliation step helps prevent both missing requirements and convenient-but-unrequested extras.

When this approach helps—and when it does not

A written contract pays off when the task is ambiguous, has meaningful edge cases, spans several modules, changes an API, or carries a security or data risk. For a tiny, reversible change, a short prompt plus a focused test may be enough. Over-documenting can slow work down and can lock in a solution before the problem is understood.

Spec-driven development is not a guarantee that an agent will obey the specification. It is a way to make intent, boundaries, and evidence easier to inspect. In late 2026, industry guidance is increasingly discussing the broader “harness” around coding agents—context, standards, and guardrails—not just model selection. A practical starting point is still modest: define what done means, then verify it.

A quick checklist

  • Describe the user outcome and the problem, not only the requested code.
  • List acceptance criteria that can be observed or tested.
  • State important constraints and explicit non-goals.
  • Point to relevant code and project conventions.
  • Ask for a bounded plan when the work crosses meaningful boundaries.
  • Run focused checks and inspect the full diff before accepting the change.

References

AI AgentsCoding AgentsSpecificationsTesting
AR

About Ali Raza

Ali is a software engineering student at Riphah International University and the founder of the digital agency Ionix Growth. He writes about modern web architecture, developer tooling, and integrating AI workflows into web applications.