AI-Assisted Troubleshooting
When to Call in AI for Help
In Lesson 5.2, you learned to debug systematically: describe the problem, narrow it down, change one thing at a time. Sometimes that's enough. But other times you'll hit a wall — the bug is in unfamiliar code, the error message is cryptic, or you've tried everything you can think of.
That's when AI becomes your debugging partner. AI is excellent at translating error messages, explaining what code does, suggesting fixes, and thinking through problems step by step. The key is knowing how to describe the problem so AI can actually help.
Answer: Try to understand the problem yourself first — that builds your skills. Use AI when you're stuck after a few minutes, when the error message is confusing, or when the bug is in code you don't understand. AI is a debugging partner, not a replacement for thinking.
The Perfect Bug Report for AI
The quality of AI's debugging help depends entirely on how well you describe the problem. Here's the template that works:
- What you were trying to do: "I'm building a streak counter that increases when a habit is checked off."
- What you expected to happen: "When I click the checkbox, the streak number should go up by 1."
- What actually happens: "Nothing changes. The number stays at 0 no matter how many times I click."
- What you've already tried: "I refreshed the preview, I checked the page, and nothing seems to happen when I click — no errors, no change."
- Where to look: "It feels like the click isn't connected to the counter — but I'm not sure where in the code."
This pattern gives AI everything it needs to diagnose the issue. In Replit you don't need to paste code — the AI panel can already see your project. Compare a good bug report to "my code doesn't work, fix it" — which would produce a generic, probably unhelpful response.
Error Messages Are Your Friends
Sometimes when something breaks, the browser shows an error message. They look scary, but they're actually the most helpful debugging tool you have — they tell you what went wrong and often where.
Where do error messages show up?
In Replit, errors usually appear in one of three places:
- The preview pane — sometimes Replit shows a red banner or text saying something failed.
- The console panel — a small panel (usually labeled Console or Output) that shows messages from the running code, including errors. If you don't see it, look for a Console tab and click it. It's a normal part of the screen, not something dangerous.
- Inside the AI agent's response — if AI ran your code and hit an error, it'll often paste the error in chat.
You don't need to solve error messages yourself. You just need to find them and pass them along.
When you see an error message, do these three things:
- Read it once. Don't skip it because it looks technical. The first few words usually say what kind of problem it is.
- Copy the whole message exactly. Don't paraphrase. The exact wording is what AI needs to recognize the pattern.
- Paste it into the AI panel with this prompt: "I'm seeing this error: [paste exact error]. What does it mean in plain English, and how do I fix it in my project?"
If you're curious about the most common error types you'll see in this course, here's a quick translation guide — none of which you have to memorize:
- SyntaxError = there's a typo somewhere in the code (missing punctuation, etc.). AI usually fixes these in one shot.
- ReferenceError = the code is trying to use something that doesn't exist or got renamed. Often happens after AI changes one part but forgets to update another.
- TypeError = the code expected one kind of thing (like a number) and got another (like undefined or text). Common when data isn't loaded yet.
Whatever the error type is, the fix is the same: paste the exact message into AI and ask for the fix.
When AI Sends You in Circles
Sometimes AI's suggested fix doesn't work. You try it, get a new error, ask AI about that, try the new fix, get another error... This is called a debugging loop, and it's a sign you need to change approach.
When this happens:
- Stop. Don't keep trying AI's suggestions if they're not converging on a solution.
- Revert to the last version that worked. Undo all the failed fixes.
- Start a fresh conversation. The old conversation's context is probably confused.
- Reframe the problem. Instead of "fix this error," try: "Explain what this code is supposed to do and identify any logical problems."
- Simplify. Can you solve the problem with a simpler approach? Sometimes the fix is to rewrite the component more simply rather than patching complicated code.
Key Concepts
- Use AI for debugging when you're stuck, error messages are confusing, or the bug is in unfamiliar code.
- The bug report template: what you tried to do, expected behavior, actual behavior, what you've tried, relevant code.
- Error messages contain valuable information: file/line number, error type, and description. Paste them exactly.
- When AI's fixes create more problems: revert, start fresh, reframe the problem, or try a simpler approach.
- Always ask AI to explain its fix, not just provide one. Understanding prevents the same bug from recurring.
Find the Bug Report Template and all other downloadable resources on the Dashboard Resources page.
Level Up: Coming Next
Lesson 5.7 — Deployment: Making It Real. Get your finished project on the internet where real people can use it.
Continue to Lesson 5.7 →