Colando erros na IA de maneira eficaz
Forneça à IA o que ela precisa para corrigir o bug.
Colando erros na IA de maneira eficaz é uma aula grátis de Vibe Coding no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Vibe Coding, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Vibe Coding inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
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.
Perguntas Frequentes
A aula “Colando erros na IA de maneira eficaz” é grátis?
Sim — o texto completo de “Colando erros na IA de maneira eficaz” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Vibe Coding, atualize para CoddyKit PRO. O curso de Vibe Coding inclui 4 aulas no total.
O que vou aprender em “Colando erros na IA de maneira eficaz”?
Forneça à IA o que ela precisa para corrigir o bug. Você pratica Vibe Coding com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Vibe Coding?
Nenhuma experiência prévia é necessária. Vibe Coding no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.
Quanto tempo leva a aula “Colando erros na IA de maneira eficaz”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Vibe Coding?
Sim. Cada aula de Vibe Coding inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Entendendo mensagens de erro
- Colando erros na IA de maneira eficaz
- Delimitando um erro
- Quando a IA fica presa