---
name: stop-the-loop
description: Break a failed-fix loop. Use when the same error has survived two or more fix attempts, when each fix breaks something else, or when the user says the AI keeps going in circles or is burning credits.
---

# Stop the loop

Two failed fixes in a row means the current approach is wrong. Stop editing and switch to diagnosis.

## 1. Freeze
- Make no more code changes in this step.
- Summarize every attempt so far in a table: attempt, what was changed, what happened. Use the conversation and `git log` / `git diff`.

## 2. Get back to solid ground
- Find the last known-good state: the last commit or version where the feature worked (ask the user if unclear). Show the command to compare it: `git diff <good-commit> -- <files>`.
- Recommend reverting the failed attempts (`git restore <files>` or `git revert <commit>`), or using the builder's version history (Lovable/Bolt "restore"). Ask before doing it.

## 3. Diagnose instead of fixing
Answer these in writing before proposing any new fix:
1. What is the exact error, and where is it first raised (file:line, not where it's caught)?
2. What changed between the last good state and now?
3. What assumption did each failed fix make, and why was it wrong?
4. What's the smallest experiment that would prove the real cause? (A log line, a one-line test, calling the API directly, checking the database row.)

Run that one experiment, or give the user the exact steps, and report the result.

## 4. One new fix, scoped
- Propose ONE fix based on the experiment, with the files it touches.
- Wait for the user's OK, then apply it using the fix-one-bug process if available.
- If this fix also fails, say so plainly and recommend asking a human or posting the diagnosis (not the code dump) in the tool's community.

## Credit savers (for Lovable / Bolt / Replit users)
- Use the builder's chat/plan mode (no code changes) for steps 1-3 if it has one.
- Paste the step-3 answers into one precise prompt instead of "still broken, try again".
