---
title: "Requirement Bugs: Check the Spec Before the Agent Codes"
description: "Requirement bugs — ambiguity, contradictions and gaps — survive a careful read and reach production as code. How to catch them before your agent starts."
author: "MDflow"
date: 2026-12-02
reading_time: "20 min"
canonical_url: https://mdflow.cz/blog/requirement-bugs-ai-coding-agents
md_url: https://mdflow.cz/blog/requirement-bugs-ai-coding-agents.md
---

# Requirement Bugs: Check the Spec Before the Agent Codes

*Published December 2, 2026 · 20 min read*


Here are two rules from the same specification. *When an order is submitted and inventory is not available, the system shall place the order on backorder.* And, a few lines further down: *The system shall not place any order on backorder.*

Read one at a time, both are fine. Read together, they describe a system nobody can build. A human reviewer skims past it because reviewers read sentences, not combinations. An AI coding agent does not skim past it — it picks one, silently, and writes code that honors a decision you never made. Trace a surprising production behavior back far enough and it rarely ends at the code. It ends at a sentence that meant one thing to the person who wrote it and something else to whatever implemented it. That is a **requirement bug** — a defect in the spec rather than in the code — and it is the cheapest bug in software to fix and one of the most expensive to find late.

> **TL;DR** — **Requirement bugs** are defects in the spec, not the code: wrong level of detail, ambiguity, inconsistency, and gaps. Three of those four are invisible in any single sentence, which is why careful reading does not catch them and why AI agents amplify them — the agent resolves them for you, without telling you. AWS's Automated Reasoning Group shipped a working answer in [Kiro's requirements analysis](https://kiro.dev/blog/deep-spec-analysis/): an LLM translates the spec into formal logic, a solver proves whether it is consistent and complete, and the human decides the questions that remain. The checker runs on text, so the text has to be somewhere durable. [MDflow](/) is a versioned markdown workspace where specs, domain rules and the decisions behind them live — readable by your reviewers and fetchable by your agents. [Start free](/login).

## What is a requirement bug?

**A requirement bug is a defect in the specification rather than in the code — a sentence or a set of sentences that cannot be implemented, or can be implemented in more than one defensible way.** It is not a typo and not a missing feature. It is an instruction that looks complete and is not.

The Kiro team sorts them into four classes, and the sort is worth internalizing because it tells you which ones a human review can realistically catch:

| Class | What it looks like | Why it survives review |
| --- | --- | --- |
| **Wrong level of detail** | "The system shall support authentication" (a thesis), or "the system shall use JWT with a 15-minute TTL" (a recipe) | Visible in one sentence — the one class a careful reader does catch |
| **Ambiguity** | "The system shall remove the record" — hard delete, or soft delete? | Each reader resolves it instantly and silently, in their own direction |
| **Inconsistency** | Two rules that cannot both hold | Requires reasoning over *pairs* of rules and their shared triggers |
| **Incompleteness** | A reachable state no rule covers | Requires reasoning over the *whole* set at once to see what is missing |

Note what the right-hand column says. Only the first class is reliably catchable by reading one sentence at a time. Ambiguity is in the sentence, but it hides in the reader rather than the text — you are not conscious of your own interpretation bias, so a sentence that is crystal clear to you is crystal clear in a different direction to someone else. Inconsistency and incompleteness are properties of the set, and the set grows combinatorially: thirty acceptance criteria give you four hundred and thirty-five pairs to hold in your head, before you start asking which triggers can fire at the same time.

That is the honest reason spec review does not work the way we pretend it does. It is not laziness. It is that we assigned a combinatorial search to a reading process.

## The five rules that cannot be implemented

Here is the worked example from the Kiro team's write-up — an order system, five acceptance criteria, each individually reasonable:

```text
R1. WHEN an order is submitted AND inventory is available,
    THE Order System SHALL fulfill the order.
R2. WHEN an order is submitted AND inventory is not available,
    THE Order System SHALL place the order on backorder.
R3. THE Order System SHALL NOT place any order on backorder.
R4. WHEN an order is canceled,
    THE Order System SHALL refund all payments associated with the order.
R5. WHILE an order is in a canceled-and-refunded state,
    THE Order System SHALL NOT fulfill the order.
```

Three findings come out of that set, and they are instructively different in difficulty.

**The obvious conflict.** Ask whether any situation exists in which all five rules hold *and* R2's trigger is active. There is none: R2 demands a backorder, R3 forbids every backorder. The responsible pair is `{R2, R3}`. A careful reader could find this one — if they happened to compare those two lines out of the ten pairs available.

**The conditional contradiction.** Now take an order in a canceled-and-refunded state and submit it again, which is what a customer re-ordering looks like. Split on inventory. If inventory is available, R1 says fulfill and R5 says do not — a contradiction on the same output, from `{R1, R5}`. If inventory is not available, you are back in `{R2, R3}`. Either branch fails, so no implementation satisfies all five. Nobody finds this by reading. It requires constructing a scenario, then case-splitting inside it.

**The gap.** Ask the opposite question: is there a reachable situation in which *none* of the behavioral rules fire? Yes — no submission event, no cancellation, not in the canceled-and-refunded state. The order exists and nothing says what the system should do with it. R3 still applies, but a blanket prohibition is not behavior. Absence has no sentence to highlight, which is precisely why reviewing a document cannot surface it.

Notice the shape of the useful question in all three cases. It is never "is this spec consistent?" in the abstract. It is "assert this trigger, now is the set satisfiable?" The clash only becomes visible once a scenario is pinned down — which is exactly the step a human reviewer skips and a solver does exhaustively.

## Why this costs more in the AI era

Vague specs have always been expensive. Two things changed.

First, **the prompt is now the de-facto requirement.** Whatever you typed into the agent is the only tangible artifact capturing what you wanted. Every vague sentence in it becomes a decision the agent makes on your behalf, undisclosed, and you find out when the behavior is already in production.

Second, **agents generate faster than anyone reviews**, so the gap between what you meant and what got built widens on every iteration rather than closing.

There is measurement behind this, not just vibes. Researchers who deliberately mutated clear prompts into ambiguous, contradictory and incomplete ones measured **Pass@1 drops of 20–40%**, with **60–90% of the syntactically valid code being semantically wrong** — it compiles, it runs, it does the wrong thing ([Larbi et al., 2025](https://arxiv.org/abs/2507.20439)). A separate study on underspecification found that models **silently fill the gaps**, and that underspecified prompts are roughly **twice as likely to regress** when you change the model or the prompt ([Yang et al., 2025](https://arxiv.org/abs/2505.13360)). That second finding is the quiet one. An underspecified spec is not merely a risk today; it is a thing that breaks when you upgrade, because the new model fills the same gap with a different bias.

## How a spec checker actually works

Rajath Mahendrappa Kotyal of the AWS Automated Reasoning Group walked through the pipeline at AI Engineer, and the team's write-up fills in the detail. Three stages, and the division of labor is the whole point.

**1. Refinement — an LLM, because this part needs creativity.** Thesis-level criteria get rewritten into testable, solution-free ones. The process works backwards from the user story: what does success look like, what must hold for it to be reached, what could prevent each prerequisite, is that path covered? In the published example, a five-criterion "delete property" requirement comes out with three amendments (a contradiction resolved, implementation language stripped, an EARS pattern corrected) and three entirely new criteria covering error paths nobody had written — the property has active leases, the property does not exist, the user cancels the prompt.

**2. Auto-formalization — an LLM again, but now with a check on it.** The refined criteria become an SMT-LIB model: a schema of entities, attributes, events and outputs; one implication per criterion (the WHEN/IF clause is the antecedent, the SHALL clause the consequent); and a set of *background assertions* encoding constraints nobody wrote down, such as a duration never being negative.

The clever part is what they do with a known weakness. LLM translation is non-deterministic — ask ten times, get several answers. Instead of suppressing that, they measure it. Sample many formalizations of the same criterion, then use the reasoning engine to cluster them **by logical equivalence**: candidates that behave identically on every input land together regardless of how differently they are written. The spread across clusters is the **semantic entropy** of the translation, and it reads as three bands:

- **Low** — the model agrees with itself. Take the majority cluster and move on.
- **High** — the model cannot formalize this reliably and is probably confabulating. Abstain; the sentence needs rewriting by a human.
- **In between** — the model robustly produces two or three *different* readings. That is genuine ambiguity in your English. Compute a semantic diff between the top two candidates, find the situations where they disagree, and ask.

This is the step I find most transferable, independent of any solver. Disagreement between samples of the same model is not noise to be averaged away. It is a measurement of how ambiguous your text is.

**3. Logical analysis — the solver, because this part needs a guarantee.** With a formal model in hand, the engine answers the questions from the order example exhaustively, and returns the *minimal set of rules* responsible for each clash rather than a vague complaint. It also samples accepted and rejected scenarios — concrete behaviors your spec permits or forbids — and an LLM judge filters them down to the ones that are *surprising* given the user story, so you are asked about the handful that matter instead of drowning in valid trivia.

Every finding, whatever its type, is surfaced the same way: a plain-language question with exactly two answers. A means keep it as-is; B means change it, with a specific proposal. You answer; the requirement gets rewritten to make your choice explicit.

**The division of labor is the lesson.** The LLM translates, the solver checks, the human decides. Each component does the thing it can be held to.

## Why it matters for developers and for AI agents

### For developers

The cost curve is the argument. A requirement bug caught before design costs one answered question. The same bug caught after implementation costs a redesign, a migration, and an argument about which behavior was intended — held months later, by people reconstructing intent from code. And "shall we hard-delete or soft-delete" is a thirty-second decision when asked at the right moment and a quarter-long project when asked after the data is gone.

### For AI agents

An agent is a context engine: it produces output exactly as good as the context it is handed. Hand it a contradiction and it cannot flag the contradiction as a contradiction, because its job is to produce code and a contradiction has no code. So it resolves silently. Worse, the resolution is not stable — it can flip between runs, between models, and between a prompt edit and the next. Clearing the ambiguity *in the artifact* is the only fix that survives a model upgrade. This is the same separation-of-duties logic as [keeping the generator away from the validator](/blog/generator-cannot-be-the-validator): whatever writes the artifact should not be the only thing judging it.

## Which specs benefit most

Not every document deserves formalization. The ones that pay it back:

1. **Rule-heavy domains** — billing, entitlements, refunds, tax, insurance eligibility, access control. Many small rules with overlapping triggers is exactly the shape where conflicts hide.
2. **State machines** — order lifecycles, subscription states, approval flows. Completeness gaps live here, in the transitions nobody enumerated.
3. **Anything with a "shall not"** — a single blanket prohibition can silently contradict a dozen behavioral rules written elsewhere, by someone else, months apart.
4. **Specs assembled from several sources** — a PRD, a security standard, a compliance rule and a legacy "how we've always done it" note. Each is coherent alone. The merged set is where `{R2, R3}` lives.
5. **Anything you intend to hand to an agent unattended** — because the gap between intent and output gets no human read before it ships.

## What a checker cannot do

Be precise about the limit, because overselling this is easy. **There is no oracle for specification correctness other than the user.** Only you know what you meant. A checker verifies domain-independent properties — testable, solution-free, unambiguous, consistent, complete — and those are genuinely checkable. Whether the surviving reading is the one you intended is not.

And there is a sharper limitation that decides whether the whole approach is pleasant or maddening in practice: **implicit domain knowledge**. The Kiro team calls it the dark matter of requirements — the facts everyone in the domain knows and nobody writes down. An order cannot be canceled before it was submitted. A property cannot have two active owners. A refunded payment cannot be refunded again. Without an explicit model of what is possible in your domain, the solver dutifully reports contradictions and gaps in situations that *cannot occur*, and you spend your afternoon dismissing findings about impossible worlds. Their current mitigation is to sample background assertions from the LLM repeatedly and keep the ones that recur — and they are candid that building good formal domain models is where most of the remaining headroom lives.

Which lands on something unglamorous. Every part of this pipeline consumes text somebody has to maintain: the requirements, the domain constraints that bound them, and the decisions produced by answering the questions. A clarification answered in a chat session and nowhere else is a bug waiting to be re-introduced by the next person who writes the next version of that sentence.

## How MDflow fits

The boundary first. **MDflow does not analyze specs.** There is no formalizer, no solver, no entropy measurement — that belongs in Kiro, or in whatever checker you adopt. What MDflow is, is the durable, versioned, agent-readable home for the documents such a checker reads and the decisions it produces.

**What lines up today**

- **A spec is a markdown document, not a database row.** Acceptance criteria in EARS, the domain constraints beside them, frontmatter for status and owner. The same file is read by a reviewer and fetched by an agent, with no schema to adopt and no export step.
- **The domain model gets to be a first-class document.** The dark matter — what cannot happen in your domain — is reusable across every feature spec you will ever write, and it is exactly the kind of knowledge that dies in a branch. Put it in a folder of its own and it outlives the feature that first needed it.
- **Folder descriptions are the retrieval signal.** A folder described as *"domain invariants — what cannot happen in the ordering system, with the rule each one constrains"* is what makes it findable at all. [`mdflow_get_context`](/docs/mcp) ranks folder descriptions above folder and document names, so an agent asking about order states gets the invariants without being told the path.
- **Version history answers "when did the contradicting rule enter".** Every write path — the editor, the [HTTP API](/docs/api) and the [MCP server](/docs/mcp) — snapshots the previous body, with line-by-line diffs and a non-destructive restore. When a spec acquires an R3 that breaks an R2 written in March, that is the question you need answered. It is a Pro feature, and deliberately not exposed over the API or MCP.
- **The actor trail is per-write.** A cross-document feed at `/log` records created, edited, shared and deleted events with the actor on every row — `you` for browser actions, `automated · <token name>` for anything arriving through an agent. Useful when the spec and the agents that read it live in the same workspace.
- **The human decision has somewhere to happen.** Two-option clarification questions need a reviewer. Share a spec by email with comment access, or publish a read-only link; comments land on the document rather than in a thread nobody can find later.
- **Agents read and write it over MCP or HTTP.** Agent control is a Pro feature — the MCP server, the HTTP API and Personal Access Tokens all require it — and on Pro the connection is OAuth from Claude, OAuth from ChatGPT (in beta), or a Personal Access Token for REST.

> **Connect Claude to MDflow:** open the [MDflow connector](https://claude.ai/directory/mdflow) in Claude's Connectors Directory, click **Connect to Claude**, and sign in — no URL or token to paste. One connection covers claude.ai, the Claude desktop and mobile apps, and Claude Code signed in with a Claude subscription (MDflow Pro). Team workspaces are not reachable through the connector and use an `mdt_` Team access token instead, with the bearer-header clients listed in the [MCP docs](/docs/mcp).

**Honest gaps.** Nothing in MDflow validates a spec: write two contradicting rules and it stores both faithfully. Version history and comments are not readable over the API or MCP, so an agent auditing a workspace sees the current text and not the diffs or the discussion that produced it. And there is no compare-and-swap on the agent surface — the editor checks `updated_at` before saving and raises a conflict, but the API and MCP write paths do not, so two agents editing the same spec is last-write-wins.

**Where this is headed** — direction, not a dated commitment. The interesting gap is between a document as prose and a document as a record something else can check: frontmatter an agent surface understands rather than merely stores, and a way for an external checker's findings to attach to the sentence that caused them. Both are interests, not roadmap.

## The bottom line

The bug was in the sentence before it was ever in the code. That was true before AI and it is more expensive now, because the thing reading the sentence writes the code immediately and resolves every ambiguity on your behalf without mentioning it.

Three changes, in order of payoff:

1. **Write acceptance criteria in a form that can be checked** — EARS templates, observable inputs and outputs, no implementation language. Most of the value arrives before any solver does.
2. **Review the set, not the sentences.** Ask which rules can fire together and what happens when they do, and ask which reachable states have no rule at all.
3. **Write down the domain constraints you think are obvious**, because they are the reason a checker's findings are useful rather than noise — and because the next model will not share your assumptions.

Then keep all three somewhere a reviewer and an agent can both open.

[Start free](/login) · [Connect an AI agent](/docs/mcp) · [Read the API docs](/docs/api)

## Frequently asked questions

### What is a requirement bug?

A requirement bug is a defect in the specification rather than in the code. There are four classes: the wrong level of detail (a thesis statement like "the system shall support authentication", or an implementation recipe), ambiguity (one sentence with two plausible readings), inconsistency (two requirements that cannot both hold), and incompleteness (a reachable situation no rule covers). All four survive a careful read, for two different reasons. Ambiguity is resolved silently by each reader in their own direction, so nobody experiences the sentence as unclear. Inconsistency and incompleteness are properties of the whole set rather than of any sentence, so they only appear once you reason over every combination of rules at once.

### Why can't an LLM just read the spec and spot the contradiction?

It can spot some. The problem is that consistency and completeness are properties of the whole requirement set, so checking them means reasoning over every combination of triggers that can fire together — a combinatorial search rather than a reading task. A model asked whether a spec is consistent produces a plausible opinion with no guarantee behind it. A solver asked whether any implementation can satisfy all the rules at once returns a proof, plus the minimal subset of rules responsible for the clash.

### What is EARS notation?

EARS, the Easy Approach to Requirements Syntax, is a small set of sentence templates for acceptance criteria — WHEN, WHILE, WHERE, IF-THEN and ubiquitous SHALL clauses. The value is that each template maps cleanly onto a logical implication: the WHEN or IF clause becomes the antecedent, the SHALL clause the consequent. That is what makes a requirement written in EARS mechanically checkable rather than merely tidy.

### Can a solver tell you whether your spec is right?

No. There is no oracle for specification correctness other than the person who knows what they meant. A solver checks domain-independent properties — is this set consistent, does it cover every case, does this sentence admit more than one formal reading — and those checks are real. Whether the surviving interpretation matches your intent is a question only you can answer, which is why a good checker surfaces findings as concrete two-option questions instead of silently picking.

### Where should the answers to spec clarification questions live?

In the spec itself, and in a durable domain document beside it. A clarification answer is a decision — this phrase means soft delete, this rule wins over that one — and if it only exists in the chat session that produced it, the next agent re-derives it differently. The same applies to the implicit domain knowledge that makes a spec hold together: that an order cannot be canceled before it was submitted, that a refunded payment cannot be refunded again. Write those down where both a reviewer and an agent can fetch them.

## Further reading

- [Requirements analysis: catching requirement bugs before they become code](https://kiro.dev/blog/deep-spec-analysis/) — the Kiro team's write-up of the three-stage pipeline, with the order-system and delete-property examples (12 May 2026)
- [Analyze requirements](https://kiro.dev/docs/specs/analyze-requirements/) — the user-facing documentation for the feature
- [Your Spec Has Bugs. Catch Them Before Your Agent Codes.](https://www.youtube.com/watch?v=0EnLxIbAvYk) — Rajath Mahendrappa Kotyal, AWS, at AI Engineer
- [When Prompts Go Wrong: Evaluating Code Model Robustness to Ambiguous, Contradictory, and Incomplete Task Descriptions](https://arxiv.org/abs/2507.20439) — Larbi et al., 2025
- [What Prompts Don't Say: Understanding and Managing Underspecification in LLM Prompts](https://arxiv.org/abs/2505.13360) — Yang et al., 2025
- [Challenges in applying large language models to requirements engineering tasks](https://doi.org/10.1017/dsj.2024.8) — Norheim et al., *Design Science*, 2024
- [Spec-Driven Development: Where Your Markdown Specs Should Live](/blog/spec-driven-development-markdown-specs) — the workflow this sits inside, and where each kind of spec belongs
- [The Generator Cannot Be the Validator](/blog/generator-cannot-be-the-validator) — why the thing that writes an artifact must not be the only thing that judges it
- [Behavior Specs for AI Agents: Opinions You Can Evaluate](/blog/behavior-specs-for-ai-agents) — specifying how an agent should work, not just what it outputs
- [Connect an AI agent to MDflow](/docs/mcp) · [HTTP API](/docs/api) · [FAQ](/faq)

