Writing Prompts AI Coding Agents Actually Understand
Not a list of prompts to copy. A vague prompt doesn't just get a worse result, in an AI builder it's a direct, common cause of the fix-one-break-another loop.
Quick answer
A well-formed prompt for an AI coding agent names three things every time: where the change belongs (the specific page, section or feature), what should happen instead of the current behaviour, and what should stay untouched. Leaving any of the three vague hands the agent room to guess, and a wrong guess on a live project is a real, broken change, not just an unhelpful search result you can ignore and try again.
Tools for this build
Why this is a different problem from a vague Google search
A vague search engine query gets you a list of results to judge and pick from yourself, no real cost to trying again with better words. A vague prompt to an AI coding agent isn't a query, it's an instruction the agent acts on directly, changing real files in your actual project. When the wording is ambiguous, the agent doesn't hand you a list of interpretations to choose from, it picks one and commits to it. If that guess is wrong, you don't get a bad search result, you get an actual, live change to your app that you now have to notice, diagnose and undo.
This is also why the same habits that work fine when talking to a person don't transfer cleanly. A colleague hearing "fix the contact form" asks a clarifying question before touching anything, since asking costs almost nothing and getting it wrong costs their afternoon. An AI coding agent is built to act quickly on what you give it rather than pause and interview you first, so the clarifying question you'd normally get from a person has to be baked into the prompt itself, upfront, or it doesn't happen at all.
The three things a well-formed prompt always includes
Where: name the specific page, component or feature involved, as precisely as you can describe it, not the whole app in general terms. What: describe the exact behaviour you want, not just that something is "wrong" or "better." What shouldn't change: say explicitly what needs to stay exactly as it is, especially anything nearby that an agent might reasonably assume is fair game to touch while it's in that part of the code.
None of these need technical language to work. "The contact form on the homepage should show an error message under the email field if it's left blank, and shouldn't change anything else on that page" names all three without a single technical term, and gives an agent far less room to guess than "fix the contact form."
The same request, two ways
Vague prompt
"The pricing page looks bad on mobile, fix it."
No page section, no target behaviour, no boundary
Well-formed prompt
"On the pricing page, the three plan cards overlap on a phone-width screen. They should stack vertically below 600px wide. Don't change the desktop layout."
Where, what, and what shouldn't change, all named
AI Build · aibuild.co.za
Describe the symptom, not your guess at the cause
A common way a well-intentioned prompt still goes wrong: describing what you think is broken instead of what you're actually seeing. "The API key must be wrong" sends the agent looking in exactly the wrong place if the real problem is something else entirely, a mismatched field name, a missing permission, a totally different cause you haven't considered. "Submitting the form does nothing and the browser console shows a 403 error" describes the actual symptom and lets the agent diagnose the real cause itself, which it's usually better positioned to do than you are from the outside.
Iterate on the prompt, not the output
When a result isn't right, the instinct is often to start manually editing what the agent produced. On a platform built around prompting, refining the prompt itself and generating again is usually the faster, more reliable path; these platforms are built for fast prompt-to-result cycles, not for hand-editing generated code piece by piece. Treat a wrong result as a signal your prompt was missing one of the three things above, and fix the prompt, not the output.
A follow-up prompt needs the same three-part discipline as a first one, not less of it. "That's still not right" tells the agent almost nothing new to work from, and often produces a different wrong guess rather than a correction toward the right one. A useful follow-up names what changed since the last attempt and what's still wrong specifically, and repeats the boundary about what shouldn't move, the same structure as the original prompt, applied again rather than assumed to still be understood.
Where you have one, a concrete example helps more than another sentence of description. Pointing at a specific existing page on your own site ("match the spacing this section already uses") or describing a reference you've seen elsewhere gives the agent something to match against, rather than asking it to interpret an adjective like "cleaner" or "more modern" entirely on its own judgement.
Where to go next
- Already stuck in a fix-one-break-another loop: Breaking Vibe-Code Loops.
- Not sure how the general build loop works yet: How to Build a Website Using AI, Step by Step.
- Considering a coding agent working on its own for a hard problem: How to Choose a Vibe Coding Tool.
- A good prompt in a chat that has grown too long still gets forgotten: Why Your AI Forgets or Stops.
Not affiliated with the platforms we write about
AI Build South Africa is an independent resource. We're not endorsed by, or an official partner of, Lovable, Base44, Bolt.new or Anthropic. We do participate in affiliate and referral programmes with some of these providers, including Base44. See our Disclaimer for the full disclosure and our Terms of Service for the wider terms.
Frequently asked questions
Is there a single perfect prompt template I can just copy?
No, and treat anything claiming to be one with suspicion. The three-part structure this guide describes (where, what, what shouldn't change) applies broadly, but the actual content of each part is specific to your project every time, not a fixed phrase to paste in.
What's actually different between prompting an AI builder and searching Google?
A search engine matches your words against existing pages and shows you several options to judge yourself. An AI coding agent takes your words as an instruction and acts on them directly, changing real files in your project. Vagueness that just gets you an irrelevant search result gets you an actual, wrong change to your app instead.
Should I write one big detailed prompt or several smaller ones?
Several smaller ones, each scoped to one specific change. A single prompt covering multiple unrelated changes gives the agent more surface area to get something wrong, and makes it harder to tell which part of a broad request caused a problem when one shows up.
What if I don't know the technical name of the file or section involved?
Describe it the way a visitor would see it instead, the exact page and what's visibly wrong, rather than guessing at a technical term you're not sure of. A precise description of the visible problem works better than an imprecise guess at the technical cause.
Does a well-formed, longer prompt cost more in tokens or usage than a short vague one?
A single well-formed prompt is usually a little longer than a single vague one, but it typically costs less overall, since it avoids the multiple follow-up prompts a vague request tends to trigger once the agent guesses wrong and you have to correct it.
How does this connect to getting stuck in a fix-one-break-another loop?
Directly. A broad prompt is one of the most common root causes of that exact loop, since it gives the agent more code in scope to change while fixing your one request, which is more code that can end up broken as a side effect. Prompting narrower from the start is a real way to avoid triggering the loop in the first place, not just a way to escape it once you're in one.
Related reading
- Giving Your AI Agent Real Project Context: the other half of a well-formed prompt, what background the agent needs before the instruction itself.
- Describing a Bug to AI So It Actually Gets Fixed: this same discipline, applied to reporting a failure instead of requesting a feature.
- Iterating on Your App Without Breaking What Works: keeping a well-formed prompt from still breaking something else three prompts later.