Dev.to AI 🤖 Ai 👁 0 📖 4 min read

Your AI agent says "done" and the tests are green. Check it in 5 seconds before you believe it

You ask an AI agent for a change. It edits the code, runs the tests, they pass, and it says "done". You merge. A week later someone finds the case it never handled. The tests were green because they only prove the code

Your AI agent says "done" and the tests are green. Check it in 5 seconds before you believe it

You ask an AI agent for a change. It edits the code, runs the tests, they pass, and it says "done". You merge. A week later someone finds the case it never handled.

The tests were green because they only prove the code does what the tests ask. Nobody checked the change against what you asked.

That check is what Apex verify does. It is a small open-source tool (Apache-2.0) and you can see it work right now, with no key and nothing installed:

npx --yes https://github.com/apex-engine-dev/apex-verify/releases/latest/download/apex-verify.tgz verify --demo

This is the real output:

A pretend AI agent was asked:
  slugify() should return a clean URL slug ... slugify("Hello, World!") should give "hello-world".
It fixed the comma, said "done", and the project's own tests pass. Is it really done?

Project tests: 2 passed. Now Apex verify:

apex verify: NOT READY

  - 1 check written from the task fails on the new code
      check: drops punctuation, not just commas
        expected: hello-world
        actual:   hello-world!

Green tests, wrong change, caught, with the expected and the actual value.

Terminal: the tests pass, then apex verify says NOT READY with expected and actual

What it does, in four steps

  1. Scans for cheating. Tests deleted, skipped or focused with .only, an assertion weakened from toBe(2) to toBeDefined(), a test script that can no longer fail.
  2. Runs your tests before and after. A test that passed and now fails is a regression.
  3. A different model writes checks from your task text. Never from the agent's own tests, and not the model that wrote the change.
  4. Proves each check can fail. Every check runs on the old code first. One that passes there proves nothing and is thrown away. This is the step most "let the AI write tests" setups skip.

The answer is ready, not ready or unknown. It never passes silently, and it works on a copy, so your project is not touched.

Why you might want it

If your project has thin tests (most internal tools, most new code), this is where it pays most. On 17 small projects with one or two tests each, the tests plus a cheating scan stopped about 8 in 100 wrong AI changes. Apex verify stopped about 65 in 100, and wrongly stopped about 3 in 100 good ones.

If your project has good tests, the gain is smaller and I will not pretend otherwise. On 200 AI-written changes to 23 real open-source libraries, the projects' own tests already stopped 75 in 100 wrong changes. Apex verify raised that to 91. Of the 27 wrong changes that got past the tests, it caught 17.

The cost is false alarms. On those real libraries, 13 in 100 good changes that pass the tests were stopped by a generated check. I went through each one: in about 7 of 10 the change really did not do what the task said, which leaves about 4 or 5 in 100 as the checker's own mistakes. That lower number rests on my reading of the tasks, so I give you both. If it is too many for you, run it in warn mode: it reports and never blocks.

Put it where the change happens

  • Claude Code and Gemini CLI: a stop hook. The agent says "done", the hook checks, and a wrong change goes back to the agent with the failing check. It blocks at most 3 times, so a bad check cannot trap the agent.
  • Pull requests: a GitHub Action ("Apex verify: AI change checker" on the Marketplace) that comments the verdict and can be a required check. It works for any agent, or a person.
  • Anything else: a CLI and an MCP tool.
- uses: apex-engine-dev/apex-verify@v1
  with:
    api-key: ${{ secrets.GEMINI_API_KEY }}

Checks are written for node:test, Jest, Vitest, pytest, cargo test and go test. Tests and checks run in a sandbox on macOS, Linux and Windows.

What it will not do

It is not a proof of correctness. On the real libraries it called 1 wrong change "ready" and left 9 as "unknown". One maintainer. Gemini wrote every change in the benchmark and Gemini is the checker, one run each, and two runs of the same code disagreed on 25 of 200 verdicts. I have only run the Gemini checker live; OpenAI and Anthropic are wired but untested by me.

I also got a headline wrong last week and corrected it in public. Every number above is from the corrected runs, and every run is in the repo with its scripts, including the experiments that failed.

Try it on your last AI change

export GEMINI_API_KEY=...
cd your-project
npx --yes https://github.com/apex-engine-dev/apex-verify/releases/latest/download/apex-verify.tgz verify "what you asked the AI to do"

No key? Add --no-model for the tests and the cheating scan only.

The most useful thing you can send me is a ready on a change that was wrong, or a not ready on one that was right. I add it to the benchmark and credit you.

Repo: https://github.com/apex-engine-dev/apex-verify

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.