mcpField

Test Until Green

FeaturedOn demand
TestingUp to 10 rounds

About Test Until Green

A manually started loop that runs npm test, reads the failures, changes the code and runs the suite again. It repeats for up to 10 rounds and is listed for Cursor and Claude Code.

Key features

  1. 01Manual trigger
  2. 02Capped at 10 rounds
  3. 03Single check command: npm test
  4. 04Supports Cursor and Claude Code

Use cases

  1. 01Fixing a failing suite after a refactor
  2. 02Clearing failures after a dependency upgrade
  3. 03Confirming a feature branch is green before review
Goal
Every test run by npm test passes.
Exit when
Stop when npm test exits with code 0, or after the 10-round limit is reached.
Between iterations run
npm test

Launch prompt

Paste into Cursor / Claude Code. The agent repeats the steps below until the exit condition is met.

prompt.md
Start the "Test Until Green" loop.
Goal: Every test run by npm test passes.
Max iterations: 10.
Step 1: Run tests — Execute npm test and note which cases fail. If the exit code is 0, nothing needs changing and the loop ends. `npm test`
Step 2: Diagnose failures — Read the error output and stack traces to locate the code behind each failing case, and decide whether the implementation or the test expectation is wrong.
Step 3: Apply a fix — Make the smallest change that addresses the confirmed cause, without touching unrelated files.
Step 4: Re-run tests — Execute npm test again and judge by the exit code: 0 ends the loop, anything else carries the new failures into the next round. `npm test`
Between iterations run: `npm test`
Exit when: Stop when npm test exits with code 0, or after the 10-round limit is reached.

Steps

Each round runs in order; if the exit condition isn’t met, another round starts, up to 10.

01
Run tests

Execute npm test and note which cases fail. If the exit code is 0, nothing needs changing and the loop ends.

$npm test
02
Diagnose failures

Read the error output and stack traces to locate the code behind each failing case, and decide whether the implementation or the test expectation is wrong.

03
Apply a fix

Make the smallest change that addresses the confirmed cause, without touching unrelated files.

04
Re-run tests

Execute npm test again and judge by the exit code: 0 ends the loop, anything else carries the new failures into the next round.

$npm test
Not met → next roundExits when met

Supported agents

Coding agents that can run this loop directly.

Cursor
Claude Code

Comments

Markdown supported