You know that friend who gives terrible directions?
"Just go down the road, turn where the thing used to be, you'll see a place, ask someone there."
And you end up lost, frustrated, and wondering why they couldn't just use actual landmarks?
That's what most people sound like when they first use AI.
"Write me something good."
"Make an image."
"Fix my code."
And then they wonder why the AI output is garbage.
The secret to getting good results from AI isn't about the AI. It's about you. Specifically, how you ask.
Welcome to prompt engineering — the art of talking to AI in a way that gets you what you actually want.
What Is Prompt Engineering?
Prompt engineering is crafting inputs (prompts) that guide AI to produce the outputs you need.
It's not a science. It's more like... coaxing a very talented but literal-minded assistant to understand what you mean, not just what you said.
New to AI entirely? Start with understanding generative AI without the hype.
Good prompts = good outputs.
Terrible prompts = terrible outputs.
Garbage in, garbage out. Tale as old as time.
Why Prompts Matter So Much
AI models are trained on billions of examples. They've seen everything. But they don't know what YOU want unless you tell them clearly.
Vague prompt: "Write about dogs."
AI thinks: "Okay, dogs. What about dogs? Their biology? History? Breeds? Training tips? A story? An essay? A list?"
It picks something, and chances are it's not what you wanted.
Specific prompt: "Write a 500-word blog post about training puppies, aimed at first-time dog owners, with a friendly and encouraging tone."
Now the AI knows exactly what to do.
The Anatomy of a Great Prompt
A good prompt has these elements:
1. Context
Who are you? What's the situation?
"I'm a developer building a SaaS app for small businesses."
Now the AI tailors responses to your context.
2. Task
What do you want the AI to do?
"Write a product description."
"Generate test cases for this function."
"Explain how OAuth works."
Be specific.
3. Format
How should the output be structured?
"As a bulleted list."
"In JSON format."
"As a 300-word blog intro."
"In simple language suitable for beginners."
4. Constraints
Any limitations or requirements?
"Without using jargon."
"Using Kenyan examples."
"Keep it under 200 words."
"Avoid technical terms."
5. Tone/Style
How should it sound?
"Professional and formal."
"Casual and conversational."
"Humorous and engaging."
"Like a patient teacher explaining to a student."
Example:
Bad prompt: "Write about APIs."
Good prompt: "I'm a beginner developer learning web development. Explain what an API is in simple terms, using a restaurant analogy, in a friendly and conversational tone. Keep it under 200 words."
See the difference?
Prompt Patterns That Work
1. Role Assignment
Tell the AI what role to play.
"You are an experienced software architect."
"You are a patient teacher explaining to a 10-year-old."
"You are a copywriter specializing in SaaS landing pages."
This frames the AI's responses in a specific expertise and tone.
Once you've mastered these basics, dive into advanced prompt engineering patterns like Chain-of-Thought and Tree-of-Thought.
2. Few-Shot Prompting
Give examples of what you want.
"Generate product names similar to these:
- Slack (team communication)
- Zoom (video calls)
- Notion (note-taking)
Now generate 5 names for a project management app."
The AI learns your style from examples.
3. Chain of Thought
Ask the AI to explain its reasoning step-by-step.
"Solve this problem step-by-step, showing your work: If a function takes 200ms to run and is called 1 million times a day, how much total compute time is used per day?"
This improves accuracy for logical/mathematical tasks. Chain-of-thought prompting is essential for building AI agents that reason through complex tasks.
4. Iterative Refinement
Start broad, then refine.
First prompt: "Write a blog intro about cloud computing."
Follow-up: "Make it more conversational."
Follow-up: "Add a Kenyan analogy."
Follow-up: "Shorten to 150 words."
Each step improves the output.
5. Negative Constraints
Tell the AI what NOT to do.
"Explain blockchain without using the words 'decentralized,' 'immutable,' or 'trustless.'"
"Write a product description without hype or exaggeration."
This avoids common AI pitfalls.
Platform-Specific Tips
ChatGPT/Claude (Text AI):
- Be conversational. These models respond well to natural language.
- Use follow-ups. Treat it like a conversation, not a one-shot query.
- Ask for formatting. "Format as markdown," "Use bullet points," etc.
Midjourney/DALL-E (Image AI):
- Be visually descriptive. "A sunset over Nairobi skyline, warm orange and purple hues, cinematic lighting, 4K, photorealistic."
- Specify style. "In the style of Studio Ghibli," "oil painting," "pixel art."
- Iterate with variations. Generate, pick the best, then ask for variations on that.
GitHub Copilot (Code AI):
- Write descriptive comments. The AI completes based on your comment.
- Use function names that describe behavior.
calculateUserTax()is better thandoThing(). - Review and edit. Copilot suggests, you verify and refine.
Common Prompt Mistakes (And How to Fix Them)
Mistake 1: Too Vague
Prompt: "Write something."
Fix: "Write a 300-word LinkedIn post about the importance of cloud computing for startups, aimed at non-technical founders."
Mistake 2: Assuming AI Knows Context
Prompt: "Continue from earlier."
If you start a new chat, the AI has no memory of "earlier."
Fix: Provide context in every conversation, or paste previous relevant parts.
Mistake 3: One-and-Done
You submit one prompt, get mediocre results, and give up.
Fix: Iterate. Refine. Ask follow-ups. Good outputs often take 2-3 rounds.
Mistake 4: Not Specifying Tone
AI defaults to neutral/formal. If you want humor, specify it.
Fix: "Write this in a funny, conversational tone like you're explaining to a friend."
Mistake 5: Overloading the Prompt
Prompt with 10 different requirements, half of them contradictory.
Fix: Start simple. Add one constraint at a time.
Mistake 6: Trusting Output Blindly
AI generates confidently wrong information all the time.
Fix: Verify facts, test code, review logic. AI is a tool, not a truth oracle.
Advanced Techniques
1. Prompt Chaining
Break complex tasks into steps.
Step 1: "List 10 blog post ideas about generative AI."
Step 2: "Pick the most interesting one and write an outline."
Step 3: "Write the introduction section."
Each step builds on the previous.
2. Persona Prompting
Create detailed personas.
"You are a senior developer at a fintech startup. You're reviewing a junior dev's code. Provide constructive feedback in a mentoring tone, focusing on best practices and security."
3. Constraint Stacking
Add multiple constraints for precise outputs.
"Write a 280-character tweet about AWS Lambda for beginners, using simple language, with a touch of humor, ending with a question to drive engagement."
4. Meta Prompts
Ask the AI to help you create better prompts.
"I want to generate a blog post about SaaS pricing. What details do you need from me to write the best possible article?"
The AI will ask clarifying questions. Answer them, then ask it to generate.
Apply these techniques to building production chatbots with well-crafted system prompts.
5. Output Formatting
Be explicit about structure.
"Generate a JSON object with keys: title, description, tags (array), publishDate."
Or:
"Format output as a markdown table with columns: Feature, Benefit, Example."
Ethical Prompt Engineering
Don't:
- Generate content to deceive (fake reviews, impersonation, misinformation)
- Use AI to harass, spam, or harm others
- Bypass safety filters for malicious purposes
- Generate copyrighted content verbatim
Do:
- Disclose when content is AI-generated (if publishing)
- Use AI to augment your work, not replace honest effort
- Respect privacy (don't input sensitive/confidential data)
- Verify outputs before sharing
Real-World Examples
Blog Writing:
Bad: "Write a blog."
Good: "Write a 700-word blog post titled 'Why Startups Fail at SaaS' aimed at first-time founders. Use a conversational tone, include practical examples, and end with 3 actionable takeaways."
Code Generation:
Bad: "Write a function."
Good: "Write a Python function that takes a list of dictionaries, filters out entries where 'status' is 'inactive', sorts by 'created_date' descending, and returns the top 10 results. Include error handling and docstring."
Image Generation:
Bad: "A car."
Good: "A vintage 1960s Volkswagen Beetle, parked on a cobblestone street in Nairobi's Eastleigh neighborhood, golden hour lighting, shallow depth of field, cinematic, photorealistic."
Email Drafting:
Bad: "Write an email."
Good: "Write a professional but friendly email to a client explaining a 2-day project delay due to unforeseen technical issues. Apologize, provide a new timeline, and reassure them of quality. Keep it under 150 words."
Tools to Level Up Your Prompting
- ChatGPT/Claude: Practice conversational prompting
- PromptBase: Marketplace for prompts (see what works)
- LangChain: Framework for building complex prompt chains
- Midjourney Docs: Best practices for image prompts
- OpenAI Playground: Experiment with settings and prompts
The Bottom Line
Prompt engineering is a skill. Like any skill, you get better with practice.
Start simple. Be specific. Iterate. Learn what works.
The AI is only as good as your instructions. Master prompting, and you unlock its full potential.
Takeaway: Good prompts lead to good AI outputs. Be specific about context, task, format, constraints, and tone. Use techniques like role assignment, few-shot examples, and iterative refinement. Avoid vague prompts and always verify outputs. Prompt engineering is a skill that dramatically improves AI usefulness. Practice it, refine it, and you'll get results that actually match what you wanted.