Build Until Green
FeaturedOn demandAbout 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
- 01Manual trigger, so the user decides when it starts
- 02Judges success by the exit code of npm run build
- 03Capped at 10 rounds to avoid endless retries
- 04Supports Cursor and Claude Code
Use cases
- 01Build failure after a dependency upgrade
- 02Type or bundling errors after merging a branch
- 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.
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.
Execute npm run build and note the first error reported. If it exits 0, the loop ends.
npm run buildTrace the error to a specific file and cause, then make a targeted change without touching unrelated code.
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 buildSupported agents
Coding agents that can run this loop directly.