IzziAI
GuideNov 26, 20264 min read

Verify AI-Generated Code with Acceptance Evidence

Turn a software requirement into unit, property, differential, and end-to-end checks that produce reviewable evidence for an AI-generated change.

IzziAI guides
AI-generated codesoftware testingacceptance criteriaClaude Codeverification
A fixed acceptance check fails before the change and passes afterward.

Verify an AI-generated code change by turning the requirement into checks that can fail. Run those checks against the exact revision under review, preserve the output, and connect each result to one acceptance rule. A confident explanation of the diff is not execution evidence.

The example below is illustrative. It shows how to review a discount-code normalization change without claiming that Starizzi ran it in a particular repository.

Write the acceptance contract before reading the patch

Assume a checkout service accepts a discount code. The requested change has four rules:

  1. Trim whitespace at the beginning and end.
  2. Compare ASCII letters without case sensitivity.
  3. Reject an empty value after trimming.
  4. Preserve internal punctuation because TEAM-25 and TEAM25 may be different codes.

These statements define observable behavior. They expose an easy mistake: removing every non-alphanumeric character would make two distinct codes collide.

Map each rule to a check

RuleCheckFailure it catches
Trim outer whitespaceExample for TEAM-25 Raw comparison
Ignore ASCII letter caseExamples for team-25 and TEAM-25Case-sensitive lookup
Reject blank inputEmpty string, spaces, and tabsBlank reaches lookup
Preserve punctuationPair for TEAM-25 and TEAM25Over-aggressive normalization

Keep expected outputs in a fixture or specification controlled by the code owner. A patch should not rewrite its own acceptance rules and pass by moving the target.

Use four layers of verification

1. Example tests make the requirement concrete

Write a table of inputs and expected normalized values or errors. Include ordinary inputs, boundaries, and a pair that must remain different. Run the test before and after the change when possible. A test that passes both versions may provide regression coverage, but it does not prove the new change was necessary.

2. Property tests search beyond examples

  • Normalizing a value twice returns the same result as normalizing it once.
  • Adding outer spaces does not change a valid code's normalized value.
  • Normalization never removes an internal hyphen.
  • A string containing only whitespace always fails validation.

Property-testing libraries can generate inputs that neither the author nor coding agent selected. Preserve the failing seed when a generated case finds a bug.

3. Differential tests protect established behavior

Run the old and new implementations over a corpus of existing valid codes. Approve only differences required by the new contract. Investigate unrelated changes. Differential evidence is valuable when production behavior has become more authoritative than an old prose specification.

4. End-to-end tests prove the user flow

Boot the checkout surface, add a toy product, enter team-25 , and verify the expected discount appears. Then enter TEAM25 and verify that it does not receive the hyphenated code's discount. Capture the browser trace, screenshot, API response, or fixture that explains a failure.

Addy Osmani's How the Claude Code team thinks about verification highlights end-to-end, property, and differential tests as high-value forms of verification. It also argues for running the changed system and keeping checks outside the change's control.

Bind the evidence to one revision

A useful record names the repository, commit, environment, fixture, commands, timestamps, and results:

YAML
Revision: 8f31c2a
Runtime: Node 26.x
Fixture: checkout-discount-toy-v2
Checks:
- unit: 18 passed, 0 failed
- property: 4 properties
- differential: 250 codes, 12 approved changes
- e2e: 2 flows passed
Artifacts:
- junit.xml
- differential-report.json
- checkout-trace.zip

Those numbers illustrate a format. Replace them with actual output. A reviewer should connect every artifact to the recorded revision.

Keep generation and judgment separate

The coding agent may propose tests and run them. The code owner decides the acceptance contract and reviews whether a test detects the target failure. For a consequential gate, read the rubric from the base branch and prevent the candidate from weakening it silently.

A verifier should explain why a check failed. The failure should name the broken rule, smallest reproducing input, and artifact that shows the behavior.

Handle a failing loop

Retrying a flaky command until it turns green is weak evidence. Classify the failure as a product defect, test defect, environment problem, or unavailable dependency. Fix the cause, narrow the claim, or escalate with preserved evidence. If a check remains flaky, change its gating authority through the project's review process and record why.

Ship the evidence with the change

The final packet should answer five questions. What behavior changed? Which checks represent it? Which revision ran? What failed before it passed? Which risks remain outside the tested profile?

Source and credit

Topic inspired by a community post from Nguyễn Văn Nghĩa, crediting Phong Hồ, with the underlying discussion traced to Addy Osmani: view the original Facebook post. This independent Starizzi guide adds an original discount-code example, acceptance matrix, and evidence-packet format. Primary reading: How the Claude Code team thinks about verification.

MORE

Related articles