• Prove a fix with a failing test first
  • Fast gates, slow gates, and what blocks
  • Keep agents honest with verifiers and evals

One command that says yes or no

A gate is an automated check every change must pass. Wrap your tests, build and lint in one command that exits non-zero on failure. Then the agent can check its own work.

Agentchanges code Gatenpm run gate draft PR exit 1: fix and retry exit 0
$ npm run gate
Agent workGateFailure loops back

Failing test first (TDD, FTW)

For a bug fix, the test comes before the fix. The failing test proves the bug exists, and the same test proves the fix works. Step through it.

  1. Write a failing test

    It reproduces the bug, and fails.

  2. Commit the test

    On its own, before any fix.

  3. Fix without touching the test

    The agent changes code only.

  4. Gate green

    Same test, now passing.

Fast gates and slow gates

Two gates, two jobs. Select a bar to see what it runs.

Fast gate, on every pull request

Slow gate, nightly

9am3pm9pm3am9am

Select a bar

Many quick gates through the day, one long run at night.

Fast gate (minutes)Nightly full suiteTimes are illustrative

Nightly red blocks everything

If the nightly run fails, nothing merges until it is fixed and closed with evidence. Turn the nightly red and see what happens.

    Nightly: green

    The UI feedback loop

    Tests do not see layout. For UI work the agent implements, takes a screenshot, compares it with the design, and adjusts. It usually takes 2 to 3 rounds.

    design screenshot
    implementscreenshotcompareadjust
    round 1round 2round 3

    The first attempt is close but off. Run a round.

    Design target (the check)Agent's implementation

    A verifier with fresh eyes

    The agent that wrote the code is the worst judge of it. A verifier subagent starts with a fresh context and checks the result against the spec.

    The writer's context

    Full of its own attempts and reasons.

    specattempt 1error log"this should work"attempt 2side questattempt 3own assumptionsdiff

    The verifier's context

    Only what it needs to judge.

    specdiffgate command

    An unbiased final check, defined once in .claude/agents/.

    Continuous evals

    An eval is a real task with a known good outcome. Keep 20 to 50 of them. Rerun them whenever your agent setup changes. Try a change.

    30 eval tasks

    Change something, then rerun:

    Every change to the setup can quietly break a task that used to work.

    PassesRegression caughtAdded from an incidentResults are illustrative

    A checker script beats a rule in prose

    Rules that live only in prose get skipped. A small checker script reads the lead's state file and fails loudly.

    Rule in prose

    "Always give a reason for a free slot. Keep the usage reading fresh. Hand over before context fills."

    Followed most of the time. Skipped when the session is long and busy.

    Checker script

    $ check-state FAIL idle slot with no reason FAIL no sweep scheduled FAIL usage reading is stale PASS report data well formed PASS under context limit

    The lead runs it every sweep and before every report, and does not publish while it fails.

    Adversarial review of a PR stack

    Each pull request can pass its own gate and still break when merged with its neighbors. Before related PRs merge together, a reviewer agent tries to break the whole stack.

    #41 Add export_jobs tablegate ✓
    #42 API: rename rows to row_countgate ✓
    #43 UI: progress bar for exportsgate ✓
    Finding (Important): #43 still reads rows, which #42 renamed. Each PR passes alone. Together, the progress bar is always empty.

    AI review, with people in charge

    • A REVIEW.md in the repo defines the passes: bugs and logic, security, match with spec and plan.
    • It says what is Important and what is a nit, and caps the nits.
    • The agent that wrote the code cannot approve it.
    • Findings inform your team's reviewers. They never approve or block alone.
    GateFinding for a person to judgeExample PRs are illustrative

    Key takeaways

    • Give every task one gate command that exits non-zero on failure.
    • Failing test first, committed first, and the fix never edits the test.
    • Fast gate on every PR, full suite nightly. A red nightly blocks all merges.
    • Use screenshots for UI, a fresh-context verifier, and 20 to 50 evals rerun on every setup change.
    • Enforce with scripts and hooks. Prose rules get skipped.

    Go deeper