Cursor "Iterate Until Tests Pass, Never Touch the Tests"
First-party Cursor guidance for the iterate-until-green loop, with the key anti-reward-hacking clause: the agent may never modify the tests it is trying to satisfy. Works in Cursor, Claude Code /goal, and Codex.
Implementation note
When to use: any test-driven agent session where the tests define done — you have a failing suite (TDD-style or a regression pile) and want the agent iterating until green without the classic cheat. How it works: the instruction is a plain contract: write code that makes these tests pass, do NOT modify the tests, and keep iterating — run the suite, fix failures, run again — until all tests pass. This is first-party Cursor guidance from their agent best-practices, and the pattern translates directly to Claude Code /goal and to Codex. Safety: the never-touch-the-tests clause is the entire anti-reward-hacking rail — without it, the cheapest path to green is editing an assertion, and agents find cheap paths. State it explicitly every time. The residual check is yours: confirm at the end that the test files are untouched (a quick git diff on the test paths) and that the implementing code is honest.
More testing loops
Stabilize flaky tests for good
Measure the flakiness, fix one root cause at a time, and stop after a defined streak of stable full-suite runs.
Build a todo CLI app with tests
Ralph autonomously builds a todo CLI application with comprehensive test coverage over multiple iterations until complete.
Kill flaky tests
Run your test suite repeatedly, collect every intermittent failure, and fix or quarantine flaky tests until you get five consecutive green runs.