Vibe Coding — your first app without knowing how to code — 4. Building & fixing

17 min read min de lecture
Chapter 04

Building & fixing

Chapter 4 of 10 · 40%

Chapter objectives

  • Test each step before moving on
  • Debug through dialogue with the AI
  • Provide the right information to fix things fast

The build-test-fix loop

You've sent your mini-PRD, the AI has generated the foundation of your app. Now begins the longest — and most formative — phase of the project: iterative construction. The rhythm is always the same: you ask for one thing, the AI does it, you test immediately, and depending on the result you validate or you fix. Then you start again with the next thing.

This rhythm may seem slow compared to the temptation of asking for everything at once. It's actually much faster over time, for a simple reason: when a bug appears, you know exactly which request introduced it — the last one. Without this discipline, a bug can come from any of your last five requests, and you'll spend more time hunting the culprit than fixing it.

flowchart LR
  D["Ask for ONE thing"] --> G["The AI generates"]
  G --> T["Test immediately"]
  T -->|"It works"| V["Validate and move on"]
  T -->|"It breaks"| E["Copy the exact error"]
  E --> C["Ask for the fix"]
  C --> T
  V --> D
The build loop: a single change between two tests, always.

Testing each step: your checklist

After each generation, open the app and actually try the feature. Don't just look at the screen: use the app like a user would. For Tom's "add a habit" feature, that means: type a name, click the button, check that the habit appears, add a second one, then reload the page to check everything is still there.

Also get into the habit of testing edge cases — that's where the bugs hide: what happens if you add a habit with an empty name? If you add twenty? If you click twice very quickly? You don't need to be exhaustive, but two or three "off the beaten path" tries per feature reveal the weak spots before your users do.

  • Test the normal case: does the main action work?
  • Reload the page: is the data still there?
  • Test an edge case: empty field, weird value, double click.
  • Check on mobile (or by shrinking the window) if your app is mobile-first.

The browser console: your best ally

When something breaks with no visible explanation, the answer is almost always in the browser console. Press F12 (or right click → "Inspect"), then open the "Console" tab. That's where the browser writes the errors: red lines, often in English, indicating what failed and where.

You don't need to understand these messages — you just need to copy them. Here's what a typical error looks like:

text
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
    at app.js:24:18

Loose translation: "at line 24 of the app.js file, the code is trying to use something that doesn't exist". That's exactly the kind of clue the AI needs to fix things in one message instead of five. Frequent errors you'll come across: TypeError (the code is handling a value of the wrong type), ReferenceError (it uses a name that doesn't exist), SyntaxError (the code itself is malformed), and 404 Not Found (a file can't be found).

Learn to open the browser console (F12) right now, before you need it. That's where the most useful error messages hide — and copying a single red line can save an hour of blind debugging.

The perfect debugging prompt

When things break, don't say "it doesn't work". The AI has no way of guessing what you see on screen. A good bug report contains four elements: what you were doing, what you expected, what happened instead, and the exact error message from the console. With these four pieces of information, the diagnosis is almost always immediate.

PROMPT
Bug to fix.
What I was doing: I click "add a habit" after typing "Reading" in the field.
What I expected: the habit appears in the list.
What happens: nothing shows up, the field clears.
Error in the console: Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') at app.js:24:18
Diagnose the cause and fix it, explaining to me in simple terms what was wrong.

Notice the last sentence: "explaining to me in simple terms what was wrong". That's what turns every bug into a lesson. After ten fixes, you'll recognize the common errors yourself — and you'll write requests that avoid them from the start.

When the AI goes in circles

It happens: you report a bug, the AI "fixes" it, the bug is still there, it "fixes" again, and nothing changes — or worse, something else breaks. After two or three unsuccessful attempts, stop pushing down the same path. Three effective strategies: ask the AI to start this feature over from scratch ("delete all the calendar code and redo it more simply"), ask it to add diagnostic messages ("add console.log statements so we can see where it gets stuck"), or completely rephrase your initial request, which may have been ambiguous.

Also keep the nuclear option in mind: going back to the last version that worked and resuming from there. That's exactly what Git is for, which we'll cover right now — a safety net that makes experimentation risk-free.

If the AI proposes rewriting half your app to fix a small bug, be wary: first ask "can you fix this with a minimal change?". Unsolicited big rewrites often introduce new bugs.

Saving with Git: your safety net

Git is the tool all developers use to save a project's history. The idea fits in one image: at every step that works, you take a "snapshot" (a commit) of your project. If an experiment goes wrong, you go back to the last snapshot in an instant. No more fear of breaking things: everything is reversible.

If you're on a browser tool (Lovable, v0, Bolt), good news: most of them manage version history for you — look for a "History" or "Versions" menu and figure out how to restore a previous state. If you're on Cursor or Claude Code, simply ask the AI to make the commits for you, or learn the three essential commands:

bash
# At every step that works, take a snapshot of the project:
git add .
git commit -m "Adding habits works"

# To see the history of your snapshots:
git log --oneline

The right rhythm: one commit after each tested and validated feature. The commit message describes what works ("daily check-off OK", "calendar displayed"). Tom picks up this habit from the very first evening — and the day a design experiment breaks his whole layout, he rolls back in thirty seconds instead of rebuilding everything.

Moving forward in small, safe steps

A tested, working feature = a solid foothold. You build on stable ground, not on sand. That's what avoids the "everything is broken and I don't know why" effect that discourages so many beginners. Tom's complete sequence for each feature: ask → test → fix if needed → commit → move on to the next.

This method has a precious side effect: confidence. Every validated small step is a concrete win, and motivation feeds on wins. By the end of the chapter, Tom's app does everything his v1 planned — adding, deleting, daily check-offs, streak — and every brick has been verified. He's ready to go live.

🛠️ Your turn

Context

Tom added the "check off a habit" feature but something isn't working: clicking the checkbox changes nothing on screen, and the streak stays at zero. Rather than panicking or sending "it doesn't work" to the AI, he's going to apply the complete debugging method — console, four-point bug report, fix, re-test, and a safety commit. Reproduce this method on your own app, on a real bug or by walking through the steps as a dry run to practice.

Instructions

  1. Test the new feature immediately after generation, like a real user.
  2. Reload the page to check that the data persists.
  3. Open the console (F12) and spot any red lines.
  4. Write a 4-point bug report: what you were doing, what you expected, what happened, the exact error copy-pasted.
  5. Send the report to the AI asking for a minimal fix and a simple explanation.
  6. Apply the fix and re-test the normal case AND an edge case.
  7. When everything works, save: a Git commit or a restore point in your tool.
Hint — "It doesn't work" is never enough: give the exact error and the context. And if the AI fails twice in a row on the same fix, change strategy — redo the feature from scratch or ask for diagnostic console.log statements.

In summary

  • The rhythm: ask for ONE thing, test immediately, fix, save, repeat.
  • Test like a user: normal case, page reload, edge cases.
  • The browser console (F12) reveals the real error messages — copy them as is.
  • The perfect bug report: what you were doing, what you expected, what happened, the exact error.
  • Always ask for a simple explanation with the fix: every bug becomes a lesson.
  • If the AI goes in circles: redo the feature from scratch, add diagnostics, or rephrase.
  • Git (or your tool’s history) makes everything reversible: one commit after each validated step.
  • Moving forward in small tested steps avoids the "everything is broken and I don’t know why" effect.

Quiz — check your understanding

1. What should you provide to debug effectively?

The literal console error plus the four points of the bug report allow an immediate diagnosis.

2. Why test at every step?

With a single change between two tests, the culprit of a bug is always the last request.

3. How do you open the browser console?

The console is built into every browser: F12 and the Console tab are enough to see the errors in red.

4. The AI fails twice in a row to fix the same bug. What do you do?

Pushing down a failing path keeps you going in circles. Starting the feature over cleanly is often faster.

5. When should you make a Git commit (or a restore point)?

One commit per working step = a permanent safety net. If an experiment breaks everything, you roll back in thirty seconds.

Auteur(s)

R

REHOUMA Haythem

Haythem Rehouma est un ingénieur et architecte IA et cloud, formateur et enseignant technique, avec un profil orienté IA médicale, AWS, MLOps, LLM/RAG et vision par ordinateur.