For the messy middle of a change, when the compiler or bundler is red and you want a tight fix-and-rerun cycle that stops only when the build passes clean.
Typical run: 10–30 min typical \u00b7 Copy any prompt box and hand it to your agent as-is.
Loops / Build Until Green
Run npm run build (or your build command) once with no code changes. Save the complete log to build-baseline.log. Report the error count and the first error verbatim, then stop. Do not fix anything yet.
Read build-baseline.log. Fix ONLY the first error. Do not touch unrelated files. Explain the fix in one sentence, then stop.
Run the build again and save the log to build-02.log (then build-03.log, and so on). Report: errors fixed, errors remaining, and the new first error. Stop after reporting.
Compare the latest build log against the previous one. If any NEW error appeared, revert the last change and try a smaller fix for the same error. Stop after reporting the comparison.
Run the build twice in a row with no code changes between runs. Both must pass with zero errors and zero warnings treated as errors. Paste both exit codes, then stop.
Write a 5-line summary: what broke, what fixed it, which files changed, how many cycles it took, and what to watch next time. Keep it under 120 words, then stop.
Symptom: a one-line type error turns into a 12-file refactor. Guardrail: forbid touching more than 3 files per cycle and require the error log quote in every reply.
Symptom: green locally, red in CI. Guardrail: one cycle must be a clean build (clear cache / fresh install) before you declare victory.
Symptom: zero errors but 40 new warnings. Guardrail: treat warnings as errors for the loop, or list every new warning in the loop note for explicit sign-off.