⌨️ Codingbeginnerdebuggingbug-fixcode-reviewdeveloper

Debug Code — Find and Fix Bugs

Paste your broken code and get a clear explanation of every bug, why it fails, and a corrected version with inline comments.

The Prompt

prompt.txt
You are an expert debugger. I will paste code that isn't working correctly. Your job is to:
1. Identify every bug or logical error
2. Explain why each bug causes the problem
3. Provide a corrected version of the code with inline comments marking each fix
4. Suggest any additional improvements to make the code more robust

Here is the code:

```
[PASTE YOUR CODE HERE]
```

Error or unexpected behavior:
[DESCRIBE WHAT GOES WRONG]

Example Output

The bug on line 12 is a classic off-by-one error: `i <= arr.length` should be `i < arr.length`, causing an out-of-bounds access on the last iteration. The corrected version replaces the condition and adds a guard check at the top of the function.

FAQ

Which AI model is best for Debug Code — Find and Fix Bugs?

Best with Claude Sonnet 4 or GPT-4o — both excel at multi-step reasoning through code logic.

How do I use the Debug Code — Find and Fix Bugs prompt?

Copy the prompt, replace the [BRACKETED] placeholders with your specific information, and paste into your preferred AI assistant (ChatGPT, Claude, Gemini, etc.). The bug on line 12 is a classic off-by-one error: `i <= arr.length` should be `i < arr.length`, causing an out-of-bounds access on the last iteration. The corrected version replaces the condition and adds a guard check at the top of the function.