Blog · 2026-08-02

Patch coverage for coding agents

Here's the loop I wanted when I built tested.dev. An agent rewrites a session refresh path, runs the tests, and they pass. Before opening the PR it runs tested check, which reads the coverage file the test run just wrote, diffs the branch against its base (origin/main by default), and exits 1, because some of the lines it just added never ran:

src/auth/session.ts:12-21

The exit code is the part that matters. The agent is still in the session that wrote those lines. The diff and the intent are loaded, so closing the gap costs one more round: write the test, re-run, tested check exits 0, open the PR. The gap gets fixed by the thing that made it, minutes after it was made, instead of in review after CI or in a debugger three months later. That's what I meant in the last post by closing gaps with the agents.

The mechanics

There isn't much machinery behind it. tested check runs with no account: it reads the coverage your runner already writes (coverage/coverage-final.json from Vitest or Jest) and grades only the new executable lines on the branch. The default floor is 80%; override it with --fail-under for a run, or failUnder in .tested.yaml for the repo. tested diff is the same math without the gate. It prints the report, exits 0, and takes --json when your agent wants structure. There's an MCP server if your agent speaks that instead.

What doesn't gate

The same run feeds the parts that don't gate. Hand it a JUnit file and flaky tests land on the Tests tab and suite timing on Performance. The demo shows two flakes right now. Neither fails a PR, on purpose: I want to see a flake the day it appears, and I don't want a required check that people learn to re-run until it goes green. Coverage stays the only gate.

Enforcement

On a laptop, though, tested check is only advice. An agent can skip it, and a human on a deadline will. The next post is the enforcement: the same check as a GitHub job you mark required, so a gap that slips past the session still can't merge.