"It Doesn't Work!" - How to Write AI Prompts That Actually Solve Bugs

We've all done it. After hours of frustration, you paste a chunk of code into an AI chat and desperately type, "Why is this broken?" The result? A generic, unhelpful guess that wastes even more time.

The truth is, an AI is not a mind-reader. It's a powerful tool that needs the right input. To get great debugging help, you need to learn how to "file a perfect bug report" for your AI assistant. This guide will teach you the E-C-O framework to get precise, actionable solutions and cut your debugging time in half.

The E-C-O Framework: The Perfect Bug Report for AI

Stop asking vague questions. Start providing structured context. The E-C-O framework ensures you give the AI everything it needs to think like a senior developer.

The Ultimate Debugging Prompt Template

This template puts the E-C-O framework into action. Fill it out, and watch the quality of AI's answers skyrocket.


You are a Senior Software Engineer and an expert debugger. I'm facing an issue in my code and need your help.

1. Environment & Error:
- Language/Framework: [e.g., Python 3.9, React 18]
- Full Error Message: [Paste the complete error message and stack trace here]

2. Code & Context:
- What the code is supposed to do: [Briefly explain the goal of this function/component.]
- The problematic code snippet:
[Paste the minimal, relevant code snippet here]

3. Objective & What I've Tried:
Expected Outcome: [Describe what should happen if the code worked correctly.]
What I've already tried: [List the steps you've taken]
Your Task: Analyze the problem and provide:
- A clear explanation of the likely cause of the error.
- A corrected version of the code snippet.
- Any alternative approaches or best practices to consider.
      

Bad Prompt vs. Good Prompt: A Python Example

The Bad, Vague Prompt:


My python code for calculating the average is giving an error.
def calculate_average(numbers):
    total = sum(numbers)
    return total / len(numbers)

print(calculate_average("1,2,3"))
      

The Good, E-C-O-based Prompt:


You are a Senior Software Engineer...
1. Environment & Error:
Language/Framework: Python 3.9
Full Error Message:
TypeError: unsupported operand type(s) for +: 'int' and 'str'

2. Code & Context:
What the code is supposed to do: This function should take a list of numbers and return their average.
The problematic code snippet:
def calculate_average(numbers):
    total = sum(numbers)
    return total / len(numbers)
I'm calling it with a string, which might be the issue.
print(calculate_average("1,2,3"))

3. Objective & What I've Tried:
Expected Outcome: The function should print 2.0.
What I've already tried: I know the error is a TypeError, so the data types are wrong. I think I need to convert the string to a list of numbers, but I'm not sure the best way.
Your Task: Analyze the problem...
      

Ready to squash bugs faster?

Treat your AI like a colleague, not a magic box. Give it good context, and it will give you great solutions. Use our Programming tools to build your next structured prompt!

Go to Programming Tools