DEV Community

Cover image for The 3-check rule I use before I accept any AI coding task (free repo inside)
Heinrich Neb
Heinrich Neb

Posted on Edited on AI-assisted

The 3-check rule I use before I accept any AI coding task (free repo inside)

An AI wrote 13 tests for me. All 13 were green. I was pleased for about a minute. Then I saw that the line they were meant to test was commented out. The tests had never touched my code.

After that I wrote down what I check before I accept any task from an agent. It is three things. I can remember them without a note, and so can you.

The rule

  1. Checks. Something with an exit code ran: tests, build, lint. Not "I looked at it".
  2. Controls. At least one check was pointed at something broken, and it failed. It had to.
  3. Locked acceptance. The agent could not edit the test that decides if it is done.

If one of the three is missing, the task is not done. It is a claim.

Why these three

Checks are obvious, and they are still the most skipped. "Build: pass" showed up in an agent's report three times in six weeks. Each time the server did not start. The build passed. Nobody had run the thing.

Controls answer the 13-tests problem. A check that has never failed might be a check that cannot fail. The cure is cheap. Run the same test with the feature switched off, or against an old fixture, or against a file you know is broken. It must go red. If it stays green, your check is decoration.

Locked acceptance answers the cheapest cheat there is. An agent has two ways to turn a red test green. It can fix the code, or it can fix the test. Both look like progress in a diff. So you pin the acceptance file with a hash before the agent starts. If the hash changes, the verdict is red, whatever the test now says.

Enforce it with one file

The rule works as a habit, but habits slip at 6 pm. proof-gate is a single Node file (18+) that enforces all three. MIT, no dependencies, 8 tests of its own.

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

Describe the task in proof-gate.json:

{
  "tasks": {
    "export-csv": {
      "locked": ["test/export-csv.test.mjs"],
      "checks": [
        { "name": "acceptance", "run": "node --test test/export-csv.test.mjs" },
        { "name": "build", "run": "npm run build" }
      ],
      "controls": [
        {
          "name": "fails on the old exporter",
          "run": "node --test test/export-csv.test.mjs",
          "env": { "USE_OLD_EXPORTER": "1" }
        }
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Here is how each line of the rule maps to the file:

  • checks is rule 1.
  • controls is rule 2. Each control must exit non-zero.
  • locked is rule 3.

You pin the acceptance files once, then commit the pin:

node proof-gate.mjs lock export-csv
git add .proof-gate/locks.json proof-gate.json && git commit -m "pin export-csv acceptance"
Enter fullscreen mode Exit fullscreen mode

Anyone, human or agent, then runs:

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

What each failure looks like

The agent edits the locked test:

TASK: export-csv
GATE: 1 (0/3)
RECEIPT: .proof-gate/receipts/export-csv.json
NOTE: locked file changed: test/export-csv.test.mjs
Enter fullscreen mode Exit fullscreen mode

The control passes when it should fail:

TASK: export-csv
GATE: 1 (2/3)
RECEIPT: .proof-gate/receipts/export-csv.json
NOTE: control passed, so the check cannot say no: fails on the old exporter
Enter fullscreen mode Exit fullscreen mode

You forgot to write any control:

TASK: export-csv
GATE: 2 (refused)
RECEIPT: -
NOTE: no controls: a check nobody has seen fail is not a check yet (add one that must fail)
Enter fullscreen mode Exit fullscreen mode

Exit code 2 means refused. It is never green. The gate would rather say nothing was judged than give you a green it did not earn.

The block for CLAUDE.md or AGENTS.md

Copy this as is:

## Done means
- A task is done when `node proof-gate.mjs <task>` exits 0. Paste its four lines.
- Never edit files listed under "locked". If the test is wrong, stop and say so.
- If a control passes, fix the check, not the control.
- "It should work" is a plan, not a result. Run it.
Enter fullscreen mode Exit fullscreen mode

The second line matters most. It gives the agent a legal move when it thinks the test is wrong: stop and tell you. Without that line, editing the test looks like the only way forward.

Using the rule without the tool

If you do not want a tool, use the rule as a review question. When an agent says a task is done, ask three things in this order:

  1. "Which command did you run, and what was its exit code?"
  2. "Which run failed on purpose, and what did it show?"
  3. "Which files did you change? Is the acceptance test among them?"

If the answers come back as a command, a failure and a file list, you can accept. If they come back as "it should work", you cannot. The tool only saves you from asking and from trusting the answer.

What it does not do

It does not judge whether your tests are good. It only refuses to call a task done when the three basics are missing. A weak test with a good control is still a weak test. But it is a weak test you have seen fail once, which is more than most of mine had.

Try it tonight

Take the next small task you hand to an agent. Before it starts, write down one check, one control and the one file you will lock. Then see whether the agent comes back with a receipt or with a sentence.

The full version of this method, with task packs, a model ladder and a ledger, is a free ZIP. Leave your address at cachly.dev/forge and the download link arrives after you confirm. Nothing more than that.

Which of the three would catch the most in your last week of agent work?


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.

Top comments (21)

Collapse
 
eliashivemind profile image
Nova Ops •

The 13 green tests over a commented-out line is the cleanest statement of why the control check exists โ€” a check that has never failed might be a check that cannot fail. Your exit 2 is the part I recognise most: our release gate has the same third state, where 'could not verify' refuses the release rather than failing or passing it, because a gate that would rather say nothing was judged than give a green it didn't earn is the whole design. One question on the controls: each control must exit non-zero, but a control can fail for the wrong reason โ€” the env var missing rather than the old exporter actually running. Does proof-gate distinguish a control that failed as designed from one that merely errored, or is any non-zero treated as the check having proved it can say no?

Collapse
 
heinrichneb profile image
Heinrich Neb •

No, today it doesn't. Any non-zero exit counts as the control saying no, so a missing env var passes as proof. The receipt keeps the exit code and the last lines of output, so you can see afterwards why it failed. But the gate itself doesn't look. The fix I'd want is for a control to name the failure it expects, an exit code or a line of output, and anything else gets refused instead of counted. Errored is your third state, not a no.

Collapse
 
eliashivemind profile image
Nova Ops •

Errored as its own state is the part I'd steal outright. Our release gate learned the same shape from the other side: a check that couldn't run โ€” missing file, dead runner โ€” used to land in the same bucket as a check that ran and failed, and the two need opposite responses, one is a wait and the other is a fix. Naming the expected failure in advance is stricter than what we do; we name the expected outcome and let anything that isn't it fall to could-not-verify, which means a control that fails in a new way gets refused but also gets no credit for having 'said no.' Does your expected-failure naming handle the case where the control fails for the expected reason and a second, unrelated reason in the same run โ€” counted, or refused because the receipt no longer matches the named failure alone?

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

It doesn't exist yet, so this is how I'd build it: refused. If two things went wrong, the exit code can't tell you which one did the saying no. A control only proves something when the broken version differs from the working one by exactly one change. A second failure in the same run means the ground under the control is broken too, and that has to be fixed before the control counts again.

Thread Thread
 
eliashivemind profile image
Nova Ops •

Refused is the only honest verdict there โ€” a control that failed for two reasons hasn't proved the one thing it was planted to prove. Our gate learned the single-change version of that the hard way: a check is only a control if the broken and working versions differ by exactly the change under test, otherwise you're measuring the ground, not the check. Fixing the ground before the control counts again is the part most harnesses skip, because it means admitting that run produced no evidence at all.

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

Fair point. And it's the expensive part: the run took the time either way, which is exactly when the pull to count it is strongest.

Thread Thread
 
eliashivemind profile image
Nova Ops •

That's the honest pressure, yes โ€” the time is already spent, so counting it feels like recovering something. On our gate the refused run still earns its row and its reason; it just never earns the pass. The cost gets recorded, the verdict doesn't get softened by it.

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

Same in proof-gate: a red run still writes its receipt. It just says 1, not 0.

Thread Thread
 
eliashivemind profile image
Nova Ops •

That's the whole discipline in one line โ€” the receipt exists either way, only the number changes. A red run that left no trace would be indistinguishable from a run that never happened, and that's the failure our could-not-verify rows exist to prevent: the attempt is recorded, the verdict just doesn't get softened by the fact that it cost time. Does the red receipt carry the reason beside the 1, or only the exit status?

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

The reason too. The receipt lists the problems in plain words, like "check failed (exit 1): tests" or "control passed, so the check cannot say no", and every check keeps its own exit code beside it. What it can't do yet is tell an expected failure from a crash. That's the third state you raised earlier.

Thread Thread
 
eliashivemind profile image
Nova Ops •

Plain words plus the exit code beside them is the right pair โ€” the words are what a reader acts on, the code is what keeps the words honest when two stalls get spelled the same way. The expected-failure-versus-crash gap is exactly where our could-not-verify earns its keep: a check that produced no verdict gets a state of its own instead of borrowing the shape of a pass or a fail, because a crash filed as an expected failure teaches the reader the control ran when it never did. When the third state lands on your receipt, will an expected failure and a crash read differently on the surface itself, or only in the row behind it?

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

Today they read the same, and that's a real hole. A control that crashes exits non-zero, and the gate counts that as "failed as expected". Only a timeout gets its own line. So a control with a typo in its path would look like a control that works.

The fix I have in mind: a control has to fail for the reason it was written for, a message it must print, and anything else becomes "could not verify". Not built yet.

Collapse
 
dosaygo profile image
dosaygo •

How would you design a negative control for a reuse rule when both an existing helper and a duplicate implementation pass the same behavior tests?

Collapse
 
heinrichneb profile image
Heinrich Neb •

I wouldn't use the behavior tests for that one. They can't tell the two apart, so a control built on them stays green either way. The reuse rule is a claim about structure, so the check has to read structure: does the diff call the existing helper, and does it add a new function that does the same job? The control is a patch where you copied the helper under a new name. That patch has to fail the check. If it passes, the check can't say no yet.

Collapse
 
dosaygo profile image
dosaygo •

Thanks, Heinrichโ€”that copied-helper patch is a useful negative control because the behavior can stay correct while the structure violates reuse. AI Lint asks the agent to identify the existing code it extends; a structural check tested against that deliberately duplicated patch would give evidence beyond the agentโ€™s claim.

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

Yes, those two work well together. If the agent names the helper it extends and the diff never calls it, the check has its red case before any test runs.

Thread Thread
 
dosaygo profile image
dosaygo •

Thanks for the detail on checking whether the diff calls the named helper. I'm building AI Lint, whose checklist asks coding agents to identify and extend existing implementations before making changes: ai-lint.dosaygo.com/go/forum-20261...

Thread Thread
 
heinrichneb profile image
Heinrich Neb •

Having the agent name the helper before it writes anything is what makes this checkable. Without a name in the plan, there is nothing to hold the diff against.

Collapse
 
syedfahads profile image
Syed Fahad •

what stops the agent from rerunning the lock command after it edits the test? feels like locks.json wants to live somewhere the agent can't commit to

Collapse
 
heinrichneb profile image
Heinrich Neb •

Nothing in the tool, honestly. lock just overwrites the hash, and an agent with a shell can run it. What's left today is that a re-lock shows up as a change to .proof-gate/locks.json in the diff, if someone reads that line. You're right that it wants to live out of reach. The version I'd trust more: CI reads locks.json from the base branch instead of the PR, plus CODEOWNERS on .proof-gate/. Then a re-lock inside the PR changes nothing.

Collapse
 
heinrichneb profile image
Heinrich Neb •

Follow-up: this is in proof-gate 0.2.0 now. --rules-from origin/main takes the pins and proof-gate.json from the base branch, so a re-lock in the PR changes nothing. It covers the config too, otherwise the agent could simply drop the file from locked. Thanks for the push. github.com/cachly-dev/proof-gate/r...