<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: guo king</title>
    <description>The latest articles on DEV Community by guo king (@speccoding).</description>
    <link>https://dev.to/speccoding</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3821717%2F3113cbab-97d2-49b7-abc0-1a8df46e1040.png</url>
      <title>DEV Community: guo king</title>
      <link>https://dev.to/speccoding</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/speccoding"/>
    <language>en</language>
    <item>
      <title>We ran OpenSpec + Superpowers end to end twice. The reviewer decided the score.</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Tue, 17 Nov 2026 09:33:37 +0000</pubDate>
      <link>https://dev.to/speccoding/we-ran-openspec-superpowers-end-to-end-twice-the-reviewer-decided-the-score-462l</link>
      <guid>https://dev.to/speccoding/we-ran-openspec-superpowers-end-to-end-twice-the-reviewer-decided-the-score-462l</guid>
      <description>&lt;p&gt;OpenSpec plans a change. Superpowers controls how an agent builds it. People keep asking whether the two work together, and the usual answer is a community schema called &lt;a href="https://github.com/JiangWay/openspec-schemas/tree/main/superpowers-bridge" rel="noopener noreferrer"&gt;superpowers-bridge&lt;/a&gt;. Its README lists OpenSpec 1.4.1 and Superpowers v5.1.0 as the versions it was written against and calls that "a historical snapshot, not an end-to-end compatibility guarantee".&lt;/p&gt;

&lt;p&gt;Both tools have moved two major versions since. So on 17 November 2026 we ran the bridge end to end twice on OpenSpec 2.1.0 and Superpowers 7.0.2, from the same one-line request, and scored both results with a test suite the agent never saw.&lt;/p&gt;

&lt;p&gt;The schema still works. The score depended on the person answering its questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fixture:&lt;/strong&gt; a small Node API whose handlers each invent their own error body. A doc in the repo says the shipped mobile apps read &lt;code&gt;body.error&lt;/code&gt; as a string.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Request:&lt;/strong&gt; "Our API error responses are all over the place. Clean them up so they're consistent."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scoring:&lt;/strong&gt; eight hidden HTTP checks, written in September and never shown to the agent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent:&lt;/strong&gt; Claude Code 2.1.326, Claude Opus 5.5 as the controller, headless. Each human message was one &lt;code&gt;claude -p&lt;/code&gt; call resumed on the same session.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The workflow asks questions, so someone has to answer. We wrote the rules down before each run:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Run A, the informed reviewer.&lt;/strong&gt; The person knows what the case's spec says. They answer only what is asked, approve a proposal unless it contradicts the spec, correct only the point that contradicts it, and never mention something a proposal leaves out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run B, the approver.&lt;/strong&gt; The person knows the one-line request and nothing else. They answer "No preference, your call" and approve everything.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;The two left columns are single-prompt runs we recorded on the same fixture in September, with the same model.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;One prompt, vague (3 runs)&lt;/th&gt;
&lt;th&gt;One prompt, spec (3 runs)&lt;/th&gt;
&lt;th&gt;Bridge run A&lt;/th&gt;
&lt;th&gt;Bridge run B&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hidden checks passed&lt;/td&gt;
&lt;td&gt;7/8 in all three&lt;/td&gt;
&lt;td&gt;8/8 in all three&lt;/td&gt;
&lt;td&gt;8/8&lt;/td&gt;
&lt;td&gt;6/8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Messages from the person&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;8 to merge, 15 to archive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent working time&lt;/td&gt;
&lt;td&gt;42 to 44 s&lt;/td&gt;
&lt;td&gt;60 to 67 s&lt;/td&gt;
&lt;td&gt;21 min 25 s&lt;/td&gt;
&lt;td&gt;16 min 3 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost reported by Claude Code&lt;/td&gt;
&lt;td&gt;$0.17 to $0.19&lt;/td&gt;
&lt;td&gt;$0.19 to $0.26&lt;/td&gt;
&lt;td&gt;$6.28&lt;/td&gt;
&lt;td&gt;$5.18&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tests in the repo afterwards&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;15 to 17&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;td&gt;35&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;With a person who approved everything, the bridge scored one check lower than a plain vague prompt. With a person who knew the rules, it matched the spec prompt, at about 27 times the cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the decisions were
&lt;/h2&gt;

&lt;p&gt;In run A the agent asked three real questions: why, what shape the error body should have, and how to build it. It did not ask about status codes. It decided those itself and listed them in the chat under "Calls I made": an archived project stays 400, a validation error stays 400. The case's spec says 409 and 422, so our reviewer corrected both. That list was the most useful thing the brainstorming step produced.&lt;/p&gt;

&lt;p&gt;A third decision was not in the chat. The summary listed five calls. The design file the agent had just written contained a sixth:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- `details` (array, optional) — only for validation: `[{ field, message }]`.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our reviewer approved the design from the chat summary without opening the file, and caught the line one turn later while reading the generated &lt;code&gt;spec.md&lt;/code&gt;. That was our lapse, and we left it in the record. It matters because an optional field gives two error-body shapes, and "every error body has the same top-level keys" is the one hidden check all three vague single-prompt runs failed.&lt;/p&gt;

&lt;p&gt;In run B the same workflow reached different decisions and nobody objected:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The error body is &lt;code&gt;{ error, code }&lt;/code&gt;, with &lt;code&gt;details&lt;/code&gt; only on validation errors.&lt;/li&gt;
&lt;li&gt;Status codes stay as they are.&lt;/li&gt;
&lt;li&gt;Echoing &lt;code&gt;X-Request-Id&lt;/code&gt; is out of scope: "It would help support, but it's a separate feature from consistency."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three were stated in the chat and approved. The hidden suite then failed the same-keys check and the request-id check.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed since the bridge's baseline
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The commands are gone.&lt;/strong&gt; OpenSpec 2.0 removed the &lt;code&gt;/opsx:*&lt;/code&gt; commands. The same steps are skills now: &lt;code&gt;/openspec-ff-change&lt;/code&gt;, &lt;code&gt;/openspec-apply-change&lt;/code&gt;, &lt;code&gt;/openspec-verify-change&lt;/code&gt;, &lt;code&gt;/openspec-continue-change&lt;/code&gt;, &lt;code&gt;/openspec-archive-change&lt;/code&gt;. The bridge's README still shows the old names.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The profile matters.&lt;/strong&gt; &lt;code&gt;ff&lt;/code&gt;, &lt;code&gt;continue&lt;/code&gt; and &lt;code&gt;verify&lt;/code&gt; are not in OpenSpec's default profile. Select the expanded one first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The schema itself is fine.&lt;/strong&gt; &lt;code&gt;openspec schema validate superpowers-bridge&lt;/code&gt; passes on 2.1.0, every Superpowers skill it names still exists, and the design and plan landed in the change folder instead of &lt;code&gt;docs/superpowers/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Native execution is a trap for this schema.&lt;/strong&gt; Superpowers now offers two ways to run a plan, subagent-driven or "Native". The schema only covers the first. In run B the agent recommended Native, our approver accepted, and the schema's verify, retrospective and archive steps were skipped until we started them by hand. In run A the same handoff never offered the choice.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One thing the workflow found that the spec did not
&lt;/h2&gt;

&lt;p&gt;In both runs the whole-branch review at the end flagged a bug that was already in the fixture. Ids are looked up as keys of plain objects, so &lt;code&gt;GET /projects/__proto__/tasks&lt;/code&gt; returned 200, and &lt;code&gt;PATCH /tasks/__proto__&lt;/code&gt; wrote onto &lt;code&gt;Object.prototype&lt;/code&gt; for the whole process. We replayed the six single-prompt Opus diffs against the same two requests. Five still do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we took from it
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The bridge supplies process, not rules.&lt;/strong&gt; Both runs read the mobile contract and kept &lt;code&gt;error&lt;/code&gt; a string. The rules that were not in the repo were corrected by a person in run A and decided by the agent in run B.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read the artifact, not the summary.&lt;/strong&gt; Most decisions were in the chat. One was only in the file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If you already know the rules, write them down.&lt;/strong&gt; A spec prompt got 8 of 8 in about a minute for about $0.23.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If nobody will read the artifacts, skip the ceremony.&lt;/strong&gt; Approving unread documents cost more and decided nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You do get a record.&lt;/strong&gt; Both runs left the brainstorm, proposal, design, spec, tasks, plan, verification and retrospective in the repo. A single prompt leaves a diff.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;p&gt;Two runs, one fixture, one controller model. The person in both runs was one of us following a written protocol, and the informed reviewer's answer sheet is the same spec the single-prompt spec runs were given. Model output varies, and these two runs already took different paths through the same schema.&lt;/p&gt;

&lt;h2&gt;
  
  
  The data
&lt;/h2&gt;

&lt;p&gt;Every message as sent, a transcript of both sessions, the archived OpenSpec changes with all eight artifacts, the diffs, the hidden-suite results and per-turn cost are in a 103 KB pack, along with the setup that worked on current versions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://spec-coding.dev/blog/openspec-superpowers-bridge-recorded-runs" rel="noopener noreferrer"&gt;Full write-up, setup and run pack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://spec-coding.dev/examples/agent-runs/api-error-envelope" rel="noopener noreferrer"&gt;The single-prompt runs on the same fixture&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you run the bridge on another harness, or with the &lt;code&gt;CLAUDE.md&lt;/code&gt; routing fragment we skipped, we'd like to see how your run differs.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>testing</category>
      <category>programming</category>
    </item>
    <item>
      <title>The agent passed every check our ticket stated. It failed the rules we never wrote down.</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Thu, 12 Nov 2026 01:54:12 +0000</pubDate>
      <link>https://dev.to/speccoding/the-agent-passed-every-check-our-ticket-stated-it-failed-the-rules-we-never-wrote-down-ihg</link>
      <guid>https://dev.to/speccoding/the-agent-passed-every-check-our-ticket-stated-it-failed-the-rules-we-never-wrote-down-ihg</guid>
      <description>&lt;p&gt;A few weeks ago we published &lt;a href="https://spec-coding.dev/examples/agent-runs/models" rel="noopener noreferrer"&gt;78 recorded Claude Code runs&lt;/a&gt; comparing one-line prompts with specs. The headline number was that 28 of 30 spec runs passed every hidden check, against 12 of 48 runs without a spec.&lt;/p&gt;

&lt;p&gt;That number says a spec helps. It doesn't say &lt;em&gt;which part&lt;/em&gt; of the spec does the work. So we went back to one case, the checkout coupon ticket, and sorted the hidden checks by a single question: did the one-line ticket mention this rule or not?&lt;/p&gt;

&lt;p&gt;The answer was cleaner than we expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ticket and the checks
&lt;/h2&gt;

&lt;p&gt;The vague prompt was this, verbatim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Add coupon codes to checkout. Make sure invalid codes do not break payment.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The repo is a small Node checkout service. Before any run, we wrote a hidden suite of 11 checks and froze it. The agent never saw it. Five of those checks test rules the ticket never mentions, such as whether a user can redeem the same coupon twice.&lt;/p&gt;

&lt;p&gt;Here are six of the checks, with results from three vague runs and three spec runs on Opus 5.5:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Hidden check&lt;/th&gt;
&lt;th&gt;In the ticket?&lt;/th&gt;
&lt;th&gt;Vague runs&lt;/th&gt;
&lt;th&gt;Spec runs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Expired, disabled or unknown code leaves checkout payable&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Processor is charged exactly the displayed total&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A user cannot redeem the same coupon twice&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;2 of 3&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Two open checkouts cannot both spend a one-per-user coupon&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;2 of 3&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Applying without paying does not use the coupon up&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A second coupon replaces the first&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;td&gt;3 of 3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every check the ticket stated passed in every run. Every failure was on a rule nobody wrote down.&lt;/p&gt;

&lt;p&gt;On Haiku 4.5 the split was sharper: all three vague runs failed both reuse checks. With the spec, all three passed all 11.&lt;/p&gt;

&lt;h2&gt;
  
  
  The failure was a decision, and the agent told us about it
&lt;/h2&gt;

&lt;p&gt;The run that failed didn't crash, and its own tests passed. It looked at the coupon data, found no usage limit, and concluded there shouldn't be one. Its final message said so: there is no per-user or one-time limit in the coupon data, so none is enforced.&lt;/p&gt;

&lt;p&gt;That reasoning is defensible. A human teammate wouldn't make it, because they know what a coupon is for. The agent only knows what's in the repo and the prompt. The other two vague runs read the same data and decided coupons are single-use. Same ticket, two coupon policies, and the tests passed either way because each run wrote tests for the policy it chose.&lt;/p&gt;

&lt;p&gt;Two more things drifted without failing any check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A lapsed coupon.&lt;/strong&gt; If a coupon expires after it's applied but before payment, one vague run quietly charged full price ($54.00 instead of the $43.20 the customer was shown). The other two refused the first payment attempt. Nobody on a real team would have chosen either without discussing it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The error contract.&lt;/strong&gt; Every vague run threw an exception on a bad code. The spec runs returned &lt;code&gt;{ ok: false, reason }&lt;/code&gt;. A frontend written against one breaks on the other.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the spec said
&lt;/h2&gt;

&lt;p&gt;The spec that fixed this was short. This is its rules and acceptance criteria section, copied from the run pack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Rules
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;A coupon is either percentOff (of the subtotal) or amountOffCents.
&lt;span class="k"&gt;- &lt;/span&gt;A coupon can be redeemed once per user. It counts as redeemed only
  when an order is paid, not when it is applied.
&lt;span class="k"&gt;- &lt;/span&gt;Applying a second coupon replaces the first.

&lt;span class="gu"&gt;## Acceptance criteria
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;AC-1 Valid coupon: getSummary shows the discount and the discounted
  total; pay charges exactly that total.
&lt;span class="k"&gt;- &lt;/span&gt;AC-2 Unknown, disabled or expired code: applyCoupon returns
  { ok: false, reason } with reason unknown, disabled or expired.
  It does not throw, and the checkout keeps its previous total
  and stays payable.
&lt;span class="k"&gt;- &lt;/span&gt;AC-3 Code already redeemed by this user: returns
  { ok: false, reason: 'already_redeemed' }.
&lt;span class="k"&gt;- &lt;/span&gt;AC-4 Redemption is re-checked inside pay: if the user redeemed the
  coupon on another order after it was applied here, pay drops the
  coupon and charges the undiscounted total.
&lt;span class="k"&gt;- &lt;/span&gt;AC-5 An amount-off coupon larger than the subtotal brings the pre-tax
  amount to 0, never below.
&lt;span class="k"&gt;- &lt;/span&gt;AC-6 A successful apply returns { ok: true, code, discountCents }.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three lines of rules did most of the work. "Once per user" covers the reuse check. "Only when an order is paid" covers apply-without-paying. AC-4 covers the two-open-checkouts race, which is the check a reviewer is least likely to think of.&lt;/p&gt;

&lt;h2&gt;
  
  
  The spec had a gap too
&lt;/h2&gt;

&lt;p&gt;The spec tells &lt;code&gt;pay&lt;/code&gt; to re-check redemption. It says nothing about re-checking expiry. So all three spec runs honoured a coupon that expired between apply and pay, and charged the discounted total.&lt;/p&gt;

&lt;p&gt;One run flagged it in its summary: &lt;code&gt;pay&lt;/code&gt; only re-checks redemption, as AC-4 asks, and a coupon that expires after being applied is still honoured.&lt;/p&gt;

&lt;p&gt;We think this is the more useful result. The spec didn't make the agent smarter. It made the agent predictable, gaps included. One consistent answer that's flagged in a summary is something you can review. Three different answers spread across three implementations is not.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we changed in how we write criteria
&lt;/h2&gt;

&lt;p&gt;Four habits came out of this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Write down the rules you'd never say out loud.&lt;/strong&gt; Usage limits, who a rule applies to, and when something counts. These are the lines a colleague infers and an agent doesn't.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name the interface and the exact result.&lt;/strong&gt; "Invalid codes show an error" leaves the contract open. "&lt;code&gt;applyCoupon&lt;/code&gt; returns &lt;code&gt;{ ok: false, reason: 'expired' }&lt;/code&gt; and does not throw" closes it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask what can change between two steps.&lt;/strong&gt; Anything validated at step one and used at step two needs a re-check before the irreversible part. That's AC-4, and it's also the gap we left for expiry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check that each criterion fails today.&lt;/strong&gt; A criterion the current code already meets grades nothing.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  If you draft criteria with a model
&lt;/h2&gt;

&lt;p&gt;A model asked to "write acceptance criteria" will fill the open decisions with plausible guesses, which is the same failure one step earlier. We ask it to surface them instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are drafting acceptance criteria for a coding agent. Do not decide
business rules yourself. For the request below:

1. List every decision the request leaves open as a question:
   limits, who it applies to, when something counts, what happens on
   failure, and what can change between two steps.
2. Draft numbered criteria AC-1..n only for what is already decided.
   Each one names the function, endpoint or screen, the input, and the
   exact result or error code.
3. Mark any criterion the current code would already pass.

Request:
[paste the ticket]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A person answers the questions from step 1. Then the criteria get written.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;p&gt;Three runs per variant shows that something can happen, not how often. The repo is small and clean on purpose. We wrote both the spec and the hidden suite, so the spec covers what we test; the expiry gap is the evidence that it wasn't written to the test.&lt;/p&gt;

&lt;p&gt;The fixture repo, both prompts, the hidden suite and every run's diff are in the run pack on the &lt;a href="https://spec-coding.dev/examples/agent-runs/checkout-coupon" rel="noopener noreferrer"&gt;coupon case page&lt;/a&gt;, licensed CC BY 4.0. The template and the full table are on &lt;a href="https://spec-coding.dev/ai-coding-acceptance-criteria" rel="noopener noreferrer"&gt;AI acceptance criteria for coding agents&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you've seen an agent make a defensible decision nobody asked for, we'd like to hear which rule it was.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>testing</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>78 Claude Code runs on three tickets: the spec mattered more than the model</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Mon, 09 Nov 2026 06:13:53 +0000</pubDate>
      <link>https://dev.to/speccoding/78-claude-code-runs-on-three-tickets-the-spec-mattered-more-than-the-model-5gc1</link>
      <guid>https://dev.to/speccoding/78-claude-code-runs-on-three-tickets-the-spec-mattered-more-than-the-model-5gc1</guid>
      <description>&lt;p&gt;Current coding agents are good enough that "just describe the ticket" usually works. So is writing a spec still worth the time? We stopped arguing about it and recorded runs instead.&lt;/p&gt;

&lt;p&gt;We gave Claude Code three ordinary tickets on small fixture repos and ran each one several times on four models: Opus 5.5, Sonnet 5.5, Haiku 4.5 and Fable 5.1. Every ticket was run from a one-line prompt and from a spec. Two of them were also run with the repo's written rules deleted. That came to 78 runs and about $14.84 of API-equivalent cost.&lt;/p&gt;

&lt;p&gt;The short version: with a spec, 28 of 30 runs passed every hidden check. Without one, 12 of 48 did.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agent:&lt;/strong&gt; Claude Code 2.1.284, headless (&lt;code&gt;claude -p&lt;/code&gt;), one prompt per run, no follow-up messages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolation:&lt;/strong&gt; a fresh copy of the fixture repo for every run, with no user settings, hooks, plugins or MCP servers (&lt;code&gt;--setting-sources project --strict-mcp-config&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scoring:&lt;/strong&gt; each case has a hidden acceptance suite, written and frozen before the first run and never shown to the agent. The suites only call interfaces that existed before the change, and they accept any reasonable way of reporting an error, so a different API design doesn't count as a failure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No cleanup:&lt;/strong&gt; nobody touched the agent's output before it was scored.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The three tickets:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Checkout coupon codes:&lt;/strong&gt; "Add coupon codes to checkout."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API error envelope:&lt;/strong&gt; "Clean up our API errors." The repo has a mobile client in the field that reads &lt;code&gt;body.error&lt;/code&gt; as a string.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split-name migration:&lt;/strong&gt; "Split name into first_name and last_name." A billing sync outside the repo still reads &lt;code&gt;users.name&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;Each cell counts runs that passed every hidden check, out of runs recorded. "No docs" and "no rules" mean the repo's written constraints were removed. Fable 5.1 got one run per variant and skipped the no-docs variants, so read its column as a spot check.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Case and variant&lt;/th&gt;
&lt;th&gt;Opus 5.5&lt;/th&gt;
&lt;th&gt;Sonnet 5.5&lt;/th&gt;
&lt;th&gt;Haiku 4.5&lt;/th&gt;
&lt;th&gt;Fable 5.1&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Coupon, vague&lt;/td&gt;
&lt;td&gt;2/3&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;1/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coupon, spec&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;1/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API errors, no docs&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;not run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API errors, docs&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API errors, spec&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;1/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Migration, no rules&lt;/td&gt;
&lt;td&gt;2/3&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;not run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Migration, rules&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;1/3&lt;/td&gt;
&lt;td&gt;0/3&lt;/td&gt;
&lt;td&gt;0/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Migration, spec&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;3/3&lt;/td&gt;
&lt;td&gt;1/3&lt;/td&gt;
&lt;td&gt;1/1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;All spec runs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9/9&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9/9&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;7/9&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;3/3&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;All non-spec runs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;7/15&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;4/15&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0/15&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1/3&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;"Passed every check" is a strict bar. Most of the API "docs" runs failed exactly one check: they didn't use a single error shape across every endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually went wrong without a spec
&lt;/h2&gt;

&lt;p&gt;The failures weren't crashes. The code ran, and the agent's own tests passed. What went wrong was a decision nobody asked for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Coupons:&lt;/strong&gt; one Opus run decided coupons have no usage limit, and said so in its summary. The three vague runs split two ways on a coupon that lapsed before payment: one charged full price, and two refused the first payment attempt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API errors:&lt;/strong&gt; without the contract doc, two of three Opus runs changed &lt;code&gt;body.error&lt;/code&gt; from a string to an object. It's a well-designed envelope, and it shows every user on mobile v3.x a blank error banner. A 13-line contract doc was enough to stop that change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Migration:&lt;/strong&gt; one Opus run wrote a correct backfill and then ran &lt;code&gt;DROP COLUMN name&lt;/code&gt;, with a warning in the summary that nobody would act on. All six of its non-spec runs split names at the first space.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Four things we didn't expect
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. A spec makes the models nearly interchangeable.&lt;/strong&gt; With a spec, the smallest and largest models finished within two runs of each other. Without one, results ranged from 7 of 15 down to 0 of 15. On a risky ticket, the spec moved the result more than the choice of model did.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Benchmark order isn't safety order.&lt;/strong&gt; Anthropic reports Sonnet 5.5 at 70.6% on Terminal-Bench 4.0, above Opus 5.5 at 66.4%. On the migration with no written rules, Sonnet 5.5 dropped &lt;code&gt;users.name&lt;/code&gt; in all three runs, and Opus 5.5 did it once. Benchmarks reward finishing the task. This failure is what finishing it too thoroughly looks like.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Small models skip the README.&lt;/strong&gt; With a README line saying the billing sync reads &lt;code&gt;users.name&lt;/code&gt;, Opus and Sonnet kept the column in 6 of 6 runs. Haiku 4.5 dropped it in 3 of 3. Rules in the repo only help if the model goes and reads them. Rules in the prompt reached all four models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. A cheap model with a spec isn't cheap.&lt;/strong&gt; Haiku 4.5 with a spec averaged $0.20 and 129 seconds a run, over 15 to 40 turns. Opus 5.5 with a spec averaged $0.22 and 63 seconds. Sonnet 5.5 was the cheapest route to a passing run: $0.11 and 33 seconds with a spec.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two spec runs that failed
&lt;/h2&gt;

&lt;p&gt;Both were Haiku 4.5 on the migration, and both passed their own tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One stored "Mary Ann Smith" as first name "Ann Mary", last name "Smith". Every other name in the data was right, so a spot check would miss it. The hidden "no characters lost" check caught it.&lt;/li&gt;
&lt;li&gt;The other put the backfill in application code inside &lt;code&gt;open()&lt;/code&gt; instead of in the migration. Any deploy that runs migrations separately, or any other service reading the database, would see empty columns.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The lesson there is about tests, not specs. The checks that caught these ran the migration the way production would.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this doesn't show
&lt;/h2&gt;

&lt;p&gt;Three runs per variant is enough to show that something &lt;em&gt;can&lt;/em&gt; happen, not how often it does. We kept the repos small and clean on purpose, so each outcome could be traced to one prompt or one file. Larger codebases give an agent more to misread. We also wrote the specs, the docs and the suites ourselves, which is how specs work in practice, but it means the specs cover exactly what we test. The one gap a spec left open (in the coupon case) is reported on the case page. Only Claude models were tested, through one agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  The data
&lt;/h2&gt;

&lt;p&gt;Every prompt, fixture repo, hidden suite and runner script is downloadable, along with each run's diff, score and final message on every model (CC BY 4.0). One correction we found while preparing this post: seven Haiku 4.5 runs have empty diffs, because our recording script diffed against &lt;code&gt;HEAD&lt;/code&gt; and those runs most likely committed their own work (one says so in its final message). Their scores stand, since the suite ran on the working tree, but the diffs are gone. We fixed the runner and replayed the other 71 diffs through it, and every hidden-suite result matched.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://spec-coding.dev/examples/agent-runs/models" rel="noopener noreferrer"&gt;Cross-model results and cost table&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://spec-coding.dev/examples/agent-runs/" rel="noopener noreferrer"&gt;The three cases, run by run&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you rerun these with another agent (Codex, Cursor, Gemini CLI, Aider, anything), we'd like to publish your results next to ours. The runner takes an &lt;code&gt;AGENT_CMD&lt;/code&gt; variable, so pointing it at a different agent is one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;AGENT_CMD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'codex exec "$PROMPT"'&lt;/span&gt; ./run.sh coupon vague 1 codex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
      <category>claude</category>
      <category>testing</category>
      <category>programming</category>
    </item>
    <item>
      <title>That VARCHAR(255) Was Never a Decision. It Was a Default.</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Wed, 29 Jul 2026 03:56:48 +0000</pubDate>
      <link>https://dev.to/speccoding/that-varchar255-was-never-a-decision-it-was-a-default-nm2</link>
      <guid>https://dev.to/speccoding/that-varchar255-was-never-a-decision-it-was-a-default-nm2</guid>
      <description>&lt;p&gt;A migration file is permanent. Once it runs against production, you cannot take it back without writing another migration.&lt;/p&gt;

&lt;p&gt;Yet most teams write migrations the way they write application code: open an editor, start typing columns, figure out constraints as they go. The result is schemas full of implicit decisions nobody documented — default values nobody questioned, nullability choices that haunt the codebase for years.&lt;/p&gt;

&lt;p&gt;Writing a 30-minute schema spec &lt;em&gt;before&lt;/em&gt; the migration forces those decisions into the open, where they can be reviewed, challenged, and agreed upon.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why schemas deserve specs more than code does
&lt;/h2&gt;

&lt;p&gt;Application code gets rewritten. Frameworks get swapped. The database schema outlives almost everything else in the stack. A column added in 2019 is still there in 2026 unless someone explicitly removed it — and removing columns from a production database is one of the riskiest operations a team can perform.&lt;/p&gt;

&lt;p&gt;That longevity makes schema decisions high-leverage. And yet most of them are made implicitly:&lt;/p&gt;

&lt;p&gt;An engineer types &lt;code&gt;status VARCHAR(255)&lt;/code&gt; and moves on. Nobody asks why it's a varchar instead of a smallint. Nobody asks whether 255 is the right length or just the ORM default. Nobody asks what values are valid. The migration passes review because reviewers focus on application logic, not on whether &lt;code&gt;placed_at&lt;/code&gt; should be &lt;code&gt;TIMESTAMP&lt;/code&gt; or &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A year later: &lt;code&gt;status&lt;/code&gt; has 14 distinct string values in production, three of which are typos. &lt;code&gt;placed_at&lt;/code&gt; stored times without timezone info, and the billing reconciliation job has been silently miscalculating for months.&lt;/p&gt;

&lt;p&gt;Each bug traces back to a decision that was never made — just defaulted into.&lt;/p&gt;

&lt;h2&gt;
  
  
  The schema spec template
&lt;/h2&gt;

&lt;p&gt;A schema spec is not a design document. It's a concrete description of the table you're about to create, detailed enough that a reviewer can evaluate every column, constraint, and index before a single line of SQL exists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Schema Spec: orders&lt;/span&gt;

&lt;span class="gu"&gt;### Table: orders&lt;/span&gt;
Description: Stores customer purchase orders. One row per checkout.

| Column      | Type        | Nullable | Default           | Constraints              |
|-------------|-------------|----------|-------------------|--------------------------|
| id          | uuid        | NO       | gen_random_uuid() | PRIMARY KEY              |
| user_id     | uuid        | NO       | —                 | FK -&amp;gt; users(id)          |
| total_cents | bigint      | NO       | —                 | CHECK (total_cents &amp;gt;= 0) |
| currency    | char(3)     | NO       | 'USD'             | CHECK (currency IN ('USD','EUR','GBP')) |
| status      | smallint    | NO       | 0                 | CHECK (status IN (0,1,2,3)) |
| placed_at   | timestamptz | NO       | now()             | —                        |
| canceled_at | timestamptz | YES      | NULL              | —                        |

&lt;span class="gu"&gt;### Status mapping&lt;/span&gt;
0 = pending, 1 = confirmed, 2 = shipped, 3 = canceled

&lt;span class="gu"&gt;### Indexes&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; idx_orders_user_id ON (user_id) — supports lookup by customer
&lt;span class="p"&gt;-&lt;/span&gt; idx_orders_placed_at ON (placed_at DESC) — supports dashboard sorting
&lt;span class="p"&gt;-&lt;/span&gt; idx_orders_status ON (status) WHERE status IN (0, 1) — partial index for active orders

&lt;span class="gu"&gt;### Foreign keys&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; user_id -&amp;gt; users(id) ON DELETE RESTRICT

&lt;span class="gu"&gt;### Migration order&lt;/span&gt;
Must run after: 001_create_users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things this format buys you:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every column-level decision is &lt;strong&gt;visible&lt;/strong&gt; — &lt;code&gt;total_cents&lt;/code&gt; is a &lt;code&gt;bigint&lt;/code&gt; with a non-negative check, not a &lt;code&gt;decimal&lt;/code&gt; or a &lt;code&gt;float&lt;/code&gt;, and a reviewer can see that.&lt;/li&gt;
&lt;li&gt;Indexes surface &lt;strong&gt;before&lt;/strong&gt; the migration is written, so the team discusses query patterns at review time instead of discovering missing indexes in production.&lt;/li&gt;
&lt;li&gt;Migration ordering is documented, so dependency failures happen on paper instead of in staging.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Every column is four decisions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Nullability.&lt;/strong&gt; The database default is nullable — if you don't say &lt;code&gt;NOT NULL&lt;/code&gt;, the column accepts nulls. This is almost always wrong for new columns. A null &lt;code&gt;email&lt;/code&gt; means a user without an email: is that a valid state? The spec forces an answer for every column. Write YES or NO. Don't leave it blank.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defaults.&lt;/strong&gt; A default isn't a convenience — it defines what happens to &lt;em&gt;existing rows&lt;/em&gt; when you add a column to a populated table. Add &lt;code&gt;currency CHAR(3) NOT NULL&lt;/code&gt; without a default and the migration fails on any non-empty table. And the default itself is a business decision: &lt;code&gt;'USD'&lt;/code&gt; is fine if all existing customers are US-based, wrong if you have customers in Europe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check constraints.&lt;/strong&gt; &lt;code&gt;CHECK (total_cents &amp;gt;= 0)&lt;/code&gt; means the database rejects negative order totals regardless of what the application does. It's your last line of defense against bad data — and every check constraint is a business rule that belongs in review. If the app later needs a status &lt;code&gt;4&lt;/code&gt;, the team knows it's a schema change, not just a code change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Foreign keys.&lt;/strong&gt; &lt;code&gt;ON DELETE CASCADE&lt;/code&gt; means deleting a user deletes all their orders. &lt;code&gt;RESTRICT&lt;/code&gt; means you can't delete a user who has orders. &lt;code&gt;SET NULL&lt;/code&gt; keeps the order but orphans it. Each option is a different failure mode. Decide in the spec — not in whoever-writes-the-migration's head.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependency ordering is a design decision, not a framework detail
&lt;/h2&gt;

&lt;p&gt;A feature adds &lt;code&gt;subscriptions&lt;/code&gt;, &lt;code&gt;subscription_items&lt;/code&gt;, and &lt;code&gt;billing_events&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;subscriptions&lt;/code&gt; references &lt;code&gt;users&lt;/code&gt; (exists)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;subscription_items&lt;/code&gt; references &lt;code&gt;subscriptions&lt;/code&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;code&gt;products&lt;/code&gt; (being created in this same branch)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;billing_events&lt;/code&gt; references &lt;code&gt;subscriptions&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the real order is: &lt;code&gt;products&lt;/code&gt; → &lt;code&gt;subscriptions&lt;/code&gt; → &lt;code&gt;subscription_items&lt;/code&gt; → &lt;code&gt;billing_events&lt;/code&gt;. Your migration framework probably handles ordering mechanically — but the dependency chain is a design fact reviewers need to &lt;em&gt;see&lt;/em&gt;. Without the spec, the engineer discovers it when staging fails, fixes it by trial and error, and nobody learns anything.&lt;/p&gt;

&lt;p&gt;The spec should also note &lt;strong&gt;rollback ordering&lt;/strong&gt;: if migration 003 depends on 002, rolling back 002 while 003 is applied breaks the FK. That note matters most during incident response, when nobody has time to trace dependency chains manually.&lt;/p&gt;




&lt;h2&gt;
  
  
  The 30-minute habit
&lt;/h2&gt;

&lt;p&gt;Before your next migration, write the table as a spec: columns with explicit nullability and defaults, every check constraint, every index with the query it supports, FK delete behavior, and migration order.&lt;/p&gt;

&lt;p&gt;Put it in the PR description or a &lt;code&gt;specs/&lt;/code&gt; directory. Let someone reject it &lt;em&gt;before&lt;/em&gt; it becomes permanent.&lt;/p&gt;

&lt;p&gt;Thirty minutes of writing. Weeks of debugging saved. The math has never once failed me.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I write about spec-first delivery, API contracts, and release engineering at &lt;a href="https://spec-coding.dev" rel="noopener noreferrer"&gt;spec-coding.dev&lt;/a&gt;. The full guide — including zero-downtime backward-compatible migration patterns — is at &lt;a href="https://spec-coding.dev/blog/spec-database-schemas-before-writing-migrations" rel="noopener noreferrer"&gt;spec-coding.dev/blog/spec-database-schemas-before-writing-migrations&lt;/a&gt;, and there's a free &lt;a href="https://spec-coding.dev/tools/db-spec-generator" rel="noopener noreferrer"&gt;DB spec generator&lt;/a&gt; that outputs this exact template.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>sql</category>
      <category>postgres</category>
      <category>programming</category>
    </item>
    <item>
      <title>Your OpenAPI Spec Is Decoration Until CI Enforces It</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Wed, 29 Jul 2026 03:56:43 +0000</pubDate>
      <link>https://dev.to/speccoding/your-openapi-spec-is-decoration-until-ci-enforces-it-1and</link>
      <guid>https://dev.to/speccoding/your-openapi-spec-is-decoration-until-ci-enforces-it-1and</guid>
      <description>&lt;p&gt;My rule: if an OpenAPI spec is not wired into CI as an executable contract, it is decoration. A spec that no test asserts against will drift within two sprints.&lt;/p&gt;

&lt;p&gt;Here's how I take a YAML file sitting in a repo and turn it into a gate that blocks pull requests when the provider stops matching the promise it made to its consumers.&lt;/p&gt;




&lt;h2&gt;
  
  
  The gap unit and integration tests keep missing
&lt;/h2&gt;

&lt;p&gt;Unit tests pass. Integration tests pass. Then a mobile client crashes in production because the status field your service returns as &lt;code&gt;"PAID"&lt;/code&gt; became &lt;code&gt;"paid"&lt;/code&gt; after someone inlined an enum refactor.&lt;/p&gt;

&lt;p&gt;No test caught it because no test was looking at the &lt;strong&gt;wire-level shape&lt;/strong&gt;. That's the gap contract tests fill:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Field drift&lt;/strong&gt; — a rename, a type change, a nullability flip&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Response shape regression&lt;/strong&gt; — a consumer depended on &lt;code&gt;items[]&lt;/code&gt; always being present; now it's omitted when empty&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error code surface&lt;/strong&gt; — a 409 became a 422 because a library upgrade changed default behavior&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Header contracts&lt;/strong&gt; — idempotency keys, pagination cursors, content types&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of those show up in a green unit suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Consumer-driven vs provider-driven: pick based on who calls you
&lt;/h2&gt;

&lt;p&gt;Two schools, and I've shipped both.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provider-driven&lt;/strong&gt; tools (Schemathesis, Dredd) take your OpenAPI spec and pound the running server with generated requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consumer-driven&lt;/strong&gt; tools (Pact) flip it: each consumer writes tests against a mock of the provider, publishes the interactions to a broker, and the provider verifies those interactions against its real server on every build.&lt;/p&gt;

&lt;p&gt;My heuristic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You own all the consumers (one mobile app, one web app, one internal worker)? &lt;strong&gt;Go consumer-driven with Pact.&lt;/strong&gt; You get proof of exactly the subset of the contract your consumers actually use — nearly always a small slice of the full surface.&lt;/li&gt;
&lt;li&gt;Public API with unknown consumers? &lt;strong&gt;Go provider-driven with Schemathesis.&lt;/strong&gt; Anyone could be depending on any field, so you validate the full declared contract.&lt;/li&gt;
&lt;li&gt;Internal platform team? Usually &lt;strong&gt;both&lt;/strong&gt; — Pact for known consumers, Schemathesis fuzzing for everything else.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Generate the tests from the spec — don't write them by hand
&lt;/h2&gt;

&lt;p&gt;Hand-written contract tests rot. Generated ones stay honest because the spec is the source:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Schemathesis&lt;/strong&gt; reads &lt;code&gt;openapi.yaml&lt;/code&gt; and generates property-based cases: every endpoint, every status code branch, every schema boundary. One command, thousands of cases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prism&lt;/strong&gt; stands up a mock server from the same spec so consumer tests run without a real backend — and it validates the consumer's &lt;em&gt;requests&lt;/em&gt; against the spec too, so a malformed FE payload gets rejected at the mock.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dredd&lt;/strong&gt; pins the documented happy paths when the spec includes explicit &lt;code&gt;examples:&lt;/code&gt; blocks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep the generated suite in its own CI job named &lt;code&gt;contract&lt;/code&gt;, separate from &lt;code&gt;unit&lt;/code&gt; and &lt;code&gt;integration&lt;/code&gt;, so a failure is immediately legible as "the wire shape moved."&lt;/p&gt;

&lt;h2&gt;
  
  
  Contract tests need a harness, or they get deleted
&lt;/h2&gt;

&lt;p&gt;Contract tests are the fourth of five layers every backend test setup needs. If the layers underneath are missing, the contract job flakes — and a frustrated team deletes it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Tooling&lt;/th&gt;
&lt;th&gt;Effort&lt;/th&gt;
&lt;th&gt;Build order&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Fixtures + data factories&lt;/td&gt;
&lt;td&gt;pytest fixtures, factory_boy&lt;/td&gt;
&lt;td&gt;1–2 days&lt;/td&gt;
&lt;td&gt;First&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mock servers&lt;/td&gt;
&lt;td&gt;Prism, WireMock&lt;/td&gt;
&lt;td&gt;2–3 days&lt;/td&gt;
&lt;td&gt;Second&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contract test runner&lt;/td&gt;
&lt;td&gt;Pact, Schemathesis&lt;/td&gt;
&lt;td&gt;3–5 days&lt;/td&gt;
&lt;td&gt;Third&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Environment bootstrap&lt;/td&gt;
&lt;td&gt;Docker Compose, CI scripts&lt;/td&gt;
&lt;td&gt;1 sprint&lt;/td&gt;
&lt;td&gt;Fourth&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Build bottom-up: each layer depends on the one below, and each returns value before the next exists.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flaky fixtures are the real enemy
&lt;/h2&gt;

&lt;p&gt;Every contract-test flake I have ever debugged traced back to one of four things, and all four have boring fixes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Non-deterministic IDs.&lt;/strong&gt; Seed the test DB with known UUIDs. Never assert equality against a generated &lt;code&gt;id&lt;/code&gt; — assert it matches &lt;code&gt;^[0-9a-f-]{36}$&lt;/code&gt; via a schema matcher.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time.&lt;/strong&gt; Freeze the clock. Every &lt;code&gt;created_at&lt;/code&gt; assertion should be a type check, not a value check.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ordering.&lt;/strong&gt; Collections need a stable sort from the provider. If your endpoint returns items in whatever order the DB felt like today, contract tests will catch it — in the bad, intermittent way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;External calls.&lt;/strong&gt; Contract tests verify &lt;em&gt;your&lt;/em&gt; contract, not Stripe's. If a contract test reaches the internet, it is misdesigned.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The CI gate that actually changes behavior
&lt;/h2&gt;

&lt;p&gt;On every provider PR, the &lt;code&gt;contract&lt;/code&gt; job:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Boots the service against a test database with deterministic seeds&lt;/li&gt;
&lt;li&gt;Runs Schemathesis against the running server using the committed spec&lt;/li&gt;
&lt;li&gt;Pulls the latest pacts for this provider from the Pact Broker and verifies them&lt;/li&gt;
&lt;li&gt;Fails the build with a PR comment naming the consumer and the broken interaction&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A developer renaming &lt;code&gt;total_cents&lt;/code&gt; to &lt;code&gt;amount&lt;/code&gt; sees — inside their PR — that the mobile team's checkout flow depends on the old name. They fix it before merge. They do not find out next Tuesday from a Slack message.&lt;/p&gt;

&lt;h2&gt;
  
  
  The loop working in practice
&lt;/h2&gt;

&lt;p&gt;The web team wanted a &lt;code&gt;loyalty_tier&lt;/code&gt; field on the order confirmation page. They added it to their Pact test, published the pact, and pushed their PR (blocked behind a feature flag).&lt;/p&gt;

&lt;p&gt;Next day, a backend engineer opened an &lt;em&gt;unrelated&lt;/em&gt; PR on the provider. The contract job pulled the broker's pacts and failed: the web consumer expected &lt;code&gt;loyalty_tier&lt;/code&gt;, the provider didn't return it yet.&lt;/p&gt;

&lt;p&gt;The two teams found the dependency &lt;strong&gt;at PR time&lt;/strong&gt; — not in staging, not in production. That's the entire value proposition in one anecdote.&lt;/p&gt;




&lt;h2&gt;
  
  
  Start here
&lt;/h2&gt;

&lt;p&gt;If you have an OpenAPI file and zero contract tests, the first afternoon looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;pip install schemathesis&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;schemathesis run openapi.yaml --url http://localhost:8000&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Triage what fails (something will fail)&lt;/li&gt;
&lt;li&gt;Add it as a CI job once it's green&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That single job will catch the next silent enum rename before your consumers do.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I write about spec-first delivery, API contracts, and release engineering at &lt;a href="https://spec-coding.dev" rel="noopener noreferrer"&gt;spec-coding.dev&lt;/a&gt;. The full version of this guide — including schema-diff review before release and CI ownership — is at &lt;a href="https://spec-coding.dev/blog/contract-testing-plan-from-openapi-to-ci" rel="noopener noreferrer"&gt;spec-coding.dev/blog/contract-testing-plan-from-openapi-to-ci&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>api</category>
      <category>devops</category>
      <category>programming</category>
    </item>
    <item>
      <title>Your API's Next Consumer Is an LLM. It Will Find Every Ambiguity in Your Spec.</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Wed, 29 Jul 2026 03:56:38 +0000</pubDate>
      <link>https://dev.to/speccoding/your-apis-next-consumer-is-an-llm-it-will-find-every-ambiguity-in-your-spec-19k0</link>
      <guid>https://dev.to/speccoding/your-apis-next-consumer-is-an-llm-it-will-find-every-ambiguity-in-your-spec-19k0</guid>
      <description>&lt;p&gt;Most API specs were written for human developers — people who read docs carefully, infer intent from context, and pause when something feels dangerous.&lt;/p&gt;

&lt;p&gt;Agentic clients do none of that. If your spec assumes a thoughtful human reader, an LLM-driven agent will find the ambiguity and run straight at it. Four hundred times. In a loop. With zero hesitation.&lt;/p&gt;

&lt;p&gt;I learned this the hard way last quarter, when an agent integration hit our &lt;code&gt;DELETE /projects/{id}&lt;/code&gt; endpoint 400 times in a runaway loop. Here's what I changed in the spec — not the code, the &lt;em&gt;spec&lt;/em&gt; — to make the API survivable for machine callers.&lt;/p&gt;




&lt;h2&gt;
  
  
  The caller is no longer a person
&lt;/h2&gt;

&lt;p&gt;I spent a decade writing API docs for humans. A field called &lt;code&gt;id&lt;/code&gt; was fine, because any developer would trace one curl example and figure out the format.&lt;/p&gt;

&lt;p&gt;Put the same field in front of an agent and you get three different hallucinated shapes in the first ten calls: UUIDs, integers, email addresses the model inferred from the resource name. The caller is a statistical pattern matcher with no shame about guessing.&lt;/p&gt;

&lt;p&gt;So I now assume every parameter will be read by something that will confidently invent a value if the description is thin. That assumption reshapes what goes on the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Descriptions carry the whole contract
&lt;/h2&gt;

&lt;p&gt;The biggest single improvement I shipped: one full sentence of semantic description for &lt;strong&gt;every&lt;/strong&gt; field, parameter, and operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Useless:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;customer_id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Usable:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;customer_id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="s"&gt;Stripe customer ID, format cus_XXXX, case-sensitive,&lt;/span&gt;
  &lt;span class="s"&gt;14-18 chars after the prefix; obtain via /customers.list,&lt;/span&gt;
  &lt;span class="s"&gt;never fabricate.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "never fabricate" part is not theater. Agents read those instructions and comply more often than you'd expect — especially when the description names the upstream source of the value.&lt;/p&gt;

&lt;p&gt;Same principle for enums: don't list &lt;code&gt;["active", "pending", "cancelled"]&lt;/code&gt; and stop. Describe what each state means and which transitions are legal. The model routes to the right value if you say it out loud.&lt;/p&gt;

&lt;h2&gt;
  
  
  Idempotency is not optional anymore
&lt;/h2&gt;

&lt;p&gt;Human clients retry once, maybe twice, then escalate to a person. Agents retry aggressively — often on ambiguous responses they should have treated as success.&lt;/p&gt;

&lt;p&gt;I now require an &lt;code&gt;Idempotency-Key&lt;/code&gt; header on every non-GET endpoint and reject requests without one. The server stores the first response for 24 hours and replays it on duplicates.&lt;/p&gt;

&lt;p&gt;This is not an agent feature. It's self-defense. Without it, a single misread 502 becomes three duplicate charges and a refund ticket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dry-run by default on anything destructive
&lt;/h2&gt;

&lt;p&gt;Every destructive operation accepts &lt;code&gt;?dry_run=true&lt;/code&gt;. The response is identical in shape to the real call, but with &lt;code&gt;"dry_run": true&lt;/code&gt; and no side effect.&lt;/p&gt;

&lt;p&gt;One crucial detail: the spec has to say dry-run is &lt;strong&gt;free and safe&lt;/strong&gt;. If the agent thinks a dry run costs a billable request or counts against a rate limit, it will skip it under pressure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two-phase confirmation for irreversible actions
&lt;/h2&gt;

&lt;p&gt;This is the pattern that turned our 400-call runaway loop into a log entry instead of a data-loss incident:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first &lt;code&gt;DELETE&lt;/code&gt; returns HTTP 202 with a &lt;code&gt;confirmation_token&lt;/code&gt;, a &lt;code&gt;summary&lt;/code&gt; of exactly what will be destroyed, and &lt;code&gt;expires_in_seconds: 30&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The agent must resubmit with the token to actually execute.&lt;/li&gt;
&lt;li&gt;The token is single-use and scoped to the exact resource.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An agent in a tight loop burns its token on the first call of each pair and never reaches execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;an agent calling DELETE /projects/prj_123
&lt;span class="nf"&gt;When &lt;/span&gt;the first request arrives without a confirmation_token
&lt;span class="err"&gt;Then return 202 with { confirmation_token, summary, expires_in_seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;30&lt;/span&gt; &lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;And &lt;/span&gt;record no destructive side effect

&lt;span class="nf"&gt;Given &lt;/span&gt;a second request arrives with an expired or mismatched token
&lt;span class="nf"&gt;Then &lt;/span&gt;return 409 with a human-readable explanation
&lt;span class="nf"&gt;And &lt;/span&gt;require a fresh confirmation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Error responses that drive the retry decision
&lt;/h2&gt;

&lt;p&gt;I rewrote every 4xx/5xx body to a fixed shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"error_code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"payment.card_declined.insufficient_funds"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"permanent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"suggested_fix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Call /customers.search with the email to resolve the ID."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"docs_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;suggested_fix&lt;/code&gt; tells the agent what went wrong. But &lt;code&gt;category&lt;/code&gt; is the field that actually saves money — it's what a client branches on when it doesn't recognize the specific code. HTTP status is no help: a &lt;code&gt;400&lt;/code&gt; might be a malformed payload or a declined card; a &lt;code&gt;500&lt;/code&gt; might clear on retry or fail identically for the next forty-seven attempts.&lt;/p&gt;

&lt;p&gt;Eight closed categories cover everything:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;category&lt;/th&gt;
&lt;th&gt;What the agent should do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;auth_required&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Refresh credentials, retry once&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;forbidden&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Do not retry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;not_found&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Do not retry the same ID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;validation&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Do not retry without changing the payload&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rate_limit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retry after the hint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;conflict&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fetch fresh state, then retry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;transient&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retry with backoff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;permanent&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Surface to a human&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two rules make this hold up: &lt;code&gt;error_code&lt;/code&gt; strings are frozen once published (deprecate, never rename), and machine-actionable detail lives in a structured &lt;code&gt;details&lt;/code&gt; object — never in prose.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make capabilities discoverable
&lt;/h2&gt;

&lt;p&gt;Agents don't browse your documentation site. They load whatever the system prompt points them at.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I expose a &lt;code&gt;/_capabilities&lt;/code&gt; endpoint returning available operations, current rate limits for the calling identity, and cost per call. Agents that check it first make dramatically fewer wrong calls.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;operationId&lt;/code&gt; values are verb_noun (&lt;code&gt;list_projects&lt;/code&gt;, &lt;code&gt;archive_project&lt;/code&gt;) — that's the name the model actually sees in its tool list.&lt;/li&gt;
&lt;li&gt;Every response carries &lt;code&gt;X-RateLimit-Remaining&lt;/code&gt; and &lt;code&gt;X-RateLimit-Reset&lt;/code&gt; as documented contract, not incidental headers. When the agent can see it's at 4 remaining calls, it backs off. When it can't, it doesn't.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Watch three numbers per agent identity
&lt;/h2&gt;

&lt;p&gt;Every request carries a required &lt;code&gt;X-Agent-ID&lt;/code&gt; header, and I log per identity: dry-run ratio, confirmation-token burn rate, and retry count.&lt;/p&gt;

&lt;p&gt;A healthy agent integration runs 30–60% dry-run during exploration, drops under 10% in steady state, and almost never fails the second phase of confirmation. Anything outside that envelope gets a closer look before it becomes an incident.&lt;/p&gt;




&lt;h2&gt;
  
  
  The uncomfortable summary
&lt;/h2&gt;

&lt;p&gt;None of this is exotic engineering. Idempotency keys, dry runs, structured errors — we've known about them for years. What changed is that the forgiving, context-aware human reader who papered over our spec gaps is gone.&lt;/p&gt;

&lt;p&gt;The spec is now the entire interface. Write it like the reader will do exactly what it says — because this reader will.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I write about spec-first delivery, API contracts, and AI-assisted engineering at &lt;a href="https://spec-coding.dev" rel="noopener noreferrer"&gt;spec-coding.dev&lt;/a&gt;. The full version of this guide (with versioning and deprecation patterns for agentic clients) is at &lt;a href="https://spec-coding.dev/blog/designing-api-specs-for-agentic-clients" rel="noopener noreferrer"&gt;spec-coding.dev/blog/designing-api-specs-for-agentic-clients&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Your MCP Server's Client Is a Language Model. Write the Contract Like You Mean It</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Mon, 20 Jul 2026 02:33:08 +0000</pubDate>
      <link>https://dev.to/speccoding/your-mcp-servers-client-is-a-language-model-write-the-contract-like-you-mean-it-3fl8</link>
      <guid>https://dev.to/speccoding/your-mcp-servers-client-is-a-language-model-write-the-contract-like-you-mean-it-3fl8</guid>
      <description>&lt;p&gt;The Model Context Protocol quietly turned every internal script, database query, and admin action into an API.&lt;/p&gt;

&lt;p&gt;The client for that API is not a developer reading your docs. It's a language model reading your tool descriptions at runtime and deciding — on its own — what to call and with what arguments.&lt;/p&gt;

&lt;p&gt;When a human developer integrates your API, ambiguity gets absorbed by their judgment. They read the docs twice, test in staging, and email you when the 409 makes no sense. An agent does none of that. It reads the tool's name, description, and input schema, forms a belief about what the tool does, and acts on that belief immediately, in production, possibly hundreds of times an hour.&lt;/p&gt;

&lt;p&gt;Every ambiguity in a human-facing API costs you a support thread. Every ambiguity in an agent-facing tool costs you &lt;em&gt;whatever the agent decided it meant&lt;/em&gt;, multiplied by every session that reaches the same fork.&lt;/p&gt;

&lt;p&gt;The fix isn't better prompting on the client side — client prompts are the one thing you don't control. The fix is a contract on the server side.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changes when the consumer is an agent
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Contract element&lt;/th&gt;
&lt;th&gt;Human developer&lt;/th&gt;
&lt;th&gt;AI agent&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Documentation&lt;/td&gt;
&lt;td&gt;Read once during integration&lt;/td&gt;
&lt;td&gt;Re-read from the schema every session; the description &lt;em&gt;is&lt;/em&gt; the docs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validation errors&lt;/td&gt;
&lt;td&gt;Fixed during development&lt;/td&gt;
&lt;td&gt;Must name the failing field so the agent can self-correct&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retries&lt;/td&gt;
&lt;td&gt;Written deliberately, once&lt;/td&gt;
&lt;td&gt;Attempted whenever an error looks transient; idempotency is survival&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Destructive actions&lt;/td&gt;
&lt;td&gt;Guarded by developer caution&lt;/td&gt;
&lt;td&gt;Guarded only by what the contract flags&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Breaking changes&lt;/td&gt;
&lt;td&gt;Announced in a changelog&lt;/td&gt;
&lt;td&gt;Silently misfire until a human notices agent behavior degraded&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;None of this is exotic. It's the same rigor a good OpenAPI spec already demands — applied with the assumption that the reader has perfect patience, zero context outside the schema, and no ability to ask a clarifying question.&lt;/p&gt;

&lt;h2&gt;
  
  
  Input schemas: constrain, don't describe
&lt;/h2&gt;

&lt;p&gt;JSON Schema is the enforcement layer of the contract, and agents respect it more reliably than they respect prose. Every constraint you can express in the schema, express in the schema: enums instead of free-text strings, patterns for identifiers, explicit defaults, required fields kept to the true minimum.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"amount_cents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"integer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"minimum"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"maximum"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;500000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Refund amount in cents. Must not exceed the invoice's remaining refundable balance; the server rejects overdrafts with REFUND_EXCEEDS_BALANCE."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The anti-pattern is the string-typed field with a paragraph of prose explaining the accepted values. Agents will eventually send the one variant your parser didn't expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Output contracts: agents parse, they don't skim
&lt;/h2&gt;

&lt;p&gt;An MCP tool that returns a friendly paragraph of prose forces every consuming agent to parse English. That parse is a probabilistic operation that will go wrong somewhere.&lt;/p&gt;

&lt;p&gt;Commit to structured output: stable field names, a machine-readable status, identifiers the agent can feed into follow-up calls. Prose belongs in one designated &lt;code&gt;summary&lt;/code&gt; field, not in the load-bearing structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"refunded"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"refund_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rf_8104"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"amount_cents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"invoice_state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"closed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"summary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Refunded $42.00 against invoice inv_2231."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And treat output fields with public-API backward-compatibility discipline. Renaming &lt;code&gt;refund_id&lt;/code&gt; to &lt;code&gt;refundId&lt;/code&gt; is a breaking change even though no compiler will catch it — the agents consuming it just start failing at whatever step needed the identifier.&lt;/p&gt;

&lt;h2&gt;
  
  
  An error taxonomy agents can act on
&lt;/h2&gt;

&lt;p&gt;A human reads "Something went wrong, please try again later" and applies judgment. An agent needs the judgment encoded: every error should map to exactly one recovery action.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th&gt;Example code&lt;/th&gt;
&lt;th&gt;Agent action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Transient&lt;/td&gt;
&lt;td&gt;&lt;code&gt;UPSTREAM_TIMEOUT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retry with backoff, same idempotency key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Invalid input&lt;/td&gt;
&lt;td&gt;&lt;code&gt;INVALID_FIELD: amount_cents&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fix the named field, retry once&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;State conflict&lt;/td&gt;
&lt;td&gt;&lt;code&gt;REFUND_EXCEEDS_BALANCE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Re-read state, re-plan, don't blind-retry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Permission&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ROLE_FORBIDDEN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stop and surface to the user&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Not found&lt;/td&gt;
&lt;td&gt;&lt;code&gt;INVOICE_NOT_FOUND&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Verify the identifier with a read tool first&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two rules keep the taxonomy honest:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Codes are append-only.&lt;/strong&gt; Agents and their prompts calcify around them; renames are breaking changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every validation error names the failing field&lt;/strong&gt; in structured detail. A bare "invalid request" sends an agent into a guess-and-retry loop that looks, in your logs, exactly like an attack.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Side effects: flag them or agents will find them
&lt;/h2&gt;

&lt;p&gt;Classify every tool three ways: read-only or mutating, idempotent or not, reversible or destructive. MCP has native annotations for exactly this — &lt;code&gt;readOnlyHint&lt;/code&gt;, &lt;code&gt;destructiveHint&lt;/code&gt;, &lt;code&gt;idempotentHint&lt;/code&gt; — and your spec should decide their values deliberately rather than defaulting them. Client applications use these hints to decide when to ask a human for confirmation; a mislabeled tool inherits whatever trust the label promised.&lt;/p&gt;

&lt;p&gt;Any mutating tool an agent may retry needs an &lt;code&gt;idempotency_key&lt;/code&gt; input that makes duplicate calls return the original result.&lt;/p&gt;

&lt;p&gt;For genuinely destructive operations — deletion, irreversible sends, money movement — the strongest contract clause is a two-step shape: a &lt;code&gt;dry_run&lt;/code&gt; mode that returns what &lt;em&gt;would&lt;/em&gt; happen plus a confirmation token, and an execute mode that requires that token. That turns "the agent deleted the wrong thing" from an incident into a rejected call.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it together: a refund tool contract
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tool: refund_invoice
purpose: refund a failed or disputed invoice, once
inputs: invoice_id (pattern inv_*), amount_cents (1..500000),
        idempotency_key (uuid, required), dry_run (bool, default true)
output: status, refund_id, amount_cents, invoice_state, summary
errors: INVALID_FIELD, INVOICE_NOT_FOUND, REFUND_EXCEEDS_BALANCE,
        ROLE_FORBIDDEN, UPSTREAM_TIMEOUT
side effects: mutating, idempotent via key, destructive
              (readOnlyHint=false, destructiveHint=true,
               idempotentHint=true)
policy: dry_run=true returns preview + confirm_token;
        execution requires a confirm_token issued within 10 minutes
version: v2 (v1 accepted amount as dollars; removed 2026-06)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every line answers a question an agent would otherwise answer by guessing. The version line is not decoration: the dollars-to-cents change is exactly the kind of silent semantic shift agent clients cannot detect and cannot survive.&lt;/p&gt;

&lt;p&gt;The uncomfortable truth about agent-facing APIs: your real interface is not the code. It's the beliefs your contract induces in a language model. Write the contract first, and those beliefs are at least ones you chose.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The full version — with the versioning/review-gate process and a deeper error-taxonomy method — is on &lt;a href="https://spec-coding.dev/blog/mcp-server-api-spec-contract" rel="noopener noreferrer"&gt;spec-coding.dev&lt;/a&gt;. There's also a free browser-based &lt;a href="https://spec-coding.dev/tools/api-spec-generator" rel="noopener noreferrer"&gt;API spec generator&lt;/a&gt; that produces this contract structure from a plain-language description.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>programming</category>
      <category>llm</category>
    </item>
    <item>
      <title>Your AI Agents Ship Code Faster Than You Can Review It. Here's the Workflow That Fixes That</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Mon, 20 Jul 2026 02:33:06 +0000</pubDate>
      <link>https://dev.to/speccoding/your-ai-agents-ship-code-faster-than-you-can-review-it-heres-the-workflow-that-fixes-that-4ied</link>
      <guid>https://dev.to/speccoding/your-ai-agents-ship-code-faster-than-you-can-review-it-heres-the-workflow-that-fixes-that-4ied</guid>
      <description>&lt;p&gt;Most teams didn't decide to become AI agent teams. One developer adopted a coding agent, another wired one into CI, and within a quarter half the pull requests were machine-written.&lt;/p&gt;

&lt;p&gt;Then the pain starts, and it's a specific kind of pain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PRs pile up faster than anyone can read them&lt;/li&gt;
&lt;li&gt;Two agents solve overlapping problems in incompatible ways&lt;/li&gt;
&lt;li&gt;A prompt that lived in one developer's chat session produced a product decision nobody approved&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The failure isn't the agents. It's that the team's intent exists nowhere an agent — or a reviewer — can check. Chat transcripts aren't reviewable, aren't reusable, and can't be compared against the final diff.&lt;/p&gt;

&lt;p&gt;Before agents, the slowest step in delivery was implementation, so every process optimized for developer throughput. With agents, implementation is nearly free, and two other steps become the constraint: &lt;strong&gt;deciding exactly what to build&lt;/strong&gt;, and &lt;strong&gt;confirming the result matches that decision&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here's the five-stage workflow that moves human effort to those two places. It's tool-agnostic — Claude Code, Cursor, Copilot agents, or a mix — because the contract lives in files, not in any tool's memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow at a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;Owner&lt;/th&gt;
&lt;th&gt;Artifact&lt;/th&gt;
&lt;th&gt;Gate to pass&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Intake&lt;/td&gt;
&lt;td&gt;Feature owner&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;spec.md&lt;/code&gt; packet&lt;/td&gt;
&lt;td&gt;Goal, non-goals, acceptance criteria approved by a human&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Task split&lt;/td&gt;
&lt;td&gt;Tech lead&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tasks.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Every task has a write scope and a verifiable outcome&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Implementation&lt;/td&gt;
&lt;td&gt;One agent per task&lt;/td&gt;
&lt;td&gt;Branch diff&lt;/td&gt;
&lt;td&gt;Diff stays inside the task's write scope&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Evidence&lt;/td&gt;
&lt;td&gt;Same agent&lt;/td&gt;
&lt;td&gt;&lt;code&gt;evidence.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Named tests exist and pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Review&lt;/td&gt;
&lt;td&gt;Human reviewer&lt;/td&gt;
&lt;td&gt;PR with linked artifacts&lt;/td&gt;
&lt;td&gt;Checklist review against criteria, not vibes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Stage 1: Turn the ticket into a spec packet
&lt;/h2&gt;

&lt;p&gt;Everything downstream inherits the quality of this step — and it's the step teams most want to skip.&lt;/p&gt;

&lt;p&gt;Input: a ticket like &lt;em&gt;"let support admins retry failed exports."&lt;/em&gt;&lt;br&gt;
Output: a one-page packet that fixes four things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;strong&gt;goal&lt;/strong&gt;, in observable terms&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;non-goals&lt;/strong&gt; that bound the change&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Acceptance criteria&lt;/strong&gt; a test can check&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;evidence&lt;/strong&gt; a reviewer will demand&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The discipline that matters most is non-goals. A line like &lt;em&gt;"no schema changes, no email template edits, no new dependencies"&lt;/em&gt; removes the three most common ways agents helpfully expand scope.&lt;/p&gt;

&lt;p&gt;Write the packet before choosing which agent implements it. This is where product ambiguity gets resolved by a person instead of leaking into an agent's assumptions.&lt;/p&gt;
&lt;h2&gt;
  
  
  Stage 2: Split the spec into bounded tasks
&lt;/h2&gt;

&lt;p&gt;A spec packet is still too big to hand to one agent as one prompt. The reliable unit of agent work is a task that a single agent can complete — and a single human can review — in one sitting.&lt;/p&gt;

&lt;p&gt;Each task needs three fields beyond its description:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Task 2 of 3: add retry endpoint
Write scope:
- src/exports/retry.ts
- src/exports/retry.test.ts

Depends on: task 1 (retry state column) merged.

Acceptance:
- POST /api/exports/:id/retry on a failed export returns 202
  and the same retry_id on duplicate calls
- retrying a non-failed export returns 409

Evidence:
- test: export_retry_idempotent
- test: export_retry_wrong_state_conflict
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One rule saves you from most multi-agent chaos: &lt;strong&gt;tasks that share files must not run in parallel.&lt;/strong&gt; If two tasks both touch &lt;code&gt;billing/index.ts&lt;/code&gt;, merge them or serialize them explicitly. Merge conflicts between agents are not a tooling problem; they're a task-splitting problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 3: Run agents in parallel inside write scopes
&lt;/h2&gt;

&lt;p&gt;With bounded tasks, parallelism becomes safe and boring — which is the goal. Give each agent one task, its packet, and an isolated branch or git worktree.&lt;/p&gt;

&lt;p&gt;The write scope is the enforcement line: an agent that edits a file outside its scope has its diff rejected before review, no discussion needed. Most modern agents respect an instruction like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Modify only the files listed under write scope. If the task requires touching anything else, stop and report instead of editing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That stop-and-report clause matters more than it looks. The most expensive agent failure is not a wrong implementation; it's a &lt;em&gt;quiet decision&lt;/em&gt; — an extra column, a renamed function, a new dependency — buried in an otherwise plausible diff. Scope enforcement converts quiet decisions into loud questions a human answers in seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 4: Collect evidence before requesting review
&lt;/h2&gt;

&lt;p&gt;An agent's claim that work is complete is worth nothing. Before a task's PR opens, the same agent fills in &lt;code&gt;evidence.md&lt;/code&gt;: which named tests were added, their pass output, and which acceptance criterion each test covers.&lt;/p&gt;

&lt;p&gt;Evidence is where hallucinated completeness dies. An agent that says "all tests pass" but can't paste the run output for &lt;code&gt;export_retry_idempotent&lt;/code&gt; has not finished. The gate is mechanical: the named test either exists and passes, or it doesn't.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 5: Review the PR against the checklist
&lt;/h2&gt;

&lt;p&gt;Human review is the scarcest resource in the whole system, so spend it only on what earlier gates can't check: &lt;strong&gt;does the diff match the intent, and did anything unstated slip in?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The reviewer confirms the diff stays in scope, maps each change to a task, spot-checks the evidence, and asks the one question no automation can: &lt;em&gt;what did nobody ask for?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A real run: one feature, three agents
&lt;/h2&gt;

&lt;p&gt;Feature: "support admins can retry a failed data export."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spec: exports/retry-failed-export/spec.md
tasks:
  1. retry state column + migration    agent A  (db/migrations, models)
  2. retry endpoint + idempotency      agent B  (src/exports/retry.ts + test)
  3. admin console retry button        agent C  (console/exports/*.tsx + test)
serialization: task 1 merges first; tasks 2 and 3 run in parallel
review: one human, three PRs, ~40 minutes total
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The instructive failure: agent B added a helpful &lt;code&gt;retry_count&lt;/code&gt; column — outside its write scope. The scope check flagged it before review. The team decided the count was genuinely useful, wrote it into the packet as a follow-up task, and rejected the out-of-scope edit.&lt;/p&gt;

&lt;p&gt;That's the workflow doing its job: &lt;strong&gt;the good idea survived, the unreviewed decision did not.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What to measure in the first 30 days
&lt;/h2&gt;

&lt;p&gt;Adopt this on one feature stream, not the whole team, and track three numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Review time per agent PR&lt;/strong&gt; — should fall week over week as artifacts standardize&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Out-of-scope edits caught before review&lt;/strong&gt; — should be non-zero early (the gate works), declining later (the prompts learn)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rework rate&lt;/strong&gt; (PRs needing a second implementation pass) — this is the number that convinces skeptics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The steady state is unglamorous: specs are short, tasks are boring, agents are interchangeable, and review is fast. That's what it looks like when humans spend their time on intent and evidence, and machines spend theirs on everything in between.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The full version of this article — with the failure-mode table and links to copy-ready templates for spec packets, task plans, and evidence logs — is on &lt;a href="https://spec-coding.dev/blog/ai-agent-team-spec-workflow" rel="noopener noreferrer"&gt;spec-coding.dev&lt;/a&gt;. The &lt;a href="https://spec-coding.dev/tools/ai-coding-spec-packet" rel="noopener noreferrer"&gt;spec packet generator&lt;/a&gt; is free and runs entirely in your browser.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
      <category>agile</category>
    </item>
    <item>
      <title>Vibe Coding vs Spec Coding: Same Refund Feature, Built Twice</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Tue, 16 Jun 2026 01:57:41 +0000</pubDate>
      <link>https://dev.to/speccoding/vibe-coding-vs-spec-coding-same-refund-feature-built-twice-62o</link>
      <guid>https://dev.to/speccoding/vibe-coding-vs-spec-coding-same-refund-feature-built-twice-62o</guid>
      <description>&lt;p&gt;Vibe coding is intoxicating. You describe what you want in plain language, the AI writes the code, and ten minutes later you have a working endpoint.&lt;/p&gt;

&lt;p&gt;I was sold — until I shipped a refund feature that way and spent the next two weeks patching bugs that a 90-minute spec would have prevented entirely.&lt;/p&gt;

&lt;p&gt;This is the side-by-side, using the exact same requirement, so you can see where the gap opens up.&lt;/p&gt;

&lt;h2&gt;
  
  
  The requirement
&lt;/h2&gt;

&lt;p&gt;An e-commerce platform needs an order refund feature. The PM's brief:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Support full and partial refunds&lt;/li&gt;
&lt;li&gt;Call the payment gateway (Stripe-style) to reverse the charge&lt;/li&gt;
&lt;li&gt;Track refund status: pending, processing, succeeded, failed&lt;/li&gt;
&lt;li&gt;Support agents trigger refunds through an internal tool&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simple enough. Both paths start here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Path A: vibe coding
&lt;/h2&gt;

&lt;p&gt;The prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Build me an order refund API in Node.js. Support full and partial refunds. Call a payment gateway to reverse the charge. Track refund status. Use Express and Postgres."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sixty seconds later: a clean &lt;code&gt;RefundController&lt;/code&gt; with &lt;code&gt;createRefund&lt;/code&gt; and &lt;code&gt;getRefundStatus&lt;/code&gt;. It validates the order exists, checks the amount against the order total, calls &lt;code&gt;paymentGateway.refund()&lt;/code&gt;, saves the result. The code looks professional. The happy path works.&lt;/p&gt;

&lt;p&gt;Ship it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug #1: the double refund
&lt;/h3&gt;

&lt;p&gt;A support agent clicks refund, the page hangs for a second, they click again. &lt;strong&gt;Two refunds go through.&lt;/strong&gt; No idempotency check.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fix prompt: "Add a check to prevent duplicate refunds for the same order."&lt;/em&gt; The AI adds a query: if a refund exists for this order, reject. Works — until it doesn't.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug #2: partial refund overflow
&lt;/h3&gt;

&lt;p&gt;A $200 order. Support issues $50, then $80, then $100. &lt;strong&gt;Total refunded: $230.&lt;/strong&gt; The duplicate check only catches &lt;em&gt;exact&lt;/em&gt; duplicates, not cumulative amounts.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fix prompt: "Track cumulative refund amounts and reject refunds that would exceed the order total."&lt;/em&gt; The AI adds a &lt;code&gt;SUM(amount)&lt;/code&gt; query — but it's not in a transaction with the insert, so two concurrent partials can both pass the check.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug #3: gateway timeout
&lt;/h3&gt;

&lt;p&gt;The gateway times out. The refund row sits at &lt;code&gt;processing&lt;/code&gt; forever. Support can't retry — the duplicate check blocks them. &lt;strong&gt;Did the money actually leave? Nobody knows.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fix prompt: "Add retry logic for gateway timeouts."&lt;/em&gt; The AI adds a retry loop: no exponential backoff, no idempotency key on the gateway call, no cap. The retry can now create a duplicate charge &lt;em&gt;on the gateway side&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug #4: the race condition
&lt;/h3&gt;

&lt;p&gt;Two agents process refunds for the same order simultaneously. Both pass the cumulative check (neither refund is committed yet), both hit the gateway, both succeed. &lt;strong&gt;The customer is refunded twice.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fix prompt: "Add locking…"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Four patches in, each reasonable in isolation, and the architecture is a patchwork: no state machine, no documented invariants, no tests for how the patches interact.&lt;/p&gt;

&lt;h3&gt;
  
  
  The real cost
&lt;/h3&gt;

&lt;p&gt;The first version took 10 minutes. The four patches took &lt;strong&gt;two weeks&lt;/strong&gt; — investigation, testing, support escalations, and one manual reconciliation against gateway records.&lt;/p&gt;

&lt;p&gt;The "fast" approach wasn't fast. It front-loaded the dopamine and back-loaded the pain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Path B: spec coding
&lt;/h2&gt;

&lt;p&gt;Same requirement. Same AI. Different starting point — 90 minutes writing this before any code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Feature: Order Refund Processing&lt;/span&gt;

&lt;span class="gu"&gt;## Goal&lt;/span&gt;
Process refunds safely: no over-refund, no duplicate
processing, correct gateway reconciliation.

&lt;span class="gu"&gt;## Non-Goals&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Customer self-service refund portal (future phase)
&lt;span class="p"&gt;-&lt;/span&gt; Refund reason analytics
&lt;span class="p"&gt;-&lt;/span&gt; Automated approval rules

&lt;span class="gu"&gt;## State Machine&lt;/span&gt;
pending → processing → succeeded
pending → processing → failed → pending (retry)

Only ONE refund may be "processing" per order at any time.

&lt;span class="gu"&gt;## Acceptance Criteria&lt;/span&gt;

Given an order with total $200 and $0 previously refunded
When a support agent requests a $50 refund
Then a refund record is created with status "pending"
  And the gateway is called with an idempotency key
  And on gateway success, status moves to "succeeded"
  And the refundable balance is now $150.

Given an order with total $200 and $150 already refunded
When a support agent requests a $75 refund
Then the request is rejected with "exceeds refundable balance"
  And no gateway call is made.

Given a refund in "processing" state
When another refund request arrives for the same order
Then the request is rejected with "refund already in progress"
  And no gateway call is made.

Given a refund in "processing" state
When the gateway times out
Then the status remains "processing"
  And a background job retries with exponential backoff
  And the retry uses the SAME idempotency key
  And after 3 failures, status moves to "failed"
  And an alert goes to the payments team.

&lt;span class="gu"&gt;## Edge Cases&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Concurrency: SELECT FOR UPDATE on the order row before
  checking refundable balance
&lt;span class="p"&gt;-&lt;/span&gt; Idempotency: each refund attempt gets a UUID, passed to
  the gateway as the idempotency key
&lt;span class="p"&gt;-&lt;/span&gt; Precision: all amounts in cents (integer), no floats
&lt;span class="p"&gt;-&lt;/span&gt; Reconciliation: nightly job compares local records
  against the gateway settlement report

&lt;span class="gu"&gt;## Rollback Plan&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Feature flag: refund_processing_v2
&lt;span class="p"&gt;-&lt;/span&gt; Rollback disables new refunds; in-flight ones continue
  via the background job
&lt;span class="p"&gt;-&lt;/span&gt; Additive schema only — no migration rollback needed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Implement the refund feature described in this spec. Follow the state machine exactly. Use SELECT FOR UPDATE for concurrency control. Include the idempotency key in all gateway calls. All amounts in cents." &lt;em&gt;[paste spec]&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The output is structurally different
&lt;/h2&gt;

&lt;p&gt;The AI generates, in the &lt;strong&gt;first version&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;processRefund&lt;/code&gt; wrapped in a transaction with &lt;code&gt;SELECT FOR UPDATE&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Cumulative balance check &lt;em&gt;inside&lt;/em&gt; the transaction — no race window&lt;/li&gt;
&lt;li&gt;Idempotency UUID minted at creation, passed to every gateway call&lt;/li&gt;
&lt;li&gt;Background retry with exponential backoff, capped at 3 attempts&lt;/li&gt;
&lt;li&gt;State transitions that match the spec's machine exactly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every bug from Path A is pre-handled. Double refund? The lock plus the idempotency key. Overflow? Balance check in the same transaction as the insert. Timeout? Same-key retry that the gateway treats as safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Same AI. Same capability. Dramatically different output — because the input was dramatically different. The AI didn't get smarter; it got better constraints.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest math
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Vibe coding&lt;/th&gt;
&lt;th&gt;Spec coding&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Time to first version&lt;/td&gt;
&lt;td&gt;10 min&lt;/td&gt;
&lt;td&gt;~2.5 hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Production bugs&lt;/td&gt;
&lt;td&gt;4 (one involving real money)&lt;/td&gt;
&lt;td&gt;0 in this scenario&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total time to stable&lt;/td&gt;
&lt;td&gt;~2 weeks&lt;/td&gt;
&lt;td&gt;~half a day&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Vibe coding is great for prototypes, internal tools, and anything where a bug costs you a shrug. The moment money, state machines, or concurrency enter the picture, the 90 minutes you "save" by skipping the spec gets repaid at loan-shark interest.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Adapted from the full case study on &lt;a href="https://spec-coding.dev/blog/same-refund-feature-vibe-coding-vs-spec-coding" rel="noopener noreferrer"&gt;Spec Coding&lt;/a&gt;. The site maintains free spec templates and a browser-based &lt;a href="https://spec-coding.dev/tools/ai-coding-spec-packet" rel="noopener noreferrer"&gt;spec packet generator&lt;/a&gt; for exactly this workflow.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Acceptance Criteria Your QA Can Run Without Asking You Anything (6 Copyable Examples)</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Tue, 16 Jun 2026 01:57:13 +0000</pubDate>
      <link>https://dev.to/speccoding/acceptance-criteria-your-qa-can-run-without-asking-you-anything-6-copyable-examples-3mif</link>
      <guid>https://dev.to/speccoding/acceptance-criteria-your-qa-can-run-without-asking-you-anything-6-copyable-examples-3mif</guid>
      <description>&lt;p&gt;The acceptance criterion I reach for most is not the happy path. It's the &lt;strong&gt;duplicate action&lt;/strong&gt;: double-clicked submit buttons, repeated webhook deliveries, retried payment calls, imported rows seen twice.&lt;/p&gt;

&lt;p&gt;That one scenario exposes more vague thinking than a dozen success cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;a user submits the same request twice within 2 seconds
&lt;span class="nf"&gt;When &lt;/span&gt;both requests reach the server
&lt;span class="nf"&gt;Then &lt;/span&gt;exactly one state change is recorded
  &lt;span class="nf"&gt;And &lt;/span&gt;the second response returns the first operation id
  &lt;span class="nf"&gt;And &lt;/span&gt;the audit log marks it as a replay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your team can't answer what happens in that scenario, the spec isn't done. Here's the format that forces the answer, plus six examples you can copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The anatomy of a criterion that works
&lt;/h2&gt;

&lt;p&gt;Every Given/When/Then has three parts with specific jobs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Given&lt;/strong&gt; — the precondition. &lt;em&gt;What must be true before the action occurs?&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When&lt;/strong&gt; — the trigger. &lt;em&gt;What specific event causes the behavior?&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Then&lt;/strong&gt; — the observable outcome. &lt;em&gt;How does someone testing this know it worked?&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The quality bar: &lt;strong&gt;QA can turn it into a test without asking the author what they meant.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"The system responds quickly" fails the bar — quickly could be 200ms or 5 seconds depending on who's reading. "The API responds within 500ms at p95" passes.&lt;/p&gt;

&lt;p&gt;Bad:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The login should work correctly and handle errors gracefully."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Good:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;a registered user is on the login page
&lt;span class="nf"&gt;When &lt;/span&gt;the user enters a valid email and correct password and clicks &lt;span class="s"&gt;"Sign in"&lt;/span&gt;
&lt;span class="nf"&gt;Then &lt;/span&gt;the user is redirected to the dashboard within 2 seconds;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;session&lt;/span&gt; &lt;span class="err"&gt;cookie&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;set&lt;/span&gt; &lt;span class="err"&gt;with&lt;/span&gt; &lt;span class="err"&gt;HttpOnly&lt;/span&gt; &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;Secure&lt;/span&gt; &lt;span class="err"&gt;flags;&lt;/span&gt;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;last_login_at&lt;/span&gt; &lt;span class="err"&gt;timestamp&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;updated&lt;/span&gt; &lt;span class="err"&gt;in&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;users&lt;/span&gt; &lt;span class="err"&gt;table.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three observable outcomes. Zero interpretation needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 1: Account lockout
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;a registered user with email &lt;span class="s"&gt;"jane@example.com"&lt;/span&gt;
  &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;account&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;not&lt;/span&gt; &lt;span class="err"&gt;currently&lt;/span&gt; &lt;span class="err"&gt;locked&lt;/span&gt;
&lt;span class="nf"&gt;When &lt;/span&gt;the user submits an incorrect password 3 times consecutively
  &lt;span class="err"&gt;within&lt;/span&gt; &lt;span class="nf"&gt;a &lt;/span&gt;10-minute window
&lt;span class="nf"&gt;Then &lt;/span&gt;the account is locked for 15 minutes;
  &lt;span class="err"&gt;subsequent&lt;/span&gt; &lt;span class="err"&gt;login&lt;/span&gt; &lt;span class="err"&gt;attempts&lt;/span&gt; &lt;span class="err"&gt;return&lt;/span&gt; &lt;span class="err"&gt;HTTP&lt;/span&gt; &lt;span class="err"&gt;429&lt;/span&gt; &lt;span class="err"&gt;with&lt;/span&gt; &lt;span class="err"&gt;body&lt;/span&gt;
  &lt;span class="err"&gt;{"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;"account_locked", "retry_after_seconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;900};&lt;/span&gt;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;form&lt;/span&gt; &lt;span class="err"&gt;displays&lt;/span&gt; &lt;span class="err"&gt;"Account&lt;/span&gt; &lt;span class="err"&gt;locked.&lt;/span&gt; &lt;span class="err"&gt;Try&lt;/span&gt; &lt;span class="err"&gt;again&lt;/span&gt; &lt;span class="err"&gt;in&lt;/span&gt; &lt;span class="err"&gt;15&lt;/span&gt; &lt;span class="err"&gt;minutes.";&lt;/span&gt;
  &lt;span class="nf"&gt;a &lt;/span&gt;login_lockout event is written to the audit_log table;
  &lt;span class="err"&gt;after&lt;/span&gt; &lt;span class="err"&gt;15&lt;/span&gt; &lt;span class="err"&gt;minutes&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;account&lt;/span&gt; &lt;span class="err"&gt;unlocks&lt;/span&gt; &lt;span class="err"&gt;automatically.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice what's pinned down: the window (10 min), the count (3), the duration (15 min), the status code, the error body, the UI copy, &lt;em&gt;and&lt;/em&gt; the audit trail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 2: Session expiry
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;a user is logged in
  &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;session&lt;/span&gt; &lt;span class="err"&gt;timeout&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;configured&lt;/span&gt; &lt;span class="err"&gt;to&lt;/span&gt; &lt;span class="err"&gt;30&lt;/span&gt; &lt;span class="err"&gt;minutes&lt;/span&gt; &lt;span class="err"&gt;of&lt;/span&gt; &lt;span class="err"&gt;inactivity&lt;/span&gt;
&lt;span class="nf"&gt;When &lt;/span&gt;the user performs no actions for 30 consecutive minutes
&lt;span class="nf"&gt;Then &lt;/span&gt;the next request returns HTTP 401;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;session&lt;/span&gt; &lt;span class="err"&gt;cookie&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;cleared&lt;/span&gt; &lt;span class="err"&gt;server-side;&lt;/span&gt;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;user&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;redirected&lt;/span&gt; &lt;span class="err"&gt;to&lt;/span&gt; &lt;span class="err"&gt;/login?reason=session_expired;&lt;/span&gt;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;page&lt;/span&gt; &lt;span class="err"&gt;displays&lt;/span&gt; &lt;span class="err"&gt;"Your&lt;/span&gt; &lt;span class="err"&gt;session&lt;/span&gt; &lt;span class="err"&gt;expired&lt;/span&gt; &lt;span class="err"&gt;due&lt;/span&gt; &lt;span class="err"&gt;to&lt;/span&gt; &lt;span class="err"&gt;inactivity.";&lt;/span&gt;
  &lt;span class="err"&gt;unsaved&lt;/span&gt; &lt;span class="err"&gt;client&lt;/span&gt; &lt;span class="err"&gt;form&lt;/span&gt; &lt;span class="err"&gt;dat&lt;/span&gt;&lt;span class="nf"&gt;a &lt;/span&gt;is NOT recoverable
  &lt;span class="err"&gt;(known&lt;/span&gt; &lt;span class="err"&gt;limitation,&lt;/span&gt; &lt;span class="err"&gt;documented&lt;/span&gt; &lt;span class="err"&gt;in&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;UI).&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last line is the underrated move: &lt;strong&gt;writing down what the system deliberately does NOT do.&lt;/strong&gt; It converts a future bug report into a documented decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 3: Checkout with insufficient stock
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;a customer has 3 units of SKU-2087 in their cart
  &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;available_quantity&lt;/span&gt; &lt;span class="err"&gt;for&lt;/span&gt; &lt;span class="err"&gt;SKU-208&lt;/span&gt;&lt;span class="nf"&gt;7 &lt;/span&gt;is now 1
&lt;span class="nf"&gt;When &lt;/span&gt;the customer clicks &lt;span class="s"&gt;"Place Order"&lt;/span&gt;
&lt;span class="nf"&gt;Then &lt;/span&gt;the order is NOT placed;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;page&lt;/span&gt; &lt;span class="err"&gt;shows&lt;/span&gt; &lt;span class="err"&gt;"Some&lt;/span&gt; &lt;span class="err"&gt;items&lt;/span&gt; &lt;span class="err"&gt;are&lt;/span&gt; &lt;span class="err"&gt;no&lt;/span&gt; &lt;span class="err"&gt;longer&lt;/span&gt; &lt;span class="err"&gt;available&lt;/span&gt;
  &lt;span class="err"&gt;in&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;requested&lt;/span&gt; &lt;span class="err"&gt;quantity.";&lt;/span&gt;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt; &lt;span class="err"&gt;item&lt;/span&gt; &lt;span class="err"&gt;shows&lt;/span&gt; &lt;span class="err"&gt;"Only&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;available&lt;/span&gt; &lt;span class="err"&gt;—&lt;/span&gt; &lt;span class="err"&gt;please&lt;/span&gt; &lt;span class="err"&gt;update&lt;/span&gt; &lt;span class="err"&gt;quantity.";&lt;/span&gt;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;customer&lt;/span&gt; &lt;span class="err"&gt;c&lt;/span&gt;&lt;span class="nf"&gt;an &lt;/span&gt;update to 1 and retry;
  &lt;span class="err"&gt;if&lt;/span&gt; &lt;span class="err"&gt;available_quantity&lt;/span&gt; &lt;span class="err"&gt;drops&lt;/span&gt; &lt;span class="err"&gt;to&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt; &lt;span class="err"&gt;between&lt;/span&gt; &lt;span class="err"&gt;page&lt;/span&gt; &lt;span class="err"&gt;load&lt;/span&gt; &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;submit,&lt;/span&gt;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;message&lt;/span&gt; &lt;span class="err"&gt;reads&lt;/span&gt; &lt;span class="err"&gt;"SKU-208&lt;/span&gt;&lt;span class="nf"&gt;7 &lt;/span&gt;is out of stock"
  &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt; &lt;span class="err"&gt;item&lt;/span&gt; &lt;span class="err"&gt;shows&lt;/span&gt; &lt;span class="nf"&gt;a &lt;/span&gt;&lt;span class="s"&gt;"Remove"&lt;/span&gt; button only;
  &lt;span class="err"&gt;no&lt;/span&gt; &lt;span class="err"&gt;payment&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;captured&lt;/span&gt; &lt;span class="err"&gt;in&lt;/span&gt; &lt;span class="err"&gt;AN&lt;/span&gt;&lt;span class="nf"&gt;Y &lt;/span&gt;insufficient-stock scenario.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two-tier degradation (low stock vs zero stock) and the final invariant are what make this executable instead of decorative.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 4: Rate limiting
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;the rate limit for the &lt;span class="s"&gt;"standard"&lt;/span&gt; plan is 100 requests/minute
  &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;key&lt;/span&gt; &lt;span class="err"&gt;"key_abc123"&lt;/span&gt; &lt;span class="err"&gt;has&lt;/span&gt; &lt;span class="err"&gt;made&lt;/span&gt; &lt;span class="err"&gt;100&lt;/span&gt; &lt;span class="err"&gt;requests&lt;/span&gt; &lt;span class="err"&gt;in&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;current&lt;/span&gt; &lt;span class="err"&gt;window&lt;/span&gt;
&lt;span class="nf"&gt;When &lt;/span&gt;the consumer sends request &lt;span class="c"&gt;#101 in the same window&lt;/span&gt;
&lt;span class="nf"&gt;Then &lt;/span&gt;the response is 429 with body
  &lt;span class="err"&gt;{"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;"rate_limit_exceeded", "retry_after_seconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;remaining&amp;gt;};&lt;/span&gt;
  &lt;span class="err"&gt;headers&lt;/span&gt; &lt;span class="err"&gt;include&lt;/span&gt; &lt;span class="err"&gt;X-RateLimit-Limit,&lt;/span&gt; &lt;span class="err"&gt;X-RateLimit-Remaining,&lt;/span&gt;
  &lt;span class="err"&gt;X-RateLimit-Reset,&lt;/span&gt; &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;Retry-After;&lt;/span&gt;
  &lt;span class="err"&gt;successful&lt;/span&gt; &lt;span class="err"&gt;responses&lt;/span&gt; &lt;span class="err"&gt;ALSO&lt;/span&gt; &lt;span class="err"&gt;carry&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;X-RateLimit-&lt;/span&gt;&lt;span class="nf"&gt;* &lt;/span&gt;headers;
  &lt;span class="err"&gt;limits&lt;/span&gt; &lt;span class="err"&gt;are&lt;/span&gt; &lt;span class="err"&gt;scoped&lt;/span&gt; &lt;span class="err"&gt;per&lt;/span&gt; &lt;span class="err"&gt;AP&lt;/span&gt;&lt;span class="nf"&gt;I &lt;/span&gt;key, not per IP;
  &lt;span class="err"&gt;429&lt;/span&gt; &lt;span class="err"&gt;responses&lt;/span&gt; &lt;span class="err"&gt;are&lt;/span&gt; &lt;span class="err"&gt;NOT&lt;/span&gt; &lt;span class="err"&gt;counted&lt;/span&gt; &lt;span class="err"&gt;against&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;next&lt;/span&gt; &lt;span class="err"&gt;window.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last two lines settle the arguments your team would otherwise have in the PR thread.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 5: CSV import with duplicates
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;an admin uploads a 10,000-row CSV to /admin/contacts/import
  &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;200&lt;/span&gt; &lt;span class="err"&gt;rows&lt;/span&gt; &lt;span class="err"&gt;have&lt;/span&gt; &lt;span class="err"&gt;emails&lt;/span&gt; &lt;span class="err"&gt;that&lt;/span&gt; &lt;span class="err"&gt;already&lt;/span&gt; &lt;span class="err"&gt;exist&lt;/span&gt;
&lt;span class="nf"&gt;When &lt;/span&gt;the import job processes the file
&lt;span class="nf"&gt;Then &lt;/span&gt;9,800 contacts are created and 200 are skipped (not updated);
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;result&lt;/span&gt; &lt;span class="err"&gt;page&lt;/span&gt; &lt;span class="err"&gt;shows&lt;/span&gt; &lt;span class="err"&gt;Total/Created/Skipped/Errors&lt;/span&gt; &lt;span class="err"&gt;counts;&lt;/span&gt;
  &lt;span class="nf"&gt;a &lt;/span&gt;CSV of skipped rows is downloadable with row_number, email, reason;
  &lt;span class="err"&gt;email&lt;/span&gt; &lt;span class="err"&gt;comparison&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;case-insensitive;&lt;/span&gt;
  &lt;span class="nf"&gt;a &lt;/span&gt;malformed row counts under &lt;span class="s"&gt;"Errors"&lt;/span&gt; and the rest continue;
  &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;import&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;atomic&lt;/span&gt; &lt;span class="err"&gt;per-row,&lt;/span&gt; &lt;span class="err"&gt;not&lt;/span&gt; &lt;span class="err"&gt;per-file&lt;/span&gt; &lt;span class="err"&gt;—&lt;/span&gt; &lt;span class="nf"&gt;an &lt;/span&gt;interruption
  &lt;span class="err"&gt;at&lt;/span&gt; &lt;span class="err"&gt;row&lt;/span&gt; &lt;span class="err"&gt;5,000&lt;/span&gt; &lt;span class="err"&gt;leaves&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;first&lt;/span&gt; &lt;span class="err"&gt;5,000&lt;/span&gt; &lt;span class="err"&gt;committed.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example 6: Notification retry
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;the service sends an email via the SMTP provider
&lt;span class="nf"&gt;When &lt;/span&gt;the provider returns a transient error (timeout, 5xx, DNS)
&lt;span class="err"&gt;Then the notification enters a retry queue with exponential backoff&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="err"&gt;min&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="err"&gt;5&lt;/span&gt; &lt;span class="err"&gt;min&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="err"&gt;15&lt;/span&gt; &lt;span class="err"&gt;min&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="err"&gt;60&lt;/span&gt; &lt;span class="err"&gt;min;&lt;/span&gt;
  &lt;span class="err"&gt;each&lt;/span&gt; &lt;span class="err"&gt;attempt&lt;/span&gt; &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;logged&lt;/span&gt; &lt;span class="err"&gt;with&lt;/span&gt; &lt;span class="err"&gt;attempt_number&lt;/span&gt; &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;next_retry_at;&lt;/span&gt;
  &lt;span class="err"&gt;after&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;4th&lt;/span&gt; &lt;span class="err"&gt;failure,&lt;/span&gt; &lt;span class="err"&gt;status&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="err"&gt;"permanently_failed"&lt;/span&gt;
  &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;an &lt;/span&gt;alert fires with the full error history;
  &lt;span class="nf"&gt;a &lt;/span&gt;PERMANENT error (550 mailbox not found) gets NO retries —
  &lt;span class="err"&gt;status&lt;/span&gt; &lt;span class="err"&gt;fails&lt;/span&gt; &lt;span class="err"&gt;immediately&lt;/span&gt; &lt;span class="err"&gt;and&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;user's&lt;/span&gt; &lt;span class="err"&gt;email_verified&lt;/span&gt; &lt;span class="err"&gt;flag&lt;/span&gt;
  &lt;span class="err"&gt;is&lt;/span&gt; &lt;span class="err"&gt;set&lt;/span&gt; &lt;span class="err"&gt;to&lt;/span&gt; &lt;span class="err"&gt;false.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The transient/permanent split is the difference between a retry policy and a retry &lt;em&gt;loop&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 5 mistakes that make criteria useless
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Too vague&lt;/strong&gt; — "the system works correctly." Untestable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implementation instead of behavior&lt;/strong&gt; — "uses Redis cache." The criterion should survive a tech-stack change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple behaviors in one criterion&lt;/strong&gt; — if it has three Whens, it's three criteria.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Happy path only&lt;/strong&gt; — the error paths are where the incidents live.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Untestable performance claims&lt;/strong&gt; — "fast" is not a number. "p95 &amp;lt; 500ms" is.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Steal this blank template
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Acceptance Criteria&lt;/span&gt;

&lt;span class="gu"&gt;### Happy path&lt;/span&gt;
Given &lt;span class="nt"&gt;&amp;lt;precondition&amp;gt;&lt;/span&gt;
When &lt;span class="nt"&gt;&amp;lt;action&amp;gt;&lt;/span&gt;
Then &lt;span class="nt"&gt;&amp;lt;observable&lt;/span&gt; &lt;span class="na"&gt;outcome&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;; &lt;span class="nt"&gt;&amp;lt;outcome&amp;gt;&lt;/span&gt;; &lt;span class="nt"&gt;&amp;lt;outcome&amp;gt;&lt;/span&gt;.

&lt;span class="gu"&gt;### Error handling&lt;/span&gt;
Given &lt;span class="nt"&gt;&amp;lt;precondition&amp;gt;&lt;/span&gt;
When &lt;span class="nt"&gt;&amp;lt;failure&lt;/span&gt; &lt;span class="na"&gt;trigger&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
Then &lt;span class="nt"&gt;&amp;lt;error&lt;/span&gt; &lt;span class="na"&gt;response&lt;/span&gt; &lt;span class="na"&gt;with&lt;/span&gt; &lt;span class="na"&gt;exact&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="err"&gt;/&lt;/span&gt;&lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;;
  &lt;span class="nt"&gt;&amp;lt;state&lt;/span&gt; &lt;span class="na"&gt;that&lt;/span&gt; &lt;span class="na"&gt;must&lt;/span&gt; &lt;span class="na"&gt;NOT&lt;/span&gt; &lt;span class="na"&gt;change&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;;
  &lt;span class="nt"&gt;&amp;lt;what&lt;/span&gt; &lt;span class="na"&gt;gets&lt;/span&gt; &lt;span class="na"&gt;logged&lt;/span&gt;&lt;span class="err"&gt;/&lt;/span&gt;&lt;span class="na"&gt;alerted&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;.

&lt;span class="gu"&gt;### Edge cases&lt;/span&gt;
Given &lt;span class="nt"&gt;&amp;lt;boundary&lt;/span&gt; &lt;span class="na"&gt;condition:&lt;/span&gt; &lt;span class="na"&gt;duplicate&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;concurrent&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;empty&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;max&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
When &lt;span class="nt"&gt;&amp;lt;action&amp;gt;&lt;/span&gt;
Then &lt;span class="nt"&gt;&amp;lt;deterministic&lt;/span&gt; &lt;span class="na"&gt;outcome&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;.

&lt;span class="gu"&gt;### Performance&lt;/span&gt;
Given &lt;span class="nt"&gt;&amp;lt;load&lt;/span&gt; &lt;span class="na"&gt;condition&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
When &lt;span class="nt"&gt;&amp;lt;action&amp;gt;&lt;/span&gt;
Then &lt;span class="nt"&gt;&amp;lt;metric&lt;/span&gt; &lt;span class="na"&gt;with&lt;/span&gt; &lt;span class="na"&gt;number&lt;/span&gt; &lt;span class="na"&gt;and&lt;/span&gt; &lt;span class="na"&gt;percentile&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;em&gt;This is a condensed cut of the full guide — all 20 examples across auth, e-commerce, APIs, data processing, and notifications — on &lt;a href="https://spec-coding.dev/blog/acceptance-criteria-examples-guide" rel="noopener noreferrer"&gt;Spec Coding&lt;/a&gt;. There's also a free &lt;a href="https://spec-coding.dev/tools/gherkin-generator" rel="noopener noreferrer"&gt;Gherkin generator&lt;/a&gt; if you want the format scaffolded for you.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>qa</category>
      <category>agile</category>
      <category>productivity</category>
    </item>
    <item>
      <title>'Retry on Error' Is Not a Payment Spec — Write the Failure Matrix Instead</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Tue, 16 Jun 2026 01:56:54 +0000</pubDate>
      <link>https://dev.to/speccoding/retry-on-error-is-not-a-payment-spec-write-the-failure-matrix-instead-2246</link>
      <guid>https://dev.to/speccoding/retry-on-error-is-not-a-payment-spec-write-the-failure-matrix-instead-2246</guid>
      <description>&lt;p&gt;Most payment specs I've reviewed describe the happy path in three pages and the failure behavior in one sentence: &lt;em&gt;"retry on error."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That sentence is where 80% of the production incidents come from.&lt;/p&gt;

&lt;p&gt;A payment workflow spec earns its keep by naming — category by category — exactly what the system does when the card network, the issuer, or the customer refuses to cooperate. Here's the structure I use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with a failure taxonomy, not a flowchart
&lt;/h2&gt;

&lt;p&gt;Before drawing a single box, force the spec to answer one question: &lt;strong&gt;what are the categories of failure this workflow can produce?&lt;/strong&gt; I insist on five, because collapsing them into "error" is what creates the mess:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Network timeout.&lt;/strong&gt; The processor never answered. The charge may or may not exist. This is the &lt;em&gt;only&lt;/em&gt; category where retrying with the same idempotency key is mandatory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Soft decline.&lt;/strong&gt; The issuer said no for a recoverable reason — insufficient funds, do-not-honor, expired card. Retry is allowed, but only with customer action or a later attempt window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard decline.&lt;/strong&gt; Stolen card, pickup card, fraud. Retrying is never correct, and on some networks it increases your risk score. The spec must forbid it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fraud review.&lt;/strong&gt; The processor accepted the auth but punted on a decision. The response is async. The spec must describe the waiting state and the webhook that ends it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3DS challenge.&lt;/strong&gt; The issuer demanded Strong Customer Authentication. This is &lt;em&gt;not a failure&lt;/em&gt; — it's a branch. The customer sees a redirect or iframe, and the workflow pauses until they finish.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every downstream decision — retry policy, user messaging, observability — hangs off this five-row matrix. If the taxonomy is wrong, nothing below it will save you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retry rules that match the category, not the HTTP status
&lt;/h2&gt;

&lt;p&gt;The rule I write into every payment spec, word for word: &lt;strong&gt;retry policy is a function of failure category, not of HTTP status.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A 402 from Stripe can be either a soft decline you should let the customer fix or a hard decline you should never touch again. The spec has to branch on the processor's &lt;em&gt;decline code&lt;/em&gt;, not the transport code.&lt;/p&gt;

&lt;p&gt;Concretely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;card_declined&lt;/code&gt; + &lt;code&gt;decline_code: insufficient_funds&lt;/code&gt; → up to three retries spaced by the dunning schedule, each gated on a customer action or a scheduled job.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;card_declined&lt;/code&gt; + &lt;code&gt;decline_code: stolen_card&lt;/code&gt; → permanent flag on the payment method; any subsequent attempt fails closed &lt;em&gt;before hitting the network&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Connection error or 5xx with no response body → immediate retry &lt;strong&gt;with the same &lt;code&gt;Idempotency-Key&lt;/code&gt;&lt;/strong&gt;, because the processor may have already charged the card and a fresh key would double-charge.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Idempotency keys belong to the attempt, not the request
&lt;/h2&gt;

&lt;p&gt;The single most common mistake I see: idempotency keys scoped to the HTTP request instead of the logical attempt.&lt;/p&gt;

&lt;p&gt;If a timeout triggers a retry and the retry generates a &lt;em&gt;new&lt;/em&gt; key, the processor treats it as a &lt;em&gt;new charge&lt;/em&gt;. The spec must say, in one sentence: &lt;strong&gt;the key is minted when the attempt begins and survives every retransmission inside that attempt.&lt;/strong&gt; A new attempt — a new customer action, a new dunning cycle, a new order — gets a new key. Nothing in between does.&lt;/p&gt;

&lt;p&gt;Also spec the key's lifetime. Processors typically honor keys for 24 hours. If a retry crosses that boundary, reconcile against the processor's ledger (list charges by metadata) instead of assuming the retry is safe.&lt;/p&gt;

&lt;h2&gt;
  
  
  3DS is a first-class state, not an error
&lt;/h2&gt;

&lt;p&gt;If the spec treats SCA as an error, the frontend will do something stupid like show a red banner while the issuer is mid-challenge.&lt;/p&gt;

&lt;p&gt;The spec needs a state called &lt;code&gt;requires_action&lt;/code&gt; (or whatever your processor calls it) with explicit transitions: entered when the auth returns a challenge URL, exited when the webhook confirms success or failure.&lt;/p&gt;

&lt;p&gt;Spec the two flavors separately:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;In-flow challenge:&lt;/strong&gt; the client SDK mounts the iframe, blocks interaction, resolves.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redirect challenge:&lt;/strong&gt; the browser navigates to the issuer's ACS URL and comes back to a return URL you control.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nail down the return URL, the query params you expect, and &lt;strong&gt;what happens if the customer closes the tab mid-challenge&lt;/strong&gt;. That last case always gets forgotten, and it's the one that produces stuck subscriptions in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Auth, capture, and the seven-day cliff
&lt;/h2&gt;

&lt;p&gt;If your workflow does auth-now / capture-later, the spec must call out auth expiry. Most processors auto-void an uncaptured auth at roughly seven days (Stripe is 7, Adyen varies by scheme, some schemes are shorter for debit).&lt;/p&gt;

&lt;p&gt;The spec needs to answer: &lt;em&gt;what happens if the fulfillment job runs on day 8?&lt;/em&gt; My answer is always the same — require a fresh auth before capture attempts beyond day 5, and treat any capture against an expired auth as a hard failure that opens a &lt;em&gt;new&lt;/em&gt; authorization, not a retry.&lt;/p&gt;

&lt;p&gt;Multi-capture makes this worse. Spec the partial-capture order, whether over-capture is permitted (usually not), and how refund-before-final-capture interacts with the remaining authorized amount. I've watched a team discover at 2am that their "simple" refund reduced the captureable balance to zero and killed the next shipment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dunning is a state machine — write it down
&lt;/h2&gt;

&lt;p&gt;For subscription failures, the spec should contain the dunning schedule &lt;em&gt;verbatim&lt;/em&gt;, not a vague "we will retry":&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attempt&lt;/th&gt;
&lt;th&gt;When&lt;/th&gt;
&lt;th&gt;Side effect&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Immediate, at renewal&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;+3 days&lt;/td&gt;
&lt;td&gt;Silent retry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;+7 days&lt;/td&gt;
&lt;td&gt;Email 24h earlier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;+14 days&lt;/td&gt;
&lt;td&gt;Final-notice email&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cancel&lt;/td&gt;
&lt;td&gt;+21 days&lt;/td&gt;
&lt;td&gt;Access revoked at next cycle boundary&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each transition is a row in a state table: previous state, trigger, new state, side effects. Without this table the team re-argues the schedule every quarter.&lt;/p&gt;

&lt;h2&gt;
  
  
  The webhook is the source of truth
&lt;/h2&gt;

&lt;p&gt;Non-negotiable clause: &lt;strong&gt;the synchronous response from the processor is advisory. The webhook is the ledger.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Forbid any state transition derived only from the API response — capture confirmed, refund settled, dispute opened, 3DS completed all wait for the corresponding event.&lt;/p&gt;

&lt;p&gt;Concrete consequence: the spec needs an outbox or a reconciliation job. If the webhook is delayed, the UI shows "processing" longer than the customer expects. The spec owns that tradeoff and picks a timeout after which a job polls the processor directly. I pick 30 seconds for interactive flows, 15 minutes for background ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Acceptance criteria with a real retry scenario
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nf"&gt;Given &lt;/span&gt;a customer with a Visa ending 4242 and a recurring $29 subscription
&lt;span class="nf"&gt;When &lt;/span&gt;the renewal charge returns card_declined / insufficient_funds
&lt;span class="nf"&gt;Then &lt;/span&gt;the payment is marked past_due
  &lt;span class="nf"&gt;And &lt;/span&gt;attempt 2 is scheduled for +3 days with the same payment method
  &lt;span class="nf"&gt;And &lt;/span&gt;no email is sent on this attempt
  &lt;span class="nf"&gt;And &lt;/span&gt;the customer retains access until the grace period expires

&lt;span class="nf"&gt;Given &lt;/span&gt;the client receives a connection timeout on charge creation
&lt;span class="nf"&gt;When &lt;/span&gt;the client retries within 24 hours
&lt;span class="nf"&gt;Then &lt;/span&gt;it reuses the original Idempotency-Key
  &lt;span class="nf"&gt;And &lt;/span&gt;the processor returns the original charge, not a duplicate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Three metrics the spec has to name
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Authorization rate&lt;/strong&gt; broken down by BIN range and card scheme.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decline-reason distribution&lt;/strong&gt; with the processor's raw &lt;code&gt;decline_code&lt;/code&gt; preserved — not bucketed into "declined".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3DS drop-off&lt;/strong&gt;: challenges initiated vs challenges completed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Miss any of these and you're flying blind the first time a single issuer changes its risk model and tanks your approval rate overnight. I also require a dashboard for &lt;strong&gt;webhook lag&lt;/strong&gt; — the gap between the processor's event timestamp and your ingestion timestamp. A growing lag is usually the earliest signal that the payment pipeline is about to page someone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;A payment spec is not "describe the charge endpoint." It's a &lt;strong&gt;failure-handling document with a small happy path attached.&lt;/strong&gt; Get the taxonomy right, attach a retry rule to each row, treat 3DS as a branch instead of an error, and let the webhook be the source of truth.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This is adapted from the full guide on &lt;a href="https://spec-coding.dev/blog/payment-workflow-spec-failure-and-retry-matrix" rel="noopener noreferrer"&gt;Spec Coding&lt;/a&gt;, where we maintain spec templates and browser-based generators for API contracts, database migrations, and payment workflows.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>payments</category>
      <category>api</category>
      <category>architecture</category>
      <category>backend</category>
    </item>
    <item>
      <title>Why Your API Contract Breaks in Production (And How to Fix It in the Spec)</title>
      <dc:creator>guo king</dc:creator>
      <pubDate>Wed, 22 Apr 2026 08:11:48 +0000</pubDate>
      <link>https://dev.to/speccoding/why-your-api-contract-breaks-in-production-and-how-to-fix-it-in-the-spec-1kjh</link>
      <guid>https://dev.to/speccoding/why-your-api-contract-breaks-in-production-and-how-to-fix-it-in-the-spec-1kjh</guid>
      <description>&lt;p&gt;The most expensive API bugs I've seen weren't implementation bugs. They were contract bugs — cases where the producer and consumer had different beliefs about what the API promised, and nobody wrote it down before the code was shipped.&lt;/p&gt;

&lt;p&gt;Here's the pattern: a team builds an endpoint, the frontend and backend agree on the behavior in a Slack thread or a meeting, and the implementation proceeds. Six months later, a field gets renamed as part of a "minor cleanup," a consumer breaks silently, and the incident postmortem includes the sentence "we thought this was backward compatible."&lt;/p&gt;

&lt;p&gt;The root cause is almost never malice or carelessness. It's that the contract was implicit — shared understanding that lived in people's heads rather than in a document that both sides could point to.&lt;/p&gt;




&lt;h2&gt;
  
  
  What an API contract actually is
&lt;/h2&gt;

&lt;p&gt;An API contract is the explicit agreement between a producer and its consumers about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What fields exist, what they're named, and what types they carry&lt;/li&gt;
&lt;li&gt;What the valid inputs are (required vs. optional, validation rules)&lt;/li&gt;
&lt;li&gt;What error codes mean and when each one is returned&lt;/li&gt;
&lt;li&gt;What "success" looks like at the HTTP level and the payload level&lt;/li&gt;
&lt;li&gt;What the retry behavior is — is this operation idempotent?&lt;/li&gt;
&lt;li&gt;What the version policy is — when does a change become breaking, and how much notice will consumers get?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most teams document some of these things. The ones that cause incidents are usually the last three.&lt;/p&gt;




&lt;h2&gt;
  
  
  The three contract decisions teams skip
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Error taxonomy
&lt;/h3&gt;

&lt;p&gt;When an operation fails, what does the consumer do next?&lt;/p&gt;

&lt;p&gt;If your API returns &lt;code&gt;400&lt;/code&gt; for validation errors and &lt;code&gt;400&lt;/code&gt; for business-rule rejections, the consumer can't distinguish between "fix your input" and "this action is blocked for business reasons." They'll implement retry logic that retries unretryable errors, or they'll show the wrong message to the user.&lt;/p&gt;

&lt;p&gt;Before implementation, the spec should define:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;400 Bad Request    — invalid input; client should fix and retry
409 Conflict       — valid input, business rule blocks; client should not retry
422 Unprocessable  — valid input, data state prevents action; may resolve over time
503 Unavailable    — transient; client should retry with backoff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a design decision. Make it in the spec, not in the error handler.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Idempotency
&lt;/h3&gt;

&lt;p&gt;Can the consumer safely retry this request if they don't get a response?&lt;/p&gt;

&lt;p&gt;Payment endpoints, state-mutation endpoints, and any operation with side effects need an explicit answer. "The backend should handle it" is not an answer — it's a deferred argument.&lt;/p&gt;

&lt;p&gt;Spec-first means writing this down before implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /orders
Idempotency: Yes
Key: X-Idempotency-Key header (UUID, client-generated)
Window: 24 hours — duplicate requests within 24h return the original response
After window: treated as new request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the consumer knows what to send, the backend knows what to store, and QA knows what to test.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Breaking change definition
&lt;/h3&gt;

&lt;p&gt;Before you ship your first external-facing version, agree on what counts as breaking:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Breaking (requires version bump, advance notice):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Removing a field&lt;/li&gt;
&lt;li&gt;Renaming a field&lt;/li&gt;
&lt;li&gt;Changing a field's type&lt;/li&gt;
&lt;li&gt;Changing the meaning of an existing status code&lt;/li&gt;
&lt;li&gt;Making an optional field required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Non-breaking (can ship without version bump):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding a new optional field&lt;/li&gt;
&lt;li&gt;Adding a new endpoint&lt;/li&gt;
&lt;li&gt;Adding a new enum value (if consumers are built to handle unknown values)&lt;/li&gt;
&lt;li&gt;Bug fixes that bring behavior in line with documented behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Document this. When "minor cleanup" happens six months from now, the engineer making the change has a checklist, not a judgment call.&lt;/p&gt;




&lt;h2&gt;
  
  
  The OpenAPI to CI pipeline
&lt;/h2&gt;

&lt;p&gt;Once your contract is written, the best way to protect it is to make breaking changes fail in CI before they reach a reviewer.&lt;/p&gt;

&lt;p&gt;The minimal setup:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Generate OpenAPI spec from your implementation&lt;/strong&gt; (or write it first and validate against it)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run &lt;code&gt;openapi-diff&lt;/code&gt; or &lt;code&gt;oasdiff&lt;/code&gt; in CI&lt;/strong&gt; — fails the build if a breaking change is detected&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run contract tests against a real consumer&lt;/strong&gt; — Pact or equivalent; the consumer's expectations are versioned alongside the producer's spec&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This doesn't prevent all contract breaks. It prevents the ones that nobody caught because they were in a field rename that "obviously" wouldn't affect anything.&lt;/p&gt;




&lt;h2&gt;
  
  
  The spec-first version of this workflow
&lt;/h2&gt;

&lt;p&gt;The difference between spec-first API development and regular API development isn't the tools. It's the order:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Regular:&lt;/strong&gt; Build → Document → Ship → Break consumer → Fix&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spec-first:&lt;/strong&gt; Define contract → Review contract → Build to contract → Validate in CI → Ship&lt;/p&gt;

&lt;p&gt;The contract review is where most of the value lives. It's the moment when the consumer team can say "we rely on that field being optional" before the producer team has already built it as required.&lt;/p&gt;

&lt;p&gt;That conversation is almost free before implementation. It's expensive after deployment.&lt;/p&gt;




&lt;h2&gt;
  
  
  A minimal API contract template
&lt;/h2&gt;

&lt;p&gt;If you don't have a spec process yet, start with this for every new endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Endpoint: POST /v1/[resource]
Purpose: [one sentence]

Request:
  Required fields: [list]
  Optional fields: [list]
  Validation rules: [list]

Response (success):
  Status: 201
  Fields returned: [list]

Response (errors):
  400: [when, what to tell the consumer]
  409: [when, what to tell the consumer]
  503: [when, consumer should retry with backoff]

Idempotency: [yes/no] — if yes, key mechanism and window
Breaking change policy: [link to shared definition]
Version: v1 — changes that break the above require a new version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the minimum. It takes 15 minutes to write. The alternative is a 2am incident.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I write about spec-first delivery and API contracts at &lt;a href="https://spec-coding.dev" rel="noopener noreferrer"&gt;spec-coding.dev&lt;/a&gt;. The &lt;a href="https://spec-coding.dev/guides/api-contract-checklist" rel="noopener noreferrer"&gt;API Contract Checklist&lt;/a&gt; covers the full pre-release review process.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>programming</category>
      <category>webdev</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
