For code that works but is under-tested. Each round adds a few targeted tests for the least-covered lines, re-measures, and stops the moment the agreed threshold holds.
Typical run: 20–45 min typical \u00b7 Copy any prompt box and hand it to your agent as-is.
Loops / Coverage Until Threshold
Set the coverage target and scope in one message. Example: "Target: 80% lines and 70% branches on src/checkout/**. Measure with npm run coverage -- --scope=src/checkout. Report the current numbers and the 3 least-covered files, then stop. Do not write tests yet."
Read the latest coverage report. List the top 10 uncovered lines or branches in the scoped files, grouped by file. Do not write code yet — just report the list, then stop.
Write at most 3 focused tests covering items from the uncovered list. Each test name must reference the behavior it covers. Run only the scoped test files, paste the pass/fail result, then stop.
Re-run the scoped coverage command. Report lines %, branches %, and whether the target is met. List what is still uncovered, then stop.
Review the tests added in this loop. Every test must fail if the code it covers is broken (mutate or comment out one line to check at least 2 tests). Delete or fix any test that passes regardless. Report which tests were checked, then stop.
Add or update the coverage gate (CI config or package.json script) so the agreed target is enforced on the scoped files. Run the gate once to prove it passes. Paste the config snippet and the passing output, then stop.
Symptom: coverage climbs but bugs still slip through. Guardrail: require the break-it check in step 5 — a test that cannot fail is deleted.
Symptom: a 30-minute loop becomes a full-suite rewrite. Guardrail: freeze the file scope in step 1; out-of-scope files need a new loop.
Symptom: threshold passes once, fails on retry. Guardrail: run the new tests 3 times before locking; any flake is fixed or removed.