You know that thing where you explain your bug to a rubber duck and suddenly you see the problem? Yeah, that actually works. And it works way better when the duck can read code and ask smart follow-up questions.
Why This Matters
Traditional rubber duck debugging (explaining your problem out loud to an inanimate object) forces you to articulate what your code does, not what you think it does. That gap? That's where 80% of bugs live.
An AI like Claude takes this further. It doesn't just listen—it reads your code, spots patterns you missed, and asks the questions you should've asked yourself.
How to Use Claude as a Debugging Partner
Paste your function with context:
I'm getting an off-by-one error in this pagination function.
When I hit page 3, it shows results from page 2 and 4.
Here's the code:
[your code here]
Don't just show the broken line. Show:
- The function it lives in
- What calls it
- What you expected vs what actually happened
Claude will ask clarifying questions like:
- "What's the starting value of
currentPage?" - "Is
itemsPerPagealways 10?" - "Where's the API response validation?"
These questions force you to think, not just copy-paste a fix.
Real Example: Async/Await Gotcha
I was building a data pipeline that processed files in parallel. Looked like this:
files.forEach(async (file) => {
const data = await processFile(file);
results.push(data);
});
console.log(results); // Always empty
When I showed this to Claude and said "why is results empty?", it asked: "Does forEach wait for async callbacks?"
Boom. That's the answer. forEach doesn't wait. I needed Promise.all(). Without being forced to explain it, I would've wasted 20 minutes adding logging statements.
The Rubber Duck Rules
- Explain, don't ask for the fix. Say "this should return 5 items but returns 3" not "fix my code"
- Provide actual error messages. Stack traces matter
- Include the context. A function without its caller is useless
- Ask it to trace through your logic. "Walk me through what happens when X=5"
When Not to Use This
- Ultra-simple bugs (use a debugger)
- Issues with external APIs (post to their forums first)
- Performance problems (profilers are better tools)
Use Claude for logic bugs, edge cases, and the stuff that makes you feel dumb when you finally spot it.
Bonus: Learn as You Debug
After Claude helps you see the bug, ask:
- "Why is this a common mistake?"
- "How do experienced devs avoid this?"
- "Any patterns I should follow?"
This turns debugging into learning. You won't make the same mistake twice.
Want more practical AI tips for developers? Check out LearnAI Weekly newsletter for real strategies, not hype.
The next time you're stuck, don't rubber duck—rubber duck with an AI that actually listens. Your future self will thank you.
Top comments (0)