Skip to main content
Building with AI (Vibe Coding)

⏱ About 15 min15 XP

Asking the AI to Help Fix It

You know your bug. You have described it clearly. Now you need to convert that description into a request the AI can actually act on. This is a skill on its own. The same bug description, asked two different ways, can produce a thoughtful specific fix or an irrelevant wall of text. The difference is in how you construct the request.

What Makes a Fix Request Work

A strong AI fix request contains four elements: 1. Context: what you are building and what it is supposed to do. One or two sentences is enough. 2. The bug: your three-part description — expected, actual, already tried. 3. Relevant code: the specific section the bug lives in, not your entire project. Paste the function or the lines around the error. 4. A clear ask: what you want the AI to do. 'Explain why this might be happening' is different from 'Fix this code and explain the change.' Without context, the AI fills gaps with assumptions that may not match your project. Without relevant code, it guesses at causes. Without a clear ask, it may explain when you wanted a fix, or fix when you wanted an explanation.

The Four Elements

Context + Bug description + Relevant code + Clear ask. Each element removes a set of wrong answers the AI might otherwise give. More precision in = more precision out.

Here is a weak fix request: 'My code is broken. Here is the full file [pastes 300 lines]. Fix it.' Here is a strong fix request: 'I am building a quiz app for a school project. When the user clicks Submit, I expect the final score to display in the score-box div. Instead it always shows 0. I confirmed the score is calculated correctly in calculateScore(). Here is the displayScore function where the bug seems to be [pastes 15 lines]. Can you explain why score might arrive as 0 and suggest a fix?' The strong request gives the AI a fighting chance to be useful on the first reply. The weak request will produce a question: 'What specifically is broken?'

Prompt Challenge

Write an AI fix request for this bug: a button that should add an item to a list does nothing when clicked.

Your prompt should…

  • Describe what the button is supposed to do and what actually happens
  • Include a short snippet of the relevant code (you can write a plausible example)
  • End with a specific ask: explain the cause, suggest a fix, or both

Scoping the Code You Share

One of the most common mistakes when asking for help is pasting too much code. When you give the AI 300 lines and say 'something is wrong,' it has to guess which part matters. It often guesses wrong, or it gives a generic answer that does not apply to your specific situation. The better approach: paste only the code that is directly involved. If the error points to a specific function, paste that function and at most the one or two functions that call it. If you think the bug is in how data moves between two pieces of code, paste both pieces. No more. Being precise about code scope also helps you: the process of deciding what to include forces you to think about where the bug actually is. You will often catch it yourself before the AI answers.

Paste the Minimum

Share the smallest piece of code that contains the bug. If you cannot identify which piece that is, say so in your request — that itself is useful information for the AI.

What is the risk of pasting your entire codebase when asking an AI to fix a bug?

Which element of a fix request tells the AI what you want it to do?

Build a Fix Request

  1. Think of a real or invented bug in a small piece of code.
  2. Write a complete AI fix request using the four elements:
  3. 1. Context (2 sentences: what you are building, what it should do).
  4. 2. Bug description (expected, actual, already tried).
  5. 3. Relevant code (write or invent 5-10 lines of code that contains the problem).
  6. 4. Clear ask (one sentence: what you want the AI to do).
  7. Read your request aloud to a partner. Ask them: without any other information, could you start diagnosing this bug?
  8. Revise if they say no.
  9. This exercise builds the instinct you will use every time you debug with AI.