How to Write Good Prompts for AI Coding Tools
The difference between an AI tool that builds what you want and one that goes in circles is usually the prompt. A simple structure for asking — goal, context, constraints, and how you'll know it's done — with before-and-after examples you can copy.
Two people ask an AI tool for the same feature. One gets exactly what they wanted in a single try. The other spends an hour going back and forth while the app gets steadily worse. Usually, the difference is how they asked.
You don't need special "prompt engineering" tricks. You need to give the AI what a good human developer would need: what you want, why, what to leave alone, and how you'll judge the result.
Why vague prompts go wrong
An AI tool fills gaps with guesses. "Make the dashboard better" leaves almost everything to guesswork: better how? For whom? Which parts? It will change something — probably several things you didn't want changed — and you'll spend the next prompts undoing it.
Specific prompts leave fewer gaps.
A simple structure: GOAL, CONTEXT, LIMITS, DONE
1. Goal — what you want, in plain words
Describe the outcome, from the user's point of view if you can.
Users should be able to reset their password if they forget it.
2. Context — what the AI needs to know
What's already there, what it relates to, anything unusual about your app.
We already have login and sign-up using Supabase auth. Emails are sent through Resend.
3. Limits — what to leave alone
This is the part beginners skip, and the part that prevents most damage.
Don't change the existing login page design. Don't add new libraries. Don't touch the database tables.
4. Done — how you'll know it worked
Give the AI a way to check its own work.
It's done when: there's a "Forgot password?" link on the login page, entering an email sends a reset link, the link lets you set a new password, and you can log in with it.
Put together, that's a prompt most AI tools will get right first time.
Before and after
Vague: "Add payments."
Better: "Add a 'Upgrade to Pro' button on the settings page that sends users to Stripe Checkout for our $9/month Pro plan (Stripe price ID is in the STRIPE_PRO_PRICE_ID environment variable). After paying, the user's plan column should become pro — set this only from the Stripe webhook, not from the success page. Don't change anything else on the settings page."
Vague: "Fix the bug."
Better: "When I click Save on the profile page, nothing happens and the browser console shows TypeError: Cannot read properties of undefined (reading 'id') at ProfileForm.tsx:42. It worked yesterday before we added the avatar upload. Find the cause and fix it without changing how the avatar upload works."
Vague: "Make it look nicer." Better: "Make the pricing page look more like a typical SaaS pricing page: three plans side by side as cards, the middle one highlighted as 'Most popular', each with a price, a short list of features, and a button. Keep our existing colours and font."
Habits that help as much as the prompt
One change at a time. Asking for five things at once makes it hard to tell which one broke something. Ask, check, save, then ask for the next.
Save before big changes. Commit with git first, so a bad result is one command away from undone. (Git and GitHub for Beginners.)
Ask for a plan first on anything big. "Before writing any code, explain how you'd do this and what files you'd change." Correcting a plan is cheap; correcting a finished feature isn't. In Claude Code, plan mode does exactly this.
Paste the real error. Not "it's broken" — the actual error text, from the terminal or the browser console. It's the most useful thing you can give an AI. (How to Read an Error Message.)
Point at examples. "Make the new Settings page work the same way as the existing Profile page" is clearer than any description.
Say what you tried. "I already tried clearing the cache and it didn't help" stops the AI suggesting it.
Ask questions. "Why did you do it that way?" and "What could go wrong with this?" are great prompts. You learn, and the AI often catches its own mistakes when asked to explain.
Put the permanent stuff in a file
If you find yourself repeating the same context in every prompt — "we use Supabase," "never change the database directly," "our brand colour is #1a7f5a" — write it down once in a file the AI reads automatically. For Claude Code that's CLAUDE.md; other tools have similar "rules" or "knowledge" settings. (How to Write a CLAUDE.md That Actually Helps.)
When it's going in circles
If you've asked for the same fix three times and it keeps failing, more prompting in the same conversation usually makes it worse. Stop, undo to your last working save, and start a fresh conversation with a clearer description. We cover this in detail in Stuck in an AI Fix Loop?
A template to copy
Goal: [what should happen, from the user's point of view]
Context: [what already exists, relevant tools/services, anything unusual]
Don't: [what to leave alone — pages, libraries, database, design]
Done when: [how you'll check — what you'll click, what you'll see]
Before changing anything, briefly tell me your plan.
EasySpawn runs Claude Code in a workspace where your app, database, and live URL are all in one place — so when your prompt says "done when it works," it can actually check. See how it works or join the waitlist.
Related: What Is Claude Code? · What Is Vibe Coding? · How to Write a Good Bug Report · Claude Code vs the Claude Chat App
Keep reading
What Is Vibe Coding? What It's Great For, and Where It Breaks
Vibe coding means building software by describing what you want to an AI and accepting what it produces, often without reading the code. It's genuinely powerful for some things and genuinely risky for others. An honest guide to where the line is.
How to Plan Your First App Before You Ask AI to Build It
Thirty minutes of planning saves days of AI going in circles. How to define the one problem your app solves, cut it down to a first version, describe your users' journeys and your data, and turn it all into a brief an AI tool can build from.