Debugging & Iterating on AI-Generated Code
From the course Vibe Coding: Build Full Apps with AI
AI-generated code isn't always perfect on the first try. Learning to debug and iterate effectively is the key skill for vibe coders.
The Iteration Mindset
Expect 3-5 rounds of iteration for most features. This is normal and fast:
- AI generates initial version (80% right)
- You spot issues and describe fixes
- AI refines (90% right)
- You test edge cases and describe remaining issues
- AI polishes (95-99% right)
Describing Bugs Effectively
Bad: "It's broken" Good: "When I click the Save button, nothing happens. I expected it to save the form data and show a success message. The button seems to be clickable but no toast notification appears."
The Bug Report Formula:
"When I [action], [what happens]. I expected [what should happen]. This happens [always / sometimes / only when...]."
Common AI Code Issues
- Missing error handling — "Add error handling to the form submission. Show a toast on error and disable the button while submitting."
- Mobile responsiveness — "The cards overlap on mobile. Make the grid single-column on screens under 640px."
- State management — "The counter resets when I navigate away and come back. Persist it to local storage."
- Performance — "The list re-renders on every keystroke. Add debouncing to the search input."
Using Browser Developer Tools
Even as a vibe coder, learn these basics:
- Console tab — Shows JavaScript errors in red
- Network tab — Shows if API calls are failing
- Elements tab — Inspect the page structure and CSS
- Responsive mode — Test mobile layouts
When you see an error, paste it directly to the AI:
"I'm getting this error in the console: [paste error]. Fix it."
When to Start Over
Sometimes it's faster to start fresh than to fix deeply broken code:
- If the architecture is fundamentally wrong
- If you've made 10+ iterations without convergence
- If the AI keeps introducing new bugs while fixing others
- Just save your requirements list and start a new conversation
Key Takeaways
- •Expect 3-5 iteration rounds — this is normal and still much faster than coding manually
- •Describe bugs with: action → what happens → what should happen → conditions
- •Common issues: missing error handling, mobile responsiveness, state persistence
- •Learn basic browser dev tools to provide better bug descriptions
- •Start over if the architecture is wrong — it's often faster than deep fixes
Progress is kept in this browser only.