DEV Community

Cover image for My AI swore all tests passed. Here's the free one-file fix that makes it prove it.
Heinrich Neb
Heinrich Neb

Posted on Edited on AI-assisted

My AI swore all tests passed. Here's the free one-file fix that makes it prove it.

My agent told me "All tests pass." It had run 74 of our 105 test files. Another time it wrote "The email went out at 08:45." The clock said 08:37. A third time: "14 people clicked Sign in." Those were page views. Nobody had counted clicks.

None of that was lying. The agent said what it believed. The trouble is that "done" is a sentence, and a sentence costs nothing to write.

So I stopped accepting sentences. A task is done when one command exits 0. The command writes a receipt, and the agent pastes the receipt instead of the word "done". Here is the free version of that, in a single file.

What you get

proof-gate is one Node file. No dependencies, MIT, 8 tests of its own. It does two things for every task:

  1. It runs your checks (tests, build, lint, anything with an exit code).
  2. It writes a receipt: the commit, the time, every command and its exit code.

It works the same with Claude Code, Cursor, Copilot or a plain shell. It does not talk to any model. It only reads exit codes.

Step 1: put the file in your repo

git clone https://github.com/cachly-dev/proof-gate
cp proof-gate/proof-gate.mjs ./proof-gate.mjs
Enter fullscreen mode Exit fullscreen mode

You need Node 18 or newer. That is the whole install.

Step 2: describe one task

Create proof-gate.json in your project root. This one guards a rate limiter:

{
  "tasks": {
    "rate-limit": {
      "checks": [
        { "name": "acceptance", "run": "node --test test/rate-limit.test.mjs" },
        { "name": "build", "run": "npm run build" }
      ],
      "controls": [
        {
          "name": "says no when the limit is off",
          "run": "node --test test/rate-limit.test.mjs",
          "env": { "RATE_LIMIT_DISABLED": "1" }
        }
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

The controls block is the part people skip, so one line on it. A control is the same check pointed at something that is supposed to be wrong. It must fail. If it passes, the gate goes red, because a check that cannot fail proves nothing. I cover that in a separate post. For now, copy the block and adapt it.

Step 3: run it

node proof-gate.mjs rate-limit
Enter fullscreen mode Exit fullscreen mode
TASK: rate-limit
GATE: 0 (3/3)
RECEIPT: .proof-gate/receipts/rate-limit.json
NOTE: -
Enter fullscreen mode Exit fullscreen mode

Four lines. Exit code 0 means green, 1 means red, 2 means refused (the setup is incomplete and nothing was judged). Refused is never green.

When something is wrong you get the first problem in NOTE:

TASK: rate-limit
GATE: 1 (2/3)
RECEIPT: .proof-gate/receipts/rate-limit.json
NOTE: control passed, so the check cannot say no: says no when the limit is off
Enter fullscreen mode Exit fullscreen mode

Step 4: make the agent hand over the receipt

Add this to CLAUDE.md, AGENTS.md or your Cursor rules:

## Done means
- A task is done when `node proof-gate.mjs <task>` exits 0. Paste its four lines.
- If the gate is red, say so. Do not call the task done.
Enter fullscreen mode Exit fullscreen mode

That is the change. The agent can still be wrong, but it can no longer be wrong quietly.

Why a receipt and not just the exit code

The receipt is .proof-gate/receipts/rate-limit.json. It holds the commit hash, a dirty flag, the time, and the last 20 lines of output from every command.

On 24 November my own worker agent reported "gate green". I looked at the receipt. The commit in it was the one before the agent's change. The agent had run the gate before it committed, so the green belonged to the old code. Without the commit in the receipt I would have believed it.

The same day, a feature gate of mine was green with 6 of 6 steps. The full server tests were red. One of them requires that every server route has a caller in the app, or a written reason why not. My gate had never included the full tests. I found it before the push, and now the full test run is part of the gate. A gate is only as honest as the list of things in it, and the receipt makes that list visible. If the checks you expected are not in the receipt, you see it.

Where it runs

The gate is a plain command, so it fits wherever you can run a shell command:

  • In Claude Code, the agent runs it itself. The rule in CLAUDE.md tells it to.
  • In Cursor or Copilot, put the same rule in your rules file or instructions, and run the gate yourself if the agent does not.
  • In CI, add one line: node proof-gate.mjs rate-limit. The exit code decides whether the job passes.

You can also run it after the agent says "done" and before you read a single line of the diff. If it is red, you saved yourself the reading.

What it is not

  • Not a test runner. It calls yours.
  • Not an AI judge. Every decision comes from an exit code.
  • Receipts keep the last 20 lines of each command's output. Keep secrets out of your test output, or add .proof-gate/receipts/ to .gitignore.

Try it tonight

Pick one task you gave an agent this week. Write its proof-gate.json entry with one check and one control. Run it. Two things can happen. It goes green and you now have a receipt. Or it goes red or refused, and you just learned something about a task you thought was finished.

The repo is here: github.com/cachly-dev/proof-gate. There is also a full version, free: the Agent Proof Kit, with task packs, a model ladder and a ledger around the gate. Leave your address at cachly.dev/forge and the download link arrives after you confirm. That is all I will say about it here.

What is the last "done" from an agent that turned out not to be?


I build cachly. It keeps what you explain to your AI: your rules, your decisions and the bugs you already solved. Claude Code, Cursor, Copilot and the others read it in every session, for you alone or for your whole team, and every lesson carries the name of whoever learned it.

Try it, in increasing order of commitment:

  • 30 seconds, no account: npx @cachly-dev/mcp-server@latest demo in any git repo. It reads your log locally and prints what an assistant would already know about the project. After npx fetches the package, the command makes no network calls.
  • Claude Code plugin: /plugin marketplace add cachly-dev/cachly-mcp, then /plugin install cachly-brain@cachly.
  • 5 minutes, free tier: npx @cachly-dev/mcp-server@latest autopilot writes the MCP configuration for whichever assistant you use.
  • Or from the web: cachly.dev · free tier, servers in Germany.

On Product Hunt from 1 December: cachly on Product Hunt. Follow it there if you want a note on launch day.

Written with AI assistance.

Top comments (7)

Collapse
 
dosaygo profile image
DOSAYGO •

How do you decide which checks belong in a task gate when an agent changes a shared helper used beyond the requested feature?

Collapse
 
heinrichneb profile image
Heinrich Neb •

So far the answer is blunt: the full test run is part of the gate, not just the feature's own checks. That came from a miss on 24 November. A feature gate of mine was green with 6 of 6 steps, and the full server tests were red, because one of them requires that every server route has a caller. I don't have a smarter way to pick a subset for a shared helper yet. Choosing checks by which files import it is the obvious candidate, but I haven't tried it.

Collapse
 
dosaygo profile image
DOSAYGO •

Thanks for the detail about the green feature gate missing a failing server route check. I'm building AI Lint; its checklist asks agents to run relevant tests during changes and the full suite at milestones, so the broader check stays visible in the workflow: ai-lint.dosaygo.com/go/forum-20261...

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

Having it in the checklist keeps the full run in view. In my case what mattered was the gate running the full suite itself, because a report that says "full suite green" and a real run look the same in a summary. How does AI Lint tell whether the agent actually ran the suite at a milestone, or only reported it?

Thread Thread
 
dosaygo profile image
DOSAYGO •

Thanks for the detail on a summary saying "full suite green" looking identical to a real run unless the gate executes the suite itself, I'm building AI Lint as an in-repo Markdown checklist and doctrine pack rather than a test runner—so your deterministic hook or CI gate still executes the full suite while AI Lint constrains what the agent writes before that gate runs and requires citing the exact test command and evidence (or an explicit Override / Reason / Risk / Mitigation record) for any completion claim: ai-lint.dosaygo.com/go/forum-20261...

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

Sounds good to me. Citing the exact command is the part I'd want too. Then the gate can rerun that command and compare, instead of trusting the summary.

Thread Thread
 
dosaygo profile image
DOSAYGO •

Agreed. Recording the working directory and revision alongside the exact command helps make the rerun comparable; the gate can then keep the exit status and output as evidence rather than relying on the summary.