Iterative Prompting: Change One Thing

/

Your first AI prompt will not produce perfect code. Mine never does. The skill is not writing better prompts — it is refining the output through iterations. Here is the exact iteration loop I use.

What is the most effective iteration pattern for AI code?

One variable change per iteration. Change the prompt, regenerate, test. Do not change the prompt and the spec and the constraints at the same time. I changed two things at once once and spent 4 hours debugging. Now I isolate one variable per iteration and the fix rate is 90% within 3 iterations.

How do you know when to stop iterating and start over?

After 5 iterations without progress. The AI is stuck on a wrong approach. Delete the session, write a fresh spec, and start over. I wasted 2 hours on 12 iterations of a broken function. A fresh session with a better spec solved it in 10 minutes. Starting over is faster than forcing a broken approach.

References

  1. Cursor AI Review
  2. Claude Code Review
  3. AI Code Validation Guide

Leave a Reply

Your email address will not be published. Required fields are marked *