How to Write Better AI Prompts
A practical guide to prompt engineering. These techniques work across ChatGPT, Claude, Gemini, and any other LLM.
1. Be Specific and Direct
The single most impactful improvement you can make to any prompt is being more specific. Vague instructions produce vague results.
Instead of asking "Help me write an email," tell the AI exactly what you need: the recipient, tone, purpose, and any constraints. The more detail you give, the less the model has to guess — and the better your output will be.
Weak prompt
Write a marketing email.
Strong prompt
Write a marketing email for our SaaS product launch. The audience is existing free-tier users. Tone: professional but excited. Include a clear CTA to upgrade. Keep it under 200 words.
2. Use Variables for Reusable Prompts
Variables turn a one-time prompt into a reusable template. Wrap dynamic parts in double curly braces like {{variable_name}} so you can swap in different values each time you use the prompt.
This is especially powerful for prompts you use repeatedly — code reviews, content generation, analysis tasks. Write the prompt once, customize it endlessly.
Weak prompt
Review my Python code for bugs.
Strong prompt
Review the following {{language}} code for:
- Bugs and logical errors
- Performance issues
- Security vulnerabilities
- Adherence to {{style_guide}} conventions
Code:
```
{{code}}
```
Provide specific line-by-line feedback with suggested fixes.3. Provide Context and Role
AI models perform dramatically better when you set the scene. Tell the model who it is, who the audience is, and what the broader context looks like.
A "system prompt" or role instruction at the beginning of your prompt anchors the model's perspective. This leads to more consistent, domain-appropriate responses.
Weak prompt
Explain Kubernetes.
Strong prompt
You are a senior DevOps engineer teaching a workshop to developers who have experience with Docker but are new to orchestration. Explain Kubernetes in practical terms: what it solves, when to use it, and a simple mental model for pods, services, and deployments. Use analogies where helpful. Avoid jargon that assumes prior K8s knowledge.
4. Specify the Output Format
Don't leave the format to chance. If you need JSON, say so. If you need a bullet list, a table, or a specific structure — describe it explicitly.
You can even provide an example of the exact output structure you want. Models are excellent at pattern-matching, so a single example often eliminates ambiguity entirely.
Weak prompt
List some project management tools and their features.
Strong prompt
Compare the top 5 project management tools for small engineering teams. Return the result as a markdown table with these columns: | Tool | Best For | Pricing | Key Feature | Limitation | After the table, add a one-paragraph recommendation for a team of 8 developers working on a SaaS product.
5. Iterate and Refine
Great prompts are rarely written in one pass. Treat prompt engineering like writing code: start with a draft, test it, observe the output, and refine.
Common iteration patterns include: - Adding constraints when the output is too broad - Removing instructions when the output is too rigid - Adding examples when the model misunderstands the format - Splitting complex prompts into sequential steps
Save your best versions. That's exactly what AIOpenLibrary is for — a library of tested, refined prompts you can build on.
Weak prompt
This prompt didn't work, forget it.
Strong prompt
Take your underperforming prompt, identify what went wrong, and adjust one thing at a time. Track what changed and why. Over a few iterations, you'll converge on something reliable.
6. Chain Prompts for Complex Tasks
For complex tasks, break them into a sequence of focused prompts rather than one massive prompt. Each step's output feeds into the next.
This approach — called prompt chaining — gives you more control, makes debugging easier, and often produces higher-quality results than a single monolithic prompt.
Weak prompt
Write a complete business plan for my startup.
Strong prompt
Step 1: "Analyze the market for {{industry}} and identify the top 3 opportunities."
Step 2: "Given these opportunities, draft a value proposition for {{product}}."
Step 3: "Create a go-to-market strategy based on this value proposition."
Step 4: "Write an executive summary combining all of the above."Ready to explore real prompts?
Browse 113+ tested prompts that put these principles into practice.
Browse the Library