If you’re a developer, writing good AI prompts can help you get better answers. Whether you’re making a website, writing code, or using AI for other tasks, a well-written prompt gives you clear and useful results.
Be Clear and Specific
Say exactly what you need.
Don’t be vague or unclear.
Example:
- ❌ “Make a function.”
- ✅ “Write a Python function that takes a list of numbers and returns the sum of all even numbers.”
Give Context
AI works better when it understands the full picture.
Example:
- Instead of: “Make a login system.”
- Say: “Make a login system using Next.js and Supabase authentication. It should allow login with email/password and Google OAuth.”
Use Step-by-Step Instructions
If the task is complex, break it down into steps.
Example:
- “First, create a database for user authentication. Then, make an API for login and registration. Finally, add error handling.”
If Using a Database, Define Tables First
When asking AI for database-related help, start by listing your tables.
This helps AI understand your data before writing queries or APIs.
Use <> to separate different parts of your prompt.
Example:
This is my Table Structure
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL,
created_at TIMESTAMP DEFAULT now()
);
<>
Now, make an Express.js API for user registration and login using bcrypt for password hashing.
Ask AI If It Needs More Info
AI may sometimes misunderstand what you want.
Before it starts, ask: “Do you need any clarification before proceeding?”
This avoids mistakes and saves time.
Give Examples
Showing expected input/output helps AI understand.
Example:
- Prompt: “Write a function to sort an array.”
- Better Prompt: “Write a JavaScript function that sorts an array of numbers in ascending order. Example: Input: [3, 1, 4, 1, 5] → Output: [1, 1, 3, 4, 5]”
Improve as You Go
If AI’s response isn’t what you expected, change your prompt.
You can also give feedback: “This is close, but make it more efficient.”
A good prompt should be divided using <> to separate different sections.
Example: Generating an Auth System with Supabase.
— Users Table
This is my table structure CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL,
created_at TIMESTAMP DEFAULT now()
);
<>
Create an authentication system in Next.js using Supabase. It should include user registration, login, and password reset.
<>
Do you need any more details before starting?
Asking for Code Improvements
If you’re giving your code for improvements, make sure to mention which part needs to be better while keeping the original logic the same.
Example:
Here is my function. I want to optimize its performance but keep the existing logic unchanged:
def find_max(nums):
max_num = nums[0]
for num in nums:
if num > max_num:
max_num = num
return max_num
Please improve the efficiency without changing the logic.
Writing good AI prompts takes practice. Be clear, organized, and give enough details. Using <> to separate different parts of your prompt makes your requests more effective. This will help you get better results when using AI in your projects.