By Harish Mahamure · 4 min read
Updated
Spec-driven agentic development: from acceptance criteria to a reviewed change
A practical workflow for AI-assisted delivery: define behavior, inspect the codebase, bound the task, and verify the result with a payment callback example.
Before asking a coding agent to implement a feature, I want to know how I will decide whether the result is correct. A convincing explanation and a passing happy-path test are not enough when the change affects money, state transitions, or existing callers.
I use Claude Code, BMAD Method, Superpowers, and spec-driven workflows in my engineering work. The workflow below is a practical synthesis, not an installation guide or a required file structure for those tools.
Start with behavior, not a document collection
For a small change, the specification can be a few acceptance criteria beside the task. Larger work benefits from a separate specification, an implementation plan, and a short record of consequential architecture decisions.
The useful questions are consistent:
- What observable behavior should change?
- Which existing behavior must remain valid?
- What happens when a dependency fails or an operation is retried?
- What evidence will demonstrate the result?
A specification should make unresolved decisions visible. It should also be editable when a legitimate requirement changes; “spec-driven” does not mean preserving an incorrect decision forever.
An example: duplicate payment callbacks
Consider a hypothetical callback handler. The request “update the payment status” does not define duplicate behavior, event ordering, or recovery after a partial failure.
A more useful specification might include:
Scenario: the same successful event is delivered twice
Given a valid event has already been recorded and applied
When the identical event is delivered again
Then acknowledge it without applying the payment twice
Scenario: the provider reuses an event ID with a different payload
Given that event ID already exists
When a conflicting payload arrives
Then flag the conflict for investigation and do not reapply it
This example assumes a provider contract that supplies a stable event identifier. That assumption must be checked against the actual provider. If no such identifier exists, define a deduplication contract before implementation.
Verification also needs to cover invalid authentication, simultaneous duplicate deliveries, and a crash between processing and acknowledgment. The response behavior and retry contract belong in the design, not in assumptions the agent makes while coding.
Inspect the existing system before planning
In an existing codebase, I would ask the agent to locate the handler, callers, persistence layer, authentication checks, state-transition rules, and nearby tests. Its findings should name files and explain the current behavior.
That prevents a common failure: implementing a technically reasonable solution beside an existing mechanism that already owns the responsibility.
The proposed change should have boundaries. For this example, a plan might cover a durable event record, an atomic state update, the relevant uniqueness constraint, and focused tests. A billing redesign would need separate justification.
Implement in reviewable steps
A bounded sequence for the example is:
- Write a regression test for the duplicate behavior.
- Confirm that it fails for the expected reason.
- Implement the smallest coherent change.
- Exercise retries, conflicting events, and concurrency.
- Review the diff for unrelated changes and migration implications.
Separate verification from the implementation narrative. “The agent says it ran tests” is weaker evidence than the command, output, and the specific behavior the tests exercise.
Keep the engineering decisions visible
An Architecture Decision Record is useful when choosing between durable deduplication and an expiring cache, or when deciding which service owns a transaction. It should state the context, decision, alternatives, and consequences.
A small naming change rarely needs an ADR. Neither does every implementation detail deserve a new markdown file. The process has earned its place only when it reduces ambiguity or makes review easier.
Judge the workflow by the result
Useful evaluation questions include whether the change satisfies its acceptance criteria, how much review rework it creates, whether regressions escape, and whether another engineer can maintain it. Compare equivalent tasks and include planning and review time before claiming a speed improvement.
For the differences between the tools around this process, see BMAD, Superpowers, and OpenSpec. For an example of production engineering outside AI workflows, see the DesignTemplate caching case study.