The "Rubber Duck" Prompt: What to do when the AI gets stuck in an infinite error loop.

We’ve all been there: The AI gives you code. It throws an error. You paste the error. The AI apologizes, gives you "fixed" code. The same error happens.

If you just keep pasting the error, the AI gets trapped in a context loop and will keep giving you the same broken garbage. Break the loop with the Rubber Duck Pivot:

Stop pasting the error and type this instead:

Forcing the LLM to explain the logic in plain English resets its context drift. Once it explains it, you'll often see exactly where it's confused, and you can say, *"Ah, okay. Now rewrite just that one function using that logic."*We’ve all been there: The AI gives you code. It throws an error. You paste the error. The AI apologizes, gives you "fixed" code. The same error happens.If you just keep pasting the error, the AI gets trapped in a context loop and will keep giving you the same broken garbage. Break the loop with the Rubber Duck Pivot:Stop pasting the error and type this instead:"Stop writing code for a second. Let's think step-by-step. Explain to me like I am 10 years old exactly what you think this function is doing, and why you think it's failing. Do not write any code until I tell you to."Forcing the LLM to explain the logic in plain English resets its context drift. Once it explains it, you'll often see exactly where it's confused, and you can say, "Ah, okay. Now rewrite just that one function using that logic."

Posted Jun 6, 2026, 9:40 PM UTC

10
Loading comments…