How to Talk to AI: The AI Coder's Prompting Guide
The #1 skill that makes everything else easier. Better prompts = better results.
The Prompt Formula
The Golden Rules
Before & After: Prompt Upgrades
See how specific language transforms vague requests into precise instructions.
How to Share an Error
The difference between getting a fix in 10 seconds vs. going back and forth for 10 minutes.
Bad: Vague complaint
"My app is broken. The page won't load. Help?"
Good: Full context
"I'm getting this error in src/app/page.tsx:" TypeError: Cannot read properties of undefined (reading 'map') "I expected the list of users to render, but the data is coming back as undefined. I'm using Next.js with the App Router."
Prompt Patterns
“Create a [component] using [tech stack] with [specific details].”
Example: Create a pricing card component using React + Tailwind with three tiers: Basic, Pro, and Enterprise.
“In [file/component], change [specific thing] to [new behavior].”
Example: In the navbar component, change the mobile menu from a dropdown to a full-screen overlay with a fade animation.
“The [component] is [wrong behavior]. It should [correct behavior]. Here's the code: ...”
Example: The modal overlay doesn't close when clicking outside. It should close when clicking the backdrop.
“Add [feature] to the existing [component]. It should [behavior] when [trigger].”
Example: Add dark mode toggle to the navbar. It should switch all colors and persist the preference in localStorage.
“Update the styling of [component] to match [reference]. Keep [constraints].”
Example: Update the cards to have a glass-morphism effect with backdrop-blur and semi-transparent white background.
“This is close but [adjustment needed]. Also [additional change].”
Example: The spacing is too tight, increase padding to p-6. Also make the heading text larger (text-3xl) and bolder.
Power Words AI Understands
Using these specific terms helps AI generate exactly what you want.
When to Start a New Chat
Sometimes the best move is a fresh start. Here's how to know when.
Building a Page Step by Step
Here's how to build a complete landing page through iterative prompting:
-
1
Set the foundation Create a Next.js page with Tailwind CSS. Set up the basic structure: a fixed navbar at top, main content area, and footer.
-
2
Build the hero Add a hero section with a gradient text heading that says 'Build faster with AI', a subtitle paragraph, and two buttons: a primary 'Get Started' and a secondary 'Learn More'.
-
3
Add features section Below the hero, add a features section with 6 cards in a 3-column grid. Each card has an icon, title, and description. Use purple/pink accent colors.
-
4
Add social proof Add a testimonials section with 3 testimonial cards showing a user avatar, name, role, and quote. Use a subtle background color.
-
5
Style & polish Add hover animations to the cards (slight lift + shadow), fade-in animations on scroll, and make sure everything is responsive on mobile.
-
6
Final touches Add a CTA banner before the footer with a gradient background. Add meta tags for SEO. Make the navbar highlight the active link.
Common Prompting Mistakes
Copy-Paste Prompts
Real prompts that work well. Copy any of them, change the details to fit your project, and paste into your AI tool.
“Create a landing page with Tailwind CSS. Include: 1) A hero section with a large heading, subtitle, and two buttons. 2) A features section with 6 cards in a 3-column grid. 3) A testimonials section with 3 cards. 4) A CTA banner with a gradient background. 5) A footer with 4 columns. Use purple (#8B5CF6) as the main color.”
“Create a navbar with: logo on the left, links in the center, and a button on the right. Fix it to the top of the page with a blurred background. On mobile, hide the links behind a hamburger menu icon that opens a slide-in drawer. Highlight whichever link is active.”
“Create a pricing section with 3 tiers: Basic ($9/mo), Pro ($29/mo), and Enterprise (Custom). Each card shows the name, price, a list of features with checkmarks, and a button. Make the Pro card stand out with a colored border and a 'Most Popular' badge. On mobile, stack the cards vertically.”
“Create a contact form with fields for Name, Email, a Subject dropdown (General, Support, Sales), and a Message textarea. All fields are required. Show a red error message below any empty field when the user tries to submit. Show a success message after submitting.”
“Create a dashboard with: 1) A sidebar on the left with navigation links and icons. 2) A top bar with a search input and a user avatar. 3) A main area with 4 stat cards at the top showing numbers, and a data table below. On smaller screens, collapse the sidebar to just icons.”
“Add dark mode to the app. Put a sun/moon toggle button in the navbar. Dark colors: background #0F0E17, cards #1A1A2E, text white, muted text #A7A9BE. Save the user's choice so it stays the same when they come back.”
“Create a hero section with a large heading that has a purple-to-pink gradient text effect, a subtitle in gray, and two buttons side by side (one filled, one outlined). Center everything. Add a subtle fade-up animation when the page loads.”
“Create an FAQ section with 6 questions. Clicking a question opens the answer and closes the others. Use a smooth animation for opening and closing. Add a plus icon that turns into a minus when open. Below the questions, add a 'Still have questions? Contact us' link.”
Frequently Asked Questions
How do I write good prompts for AI coding tools?
Be specific about what you want: describe the feature, the look and feel, and any constraints. Break big requests into smaller steps. Include context like 'I'm using Next.js with Tailwind CSS' so the AI generates compatible code. Show examples of what you want when possible.
Why does AI give me bad code sometimes?
AI works best with clear, specific instructions. Vague prompts like 'make it better' produce vague results. Instead, say exactly what's wrong and what you want: 'The button is too small on mobile, make it full-width below 640px'. The more context you provide, the better the output.
Should I give AI my entire project or one piece at a time?
Work in small steps. Ask for one feature or fix at a time, test it, then move on. Giving the AI too much at once leads to errors and makes it harder to identify what went wrong. Think of it like giving directions: step-by-step works better than dumping a whole map.
What is prompt engineering for coding?
Prompt engineering is the skill of writing clear instructions that get the best results from AI. For coding, this means describing what you want built, what tech stack you're using, what the current code looks like, and what specific changes you need. It's the core skill of AI coding.