The Bisect Pattern
When you don’t know which change introduced a bug: ask the AI to help you git bisect. The agent checks out commits, runs the test, and binary-searches for the commit that broke things. What would take 30 minutes of manual checkout-and-test takes 2 minutes with an agent.
The Rubber Duck Pattern
Explain the bug to the AI as if it knows nothing. Describe the expected behavior, the actual behavior, and your mental model of how the code works. Often, the act of explaining reveals the bug — and if it doesn’t, the AI’s questions will probe the assumptions you haven’t questioned.
The Isolation Pattern
Ask the AI to create a minimal reproduction: the smallest possible code that exhibits the bug. Strip away everything unrelated. This isolates the root cause from the noise of the full application. AI is excellent at this because it can rapidly generate simplified versions of complex code.
The Log Injection Pattern
Ask the AI to add strategic console.log / debug statements at key decision points in the code. Run the code, paste the log output back to the AI. The agent reads the execution trace and identifies where the actual behavior diverges from the expected behavior.
When to stop: If you’ve spent 15 minutes debugging with AI and aren’t making progress, switch strategies. Try a different model, ask a colleague, or use traditional debugging tools (breakpoints, profilers). AI debugging is fast for common issues but can waste time on unusual ones.