The Exit Criteria Pattern: Know When to Stop Iterating with AI
Here's a pattern I see constantly: a developer asks AI to refactor a function, gets a decent result, then spends 45 minutes on follow-up prompts trying to make it "perfect." The final version is ba...

Source: DEV Community
Here's a pattern I see constantly: a developer asks AI to refactor a function, gets a decent result, then spends 45 minutes on follow-up prompts trying to make it "perfect." The final version is barely better than the third iteration — and sometimes worse. The problem isn't the AI. It's that you never defined what "done" looks like. The Pattern Before you start any AI-assisted task, write exit criteria. Literally. In your prompt. Task: Refactor the processOrder function to handle partial failures. Exit criteria (stop when ALL are true): - [ ] Each payment/inventory/notification step can fail independently - [ ] Failed steps are logged with enough context to retry manually - [ ] The function returns a result object showing which steps succeeded/failed - [ ] No step takes longer than 5 seconds (timeout handling) - [ ] Existing tests still pass When all boxes are checked, you're done. Ship it. Move on. Why Developers Over-Iterate Three reasons: Perfectionism masquerading as diligence. "Wh