← Tech, Coding & Troubleshooting

Debugging · Problem solving · Thinking

How to Use AI as a Rubber Duck for Debugging

Rubber duck debugging is a real technique: programmers explain their code out loud to a rubber duck, and in the act of articulating the problem, often discover the solution themselves. AI makes a far better rubber duck -- it listens, asks clarifying questions, and actually responds. When you are stuck on a problem and cannot see it clearly, talking through the logic with AI forces you to articulate your assumptions, surface what you actually do not understand, and often reveals the bug before AI has said anything helpful at all. It is also useful for thinking through architecture decisions, talking through the trade-offs between approaches, and getting a sanity check on your reasoning before committing to a solution.

5 Best Prompts for Rubber Duck Debugging to Ask Claude or ChatGPT

Copy any prompt below and paste it directly into your AI of choice.

  1. Prompt 01 · Talk through the problem

    "I am going to explain a bug I am stuck on. Please listen, ask me clarifying questions, and help me think through it -- do not just give me the answer immediately. I want to reason through it out loud first. Here is the situation: [describe your code and what is happening]."

    Best for: the stuck feeling where you suspect that articulating the problem clearly will reveal the solution.

  2. Prompt 02 · Question my assumptions

    "I am debugging [problem] and I think the issue is [your hypothesis]. Can you ask me probing questions about my assumptions -- things I might be taking for granted that could be wrong -- rather than just telling me if I am right or wrong?"

    Best for: situations where you have a hypothesis about the bug but want to stress-test it before going down a rabbit hole.

  3. Prompt 03 · Explain your code back to me

    "Here is my code: [paste]. Can you explain back to me what you think it does, step by step? I want to see if your understanding matches my intention, because the mismatch might reveal where the bug is."

    Best for: discovering bugs that exist because the code does not do what you thought it did.

  4. Prompt 04 · Think through architecture

    "I am trying to decide between these two approaches to [problem]: [describe approach A] and [describe approach B]. Can you help me think through the trade-offs by asking me questions about my requirements, constraints, and priorities -- rather than just recommending one?"

    Best for: architecture decisions where talking through the requirements reveals what the right answer actually is.

  5. Prompt 05 · Help me get unstuck

    "I have been stuck on this problem for [time] and I cannot make progress: [describe]. I have tried [what you have tried]. Can you help me break out of my current thinking by suggesting a completely different angle, a simpler version of the problem to solve first, or a question I have not asked yet?"

    Best for: the dead end where you need someone to help you think differently, not just check your existing work.