AI Agent Prompt Engineering Guide
The way you ask matters. Learn prompt engineering techniques to get clearer, more useful, and more accurate responses from your OpenClaw agent.
Prompt engineering is the skill of communicating effectively with AI. Small changes in how you phrase requests can mean the difference between a useless response and exactly what you needed.
Core Principles
🎯 Be Specific
Vague prompts get vague answers. The more context you provide, the better the result.
❌ Vague
"Tell me about Paris"
✅ Specific
"Recommend 3 affordable restaurants near the Eiffel Tower with outdoor seating, open for lunch on Tuesdays"
📋 Provide Context
Help the agent understand your situation, constraints, and goals.
❌ No Context
"Write an email"
✅ With Context
"Write a follow-up email to a client who requested a quote 3 days ago. We had a call yesterday where I explained pricing. Keep it friendly but professional."
🎨 Specify Format
Tell the agent how you want the output structured.
❌ Unstructured
"Analyze this data"
✅ Structured
"Analyze this sales data and provide: 1) Top 3 trends 2) One actionable insight 3) Bullet points only, max 100 words"
Advanced Techniques
Role Assignment
Give the agent a persona to shape its response style:
Example
"Act as a senior DevOps engineer reviewing this Dockerfile. Point out security issues, optimization opportunities, and best practice violations."
Chain of Thought
Ask the agent to show its reasoning:
Example
"Should I use PostgreSQL or MongoDB for my project? Think through the trade-offs step by step, then give a recommendation."
Few-Shot Examples
Show the agent what you want:
Example
"Classify these reviews as Positive, Neutral, or Negative:
Input: 'Amazing product, fast shipping!' → Positive
Input: 'It works' → Neutral
Input: 'Broke after one day' → Negative
Input: 'Not what I expected but okay' → ?"
Common Patterns
📧 Email Drafting
Template: "Write a [tone] email to [recipient] about [topic]. Include [specific points]. Keep it under [length]."
🔍 Research Summaries
Template: "Research [topic] and summarize: 1) Key findings 2) Pros/cons 3) Bottom line recommendation"
💻 Code Review
Template: "Review this code for [language/framework]. Check for: bugs, security issues, performance problems, style violations"
Iterative Refinement
Rarely get the perfect result on first try. Use follow-ups:
- "Make it shorter" — Reduce length
- "Add more detail about X" — Expand specific section
- "Rewrite for a technical audience" — Adjust complexity
- "Use bullet points instead" — Change format
- "That second point is wrong, fix it" — Correct errors
🚀 Practice Makes Perfect
Prompt engineering is a skill. The more you practice, the better you'll get at getting exactly what you need.
Advanced Techniques →