Skip to content

Verification-Driven Agentic Coding

Agentic coding works best when the agent has a target it can check by itself.

Without a verification signal, the agent stops when the code looks plausible. With a signal, it can run the check, read the failure, change the code, and repeat until the output is actually better.

  1. Ask the agent to inspect the relevant code path.
  2. Define the smallest check that proves the behavior.
  3. Write or identify that check before changing the implementation.
  4. Let the agent implement the fix.
  5. Make the agent run the check and show evidence.

For code, the check might be a failing unit test. For UI, it might be a screenshot comparison. For data work, it might be a fixture diff. For infrastructure, it might be a dry-run plan.

SignalBest forExample
Unit testPure functions, edge cases, regressionsnpm test -- auth-refresh.test.ts
Integration testAPI, database, service boundariespytest tests/api/test_login.py
Build/typecheckCompile-time and contract errorsnpm run build, tsc --noEmit
Lint/formatMechanical consistencynpm run lint
ScreenshotVisual UI changesBrowser or Playwright screenshot after the edit
Fixture diffParsers, serializers, generated outputCompare generated JSON against expected output
Log replayDebugging production-like failuresPipe an error log into the task context
Dry runCloud, migration, deployment workterraform plan, migration preview, --dry-run
Investigate this bug first. Do not change implementation yet.
Write the smallest failing test that reproduces the reported behavior.
Run only that test and confirm it fails for the expected reason.
Then implement the fix, rerun the test, and show the final command output.

This works because the agent gets a concrete loop:

flowchart LR
    A["Inspect code"] --> B["Create failing check"]
    B --> C["Implement change"]
    C --> D["Run check"]
    D --> E{"Passes?"}
    E -->|No| C
    E -->|Yes| F["Return evidence"]
Use the existing app locally.
Reproduce the UI issue, take a screenshot, apply the smallest fix,
take another screenshot, and compare the result against the expected state.
Do not call the task done unless the visual difference is resolved.

For UI work, a text description is often not enough. Screenshots give the agent a readable result, especially when spacing, overflow, contrast, and layout are involved.

Ask for evidence, not just a claim:

  • the exact command it ran
  • the relevant passing test output
  • before/after screenshots for visual work
  • the changed files
  • any checks it could not run and why
FailureWhat to do instead
Agent updates snapshots without explaining whyAsk it to prove the new output is correct
Agent runs the whole suite too earlyStart with the smallest relevant test
Agent claims success without outputRequire command output or screenshot evidence
Agent suppresses an errorTell it to fix root cause, not silence the check
No runnable tests existStart with a smoke script, fixture, or manual checklist

Do not force a full TDD loop for small documentation edits, typo fixes, or obvious one-line changes. Use the cheapest meaningful check: build the docs, run markdown lint, or read the changed page.