Or press ESC to close.

The Spec Is the Contract: How SDD Is Changing API Test Strategy

Jun 14th 2026 5 min read
medium
ai/ml
qa
api
contract
documentation
architecture
strategy

You've set up contract tests, the pipeline catches breaking changes, and everything looks solid. Then your team adopts an AI coding assistant. The code ships faster, the unit tests pass, and three days later you get a Slack message: "Hey, did something change in the auth endpoint? Our service is broken." Nothing caught it. The AI generated the implementation, someone reviewed it quickly, and nobody checked whether it still honored the agreed behavior between services.

This is not a tooling problem. It is a source-of-truth problem. And Spec-Driven Development, paired with the contract testing mindset, might be the most practical answer QA automation engineers aren't talking about yet.

Two Concepts, One Idea

Contract testing is the practice of defining the expected behavior between two services before testing their integration. Instead of spinning up both sides and hoping they talk correctly, you capture the agreement: what the consumer expects to receive, and what the provider commits to deliver. That agreement is the contract. It lives in your repo, it is version-controlled, and when something breaks it, your pipeline tells you before production does.

Spec-Driven Development follows a similar instinct but starts even earlier. Before any code is written, you define a spec: a structured document that describes what is being built, why, and how it should behave. Tools like OpenSpec and Spec Kit make this spec the artifact that both the developer and the AI coding assistant work from. The AI does not freestyle from a vague prompt. It reads the spec, implements against it, and can verify its output against it.

The overlap is hard to miss. Both practices are asking the same question before work begins: what is the expected behavior, and how do we make sure it is honored? One asks it at the integration layer, the other asks it at the implementation layer. Put them together and you have something more robust than either one alone.

Where the Spec Becomes the Contract

In a traditional workflow, the spec and the contract are two separate things maintained by two different people at two different points in the cycle. A product manager writes requirements, a developer builds against them, and a QA engineer later defines what the API should return in a contract test. By the time the contract is written, the spec is already a Confluence page nobody is reading.

SDD collapses that gap. When you define a spec in OpenSpec before implementation starts, you are already describing inputs, outputs, and expected behaviors. That is exactly the information a contract test needs. The spec is not a planning document that gets abandoned after kickoff. It is a living artifact that stays in the repo, gets updated as the feature evolves, and can be referenced at any point in the pipeline.

This is where QA engineers have a real opportunity. If the spec describes how an endpoint should behave, it can seed your contract tests directly. You are not writing the contract from scratch by reading someone else's code after the fact. You are pulling from an artifact that was agreed upon before a single line was written. The source of truth does not shift because the AI shipped fast. It was locked in at the start.

One spec. Two purposes. That is the core argument.

What This Looks Like in Practice

Take a simple example. Your team is adding a new user profile endpoint. In a typical AI-assisted workflow, a developer drops a prompt into their coding assistant, the AI scaffolds the endpoint, and the implementation is up for review within minutes. Fast, but unanchored.

With SDD, the flow starts differently. Before the AI writes anything, a proposal is created in OpenSpec describing the change: what the endpoint does, what it accepts, what it returns, and any constraints around authentication or error handling. The AI coding assistant reads that proposal and implements against it. If the team uses Spec Kit, the same intent flows through a structured four-phase process: specify, plan, tasks, implement. Either way, the behavior is defined first and the code follows.

Now look at what you have as a QA engineer. You have a structured document describing exactly how that endpoint should behave, written before the implementation existed and kept in the same repo as the code. Your contract test is not a reverse-engineering exercise anymore. You read the spec, you define the consumer expectations from it, and you write assertions that directly reflect what was agreed. If the AI drifts from the spec during implementation, your contract test catches it. If the spec itself changes, it changes explicitly, in version control, with a diff you can review.

The verification step makes this even tighter. OpenSpec includes a verify command that checks the implementation against the spec after the AI finishes its work. Think of that as a pre-flight check before your contract tests even run. Two layers of validation, both anchored to the same source of truth.

The QA Engineer's Advantage

Developers tend to read specs as build instructions. The spec tells them what to create, and once the code is written, the spec has done its job. QA engineers read the same document differently. They are already asking what could go wrong, where the edge cases are, and how to prove the behavior is correct. That is not a different skill set. That is a better relationship with the spec.

This is why QA engineers should not be waiting at the end of an SDD workflow to receive a finished implementation. They should be involved when the spec is being written. Catching an ambiguous input validation rule in a proposal document costs nothing. Catching it after the AI has generated three layers of code that depend on that rule is expensive.

Spec ownership in SDD is not a bureaucratic responsibility. It is leverage. When QA owns or co-owns the spec, the test strategy writes itself. Coverage decisions come from the spec, edge cases come from the spec, and contract assertions come from the spec. You are not chasing a moving target after the fact. You are working from the same artifact the AI used to build the thing you are testing.

The teams that figure this out early will have QA engineers who are less reactive and more influential. Not because the role changed, but because the artifact they have always been best at interpreting finally became the most important thing in the workflow.

The Risks to Watch

SDD does not eliminate risk. It shifts where the risk lives, and if you are not paying attention, that shift can create a false sense of confidence.

The first risk is spec drift. A spec is only useful as a source of truth if it stays in sync with the implementation. When a feature evolves mid-sprint, when a developer makes a small adjustment without updating the proposal, or when the AI is given a follow-up prompt that quietly contradicts the original spec, the document and the code start to diverge. Your contract tests are now validating behavior that was agreed on paper but never actually implemented. This is the same problem as a flaky test, except harder to spot because everything looks green.

The second risk is over-trusting AI-generated specs. Some SDD tools allow the AI to generate the proposal itself from a high-level prompt. That can be a useful starting point, but it is not a substitute for human review. An AI-generated spec can be internally consistent and still be wrong about what the product actually needs. If nobody reads it critically before implementation starts, you have just automated the misunderstanding.

The third risk is treating the spec as a one-time artifact. The teams that get the most out of SDD are the ones that update the spec when requirements change, archive completed changes properly, and review spec diffs with the same attention they give to code diffs. A spec that stops being maintained stops being trustworthy, and a contract test built on an untrustworthy spec is just noise in your pipeline.

The good news is that all three risks are visible. They show up as diffs, as failed verifications, as mismatches between the spec and the contract. The discipline is in deciding to look.

Conclusion

Spec-Driven Development and contract testing are not competing ideas. They are complementary ones that have been living in separate conversations for too long. Contract testing gives you a way to enforce agreed behavior at the integration layer. SDD gives you a way to establish that agreement before a single line of code is written. Together they close the gap that AI-assisted development has made wider: the gap between what was intended, what was built, and what was tested.

The practical shift is smaller than it sounds. If you are already writing contract tests, you are already thinking in terms of expected behavior and defined agreements. The next step is pushing that thinking earlier in the cycle, into the spec, before the AI starts generating code. That is where your instincts as a QA engineer are most valuable and currently most underused.

Next time a new feature lands in your backlog, before the developer opens their AI coding assistant, ask one question: is there a spec for this? If the answer is no, that is your opening. Write one, or push for one. Define the behavior, lock in the agreement, and let everything downstream, the AI implementation, the code review, the contract test, follow from it.

The spec is the contract. It always was. SDD just makes it official.