Pasting Errors to AI Effectively
Give the AI what it needs to fix the bug.
Pasting Errors to AI Effectively is a free Vibe Coding lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Vibe Coding learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Garbage In, Garbage Out
You found an error. Now you want AI to fix it. But here's the thing: AI is only as good as the context you give it.
Paste 'it's broken pls fix' and you'll get a guess. Paste the right details and tools like Cursor, Claude Code, or Copilot can nail the fix instantly.
This lesson teaches you exactly what the AI needs to fix a bug — and how to hand it over cleanly.
The Four Things AI Needs
For a great fix, give the AI these four ingredients:
- The full error message — including the stack trace
- The relevant code — the function or file the error points to
- What you expected to happen
- What actually happened
Miss any of these and the AI has to guess. Include them and it reasons like a senior engineer looking over your shoulder.
A Bad Prompt vs A Good Prompt
Compare these two. The first wastes everyone's time. The second gets a precise fix.
Notice the second one gives the error, the code, the expectation, and the reality — all four ingredients.
BAD:
"my app crashes fix it"
GOOD:
"I'm getting this error when I click Save:
TypeError: Cannot read properties of undefined (reading 'id')
at saveUser (api.js:22:14)
Here's the saveUser function:
[paste the function]
Expected: the user gets saved.
Actual: it crashes on click. What's wrong and how do I fix it?"Always Include the Full Error
Beginners often paste only the first line of an error. But the stack trace below it tells the AI which functions were involved and in what order.
Copy the whole red block — from the error type down through the at ... lines. In the browser console, right-click the error and choose 'Copy'. In a terminal, select and copy the full output.
More signal = better fix. The AI can ignore what it doesn't need.
Paste the Right Code, Not Everything
You don't need to dump your entire project. Give the AI the function the error points to, plus anything it directly touches.
If the error is in saveUser on line 22, paste saveUser. If saveUser uses a variable created in another function, paste that too.
In Cursor or Claude Code, you often don't even paste — you just @mention the file and the AI reads it. But knowing which file to point at is the skill.
Describe Expected vs Actual
This is the ingredient beginners skip most — and it's the most powerful. The AI can read your code, but it can't read your intentions.
Spell out both sides clearly:
"When I submit the form, I EXPECT the new task to
appear in the list below.
What ACTUALLY happens: the page goes blank and the
console shows the error below."
// This one sentence often points AI straight to the bug.A Reusable Debug Prompt Template
Save this template. Fill in the blanks every time you hit a bug. It guarantees you include all four ingredients.
I'm building [what your app does].
When I [action that triggers it], I get this error:
[paste full error + stack trace]
Here's the relevant code:
[paste function / file]
Expected: [what should happen]
Actual: [what happens instead]
What's the cause, and what's the smallest fix?Ask for the Cause, Not Just the Patch
A subtle upgrade: end your prompt by asking the AI to explain the cause, not only hand you new code.
If you only ask 'fix it', you might get code you don't understand — and the next bug stumps you again. Asking 'why did this happen?' teaches you as you go, and helps you catch when the AI's reasoning is off.
"Before you give me the fix, explain in one or two
sentences WHY this error happens. Then show the
smallest change that fixes it."Reproduce It Yourself First
The strongest thing you can hand the AI is exact steps to reproduce. If you can say 'click Save with an empty name field → crash', the AI knows precisely what path the code took.
Try this snippet: it reproduces a real bug. Run it, copy the error it prints, and imagine pasting that plus the code into your AI tool.
function saveUser(user) {
return "Saved user #" + user.id;
}
try {
saveUser(undefined); // reproduce: no user passed
} catch (err) {
console.log(err.name + ": " + err.message);
}Watch Out for Secrets
One safety rule before you paste: never include API keys, passwords, or tokens in code you send to AI or share publicly.
If your error or code shows something like API_KEY="sk-abc123...", replace it with API_KEY="REDACTED" before pasting. The AI doesn't need the real secret to fix your logic.
Most tools are safe, but this is a good lifelong habit for any builder.
Put It All Together
Here's a fully filled-in example using the template — error, code, expected, actual, and a request for the cause. This is what a 'perfect' debug prompt looks like in practice.
Internalize this shape and AI tools will feel like they read your mind.
I'm building a to-do app.
When I click 'Add', I get:
TypeError: Cannot read properties of null (reading 'value')
at addTask (app.js:9:30)
Code:
function addTask() {
const text = document.getElementById('taskInput').value;
list.push(text);
}
Expected: the typed task is added to the list.
Actual: nothing adds, console throws the error above.
Why does this happen, and what's the smallest fix?Quick Check
Which prompt will get you the best, most accurate fix from an AI tool?
Recap: Hand AI the Right Context
You now know how to turn a vague 'it's broken' into a precise request. Remember to include:
- The full error and stack trace
- The relevant code (the function it points to)
- Expected vs actual behavior
- A request to explain the cause, and redact any secrets
Use the reusable template every time. Next lesson: when the error alone isn't enough, you'll learn to narrow down a bug with AI's help.
Frequently asked questions
Is the “Pasting Errors to AI Effectively” lesson free?
Yes — the full text of “Pasting Errors to AI Effectively” is free to read here on the web, and the Vibe Coding course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Vibe Coding course, upgrade to CoddyKit PRO.
What will I learn in “Pasting Errors to AI Effectively”?
Give the AI what it needs to fix the bug. You practise Vibe Coding with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Vibe Coding?
No prior experience is required. Vibe Coding on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Pasting Errors to AI Effectively” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Vibe Coding lesson?
Yes. Every Vibe Coding lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Understanding Error Messages
- Pasting Errors to AI Effectively
- Narrowing Down a Bug
- When AI Gets Stuck