Prompt Engineering for Vibe Coding: Write AI Prompts That Actually Work
Stop getting stuck in AI hallucination loops. Copy these proven prompt structures, templates, and rules files that turn vague ideas into working apps.
Same tool, same afternoon, two prompts. One gives you a working feature. The other gives you a mess that barely resembles what you meant. The difference is almost never the AI. It is the prompt. Here is how to write the good kind, with templates and a rules file you can copy.
Before and after: one prompt, rewritten
Here is the difference in one copy-paste example. The first prompt sends the AI guessing. The second answers every question it would otherwise guess at.
Build me a habit tracker app with a nice design.
Context: Next.js 14 app, TypeScript, Tailwind, Supabase auth already set up. Goal: a /habits page where a signed-in user adds a habit, checks it off for today, and sees a 7-day streak row under each one. Constraints: use our existing Card and Button components, store check-ins in a habit_checkins table, no new libraries. Output: the page, the table SQL, and a two-line summary of what changed.
Context: [app], built with [stack]. Already exists: [files, components, tables]. Goal: [one specific outcome a user can see]. Constraints: use [components/libraries]. Do not change [area]. No new dependencies. Output: [full files or a diff], then a two-line summary.
Why prompts decide everything
An AI coding tool does not read your mind. It reads your words and fills every gap with a guess. Ask for "a wall" and you get a wall, with a hundred choices about height, color and material made for you. Some of those guesses land. Many do not.
Three things go wrong most often:
- Ambiguity. "Simple", "clean" and "modern" mean something different to everyone, the AI included.
- Missing context. It cannot see your project, your stack or your style unless you tell it.
- Scope creep. A vague ask gives it license to build far more than you wanted.
Prompting is not about magic words. It is about being clear with a very capable, very literal collaborator.
The four parts of a great prompt
Every strong prompt answers four questions. You will not always need all four, but the more you include, the closer the first answer lands.
- 01
Context: where are we?
What is the project, what is the stack, and what already exists. For example: a Next.js 14 app with TypeScript, Tailwind and shadcn/ui, a task manager for freelancers.
- 02
Goal: what do you want?
One specific outcome. Not "add auth" but "add email and password sign-in with a forgot-password link".
- 03
Constraints: what are the rules?
Libraries to use or avoid, patterns to follow, things that must not change. Say which rules are hard and which are nice to have.
- 04
Format: what should come back?
One file or several, full code or a diff, with or without an explanation. Saying it saves a round trip.
Vague versus specific
The fastest way to see the difference is side by side. Here are three everyday asks.
Make a login page.
Build a login page in Next.js with Tailwind. Email and password fields, a Sign in button, a Forgot password link, inline errors under each field, and a loading state on the button. Use our existing Button and Input components.
Fix the bug in my code.
The task list does not update after I add a task. Expected: the new task appears at the top. It only shows after a refresh. Here is the component and the add handler. I already checked that the API returns the new task.
Make it look better.
Restyle the pricing card: more padding, a 16px radius, the plan name in 20px semibold, the price in 40px, and a subtle border instead of the shadow. Keep the dark theme.
Three templates to copy
Swap the bracketed parts for your own and paste them into Cursor, Claude, Bolt or whatever you build with.
Context: [App] built with [stack]. Relevant files: [list]. Feature: [one sentence on what it does and who uses it]. Requirements: - [requirement] - [requirement] Constraints: use [library/pattern]. Do not change [area]. Output: the full code for each changed file, then a two-line summary.
Problem: [what happens]. Expected: [what should happen]. Steps to reproduce: [1, 2, 3]. Relevant code: [paste the smallest piece that shows it] Already tried: [what you ruled out]. Environment: [framework, version, browser].
Project: [name], a [type of app] for [audience]. Stack: [framework], [styling], [database], [auth]. MVP features: 1. [feature] 2. [feature] 3. [feature] Set up the project structure and the first feature only. Explain each folder in one line.
Give the AI a memory: rules files
Retyping your stack in every prompt gets old, and the one time you forget is the time the AI quietly swaps your database library. A rules file in your project root fixes that. The tool reads it before every request, so the context travels with you.
- Cursor reads project rules from a
.cursorrulesfile (or rule files in the newer.cursor/rulesfolder). - Claude Code reads
CLAUDE.mdat the root of your repo. - Copilot and Windsurf have their own instruction files too. The contents are the same idea everywhere.
# Project: [name], a [type of app] for [audience] ## Stack - Next.js 14 (App Router), TypeScript, Tailwind, shadcn/ui - Supabase for Postgres and auth, row level security on every table - Deployed on Netlify ## Rules - Use the existing components in /components/ui before writing new ones. - No new dependencies without asking first. - Keep secrets in environment variables, never in client code. - One feature per change. Show me a plan before editing more than three files. - After each change, tell me how to test it in two lines.
Habits that keep you fast
- 01
One feature per prompt
Big asks produce tangled code that is hard to review. Small asks produce changes you can read, test and keep.
- 02
Always say the stack
Even if it seems obvious. It prevents the AI from quietly switching libraries or patterns on you.
- 03
Save the prompts that work
Keep a notes file of prompts that gave great results. Reuse them; they get better every time you tweak them.
Most stuck projects trace back to a prompt or scope mistake. The 10 vibe coding mistakes post covers the rest, each with a two-minute fix.
Start with a clear idea
The best prompts start from a clear plan. The free Vibe Code Vibes Idea Generator gives you one: pick your interests and time, and each idea comes with a pitch, a stack, the key features and a build prompt you can paste straight into your editor.

Ready to find your next build?
Pick what you are into and get four ideas shaped by your time and your tools.
Not sure which tool to build with? Take the quiz.