The pull request looks perfect. The agent built the feature, wrote the tests for the feature, and every check on the page is green. My cursor is on merge, and I stop on one question: who decided what those tests should check?
The same agent did. It read its own code and wrote tests confirming that the code does what the code does. When one agent writes both the code and its tests, a green run mostly proves the two agree with each other, not that either matches what you wanted. The tests that prove something are written, or at least approved, before the agent starts, from the behaviour you asked for.
Green was never the proof
This isn't new, and it isn't about AI. Martin Fowler wrote long ago that test coverage is of little use as a numeric statement of how good your tests are. High coverage is easy to reach with low-quality tests, and weak tests can be weak in ways coverage can't detect. A green run is the same kind of signal. Nothing failed, which says very little about whether the right things were checked.
Fowler's use for coverage points the other way: finding the parts of a codebase nobody tests at all. Missing tests tell you something. Green, on its own, mostly doesn't.
Why an agent makes it worse
In my experience, a person writing tests after their own code still has the ticket in their head. An agent testing its own diff starts from the diff. If it misread the requirement, it misread it twice: once in the code, once in the test that checks the code. Both agree. Both are wrong. The dashboard is green.
Before
Tests the agent wrote after its code
- Derived from the code that already exists
- Pass because they describe that code
- A misread requirement gets copied into both
After
Tests written or approved before it started
- Derived from the behaviour you want
- Fail until the code does that behaviour
- A misread requirement shows up as red
The order is the point
Test-driven development has said this for years. Fowler describes it as writing a test for the next bit of functionality first, then writing the code until the test passes. The test exists before the code, so it defines what passing means. The code has to meet it. It can't shape it.
So I think of it this way: a test written after the code describes it, and a test written before it sets the bar. With agents I don't always type the test myself. What matters is that it's written or approved before the agent starts, from the behaviour, and that the agent can't quietly bend it to fit.
A quick audit of your green checks
- 1List the tests behind the featureNot the whole suite. The tests that cover the thing you're about to ship.
- 2Mark who wrote each oneYou, a teammate, or the agent in the same change as the code.
- 3Mark whenBefore the code existed, or after. Your history shows which commit added the test and which added the code.
- 4Count only the ones that came first as proofKeep the rest. They'll catch regressions later. They just don't prove the feature does what you asked.
- 5Break the code on purposeFlip a condition and run the suite. That's mutation testing by hand: a small change to the program, a mutant. A suite that kills it can find that kind of fault. A surviving mutant usually means it can't, and a green run would never have told you.
The rule: the agent adds, people own
The agent may add as many tests as it likes. The tests that define the behaviour stay human-owned: the agent can propose a change to them, but it can't make one alone.
On GitHub this is cheap to enforce. A CODEOWNERS file names the people or teams responsible for parts of a repository, so the folder holding your behaviour tests gets an owner. Code owners are requested for review automatically when a pull request touches what they own, and a branch protection rule can require their approval before it merges. An agent that edits a behaviour test to turn it green now needs a person to say yes.
Try the audit on the next pull request an agent opens. If none of its tests came before the code, you know what that green is worth, and you know which test to write first next time.
Free checklistThe Done Gate: 5 proofs before a ticket closesFor mobile teams shipping with AI agents: the five proofs a ticket carries before anyone may call it done, why each one exists, and a template to paste into your pull requests.Get the checklist Building with AI?Let's talk about your appBook a free intro call


