mcpField

Build Until Green

FeaturedOn demand
TestingUp to 10 rounds

About Build Until Green

This loop brings a project's production build back to a working state. Each round runs npm run build, edits code based on the errors, then rebuilds to confirm the result, for at most 10 rounds.

Key features

  1. 01Manual trigger, so the user decides when it starts
  2. 02Judges success by the exit code of npm run build
  3. 03Capped at 10 rounds to avoid endless retries
  4. 04Supports Cursor and Claude Code

Use cases

  1. 01Build failure after a dependency upgrade
  2. 02Type or bundling errors after merging a branch
  3. 03Confirming the production build works before a release
Goal
The production build succeeds and npm run build completes without errors.
Exit when
Stop when npm run build exits 0, or after 10 rounds if it still fails.
Between iterations run
npm run build

Launch prompt

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

prompt.md
Start the "Build Until Green" loop.
Goal: The production build succeeds and npm run build completes without errors.
Max iterations: 10.
Step 1: Run the build — Execute npm run build and note the first error reported. If it exits 0, the loop ends. `npm run build`
Step 2: Diagnose and fix — Trace the error to a specific file and cause, then make a targeted change without touching unrelated code.
Step 3: Re-run the build — Execute npm run build again and check whether the earlier error is gone and no new ones appeared. If it still fails, continue to the next round. `npm run build`
Between iterations run: `npm run build`
Exit when: Stop when npm run build exits 0, or after 10 rounds if it still fails.

Steps

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

01
Run the build

Execute npm run build and note the first error reported. If it exits 0, the loop ends.

$npm run build
02
Diagnose and fix

Trace the error to a specific file and cause, then make a targeted change without touching unrelated code.

03
Re-run the build

Execute npm run build again and check whether the earlier error is gone and no new ones appeared. If it still fails, continue to the next round.

$npm run build
Not met → next roundExits when met

Supported agents

Coding agents that can run this loop directly.

Cursor
Claude Code

Comments

Markdown supported