Optimizing Prompts
Markdown--- name: optimizing-prompts description: Transforms vague or poorly structured prompts into clear, effective, well-structured instructions for AI models. Use when users request prompt optimization, provide unclear or ambiguous instructions, ask for help making requests more effective, or need complex tasks broken down into better-structured prompts. --- # Optimizing Prompts Transform user-provided prompts into high-quality, clear, effective instructions using proven prompt engineering principles.
Given this prompt: "Write about marketing"
Output:
Issues identified:
- No target audience specified
- No scope or angle defined
- No length, format, or tone guidance
- No success criteria
Optimized prompt:
Write a 600-800 word blog post about email marketing best practices for small e-commerce business owners with limited marketing experience.
Structure:
- Brief intro on why email marketing matters for e-commerce (2-3 sentences)
- 4-5 actionable tips, each with a short example
- Closing call-to-action encouraging list-building
Tone: Practical and encouraging, avoid jargon. Assume the reader has never run an email campaign before.
If a claim needs current data/statistics you're unsure about, flag it rather than inventing numbers.
Key improvements: Added audience, scope, structure, length, tone, and explicit permission to flag uncertainty instead of hallucinating.
Progress:
- Step 1: Analyze the original prompt for issues
- Step 2: Identify the core intent
- Step 3: Apply optimization principles
- Step 4: Consider advanced techniques if warranted
- Step 5: Present the optimized prompt with explanation
- Step 6: Iterate based on feedback
Step 1: Analyze the Original Prompt
Check for:
- Clarity issues — ambiguous terms, implicit assumptions, missing context
- Specificity gaps — no constraints, undefined success criteria, unclear scope/audience
- Structure problems — disorganized, no logical flow, no sections
- Format gaps — unspecified output format, length, tone, or examples
- Complexity — task too big for one prompt; needs chaining or step-by-step reasoning
Step 2: Identify the Core Intent
Determine: What is the user actually trying to accomplish? What defines success? Who's the audience? If unclear from the prompt, ask before optimizing rather than guessing.
Step 3: Apply Optimization Principles
- Be clear and direct — state requirements explicitly, remove vague language
- Add context — explain why requirements matter, include use case/background
- Add specificity — length, format, scope, audience, quality bar
- Structure the request — logical order, numbered points, separated sections (context / requirements / format)
- Include examples — especially for tricky formats, tone, or edge cases
- Allow uncertainty — explicitly permit "I don't know" to prevent hallucination
Step 4: Consider Advanced Techniques
Apply only when warranted by task complexity:
| Technique | When to use |
|---|---|
| Chain of Thought | Task needs reasoning/analysis; request step-by-step thinking before the final answer |
| Prefilling | A strict output format (JSON/XML) is required; eliminates preambles |
| Prompt Chaining | Task is too large/complex for one prompt; split into sequential steps that build on each other |
| Structured Output | Exact format needed; provide schema, template, or delimiter tags |
Load references/prompt-best-practices.md for detailed guidance and troubleshooting on these techniques.
Step 5: Present the Optimized Prompt
Use this exact output format:
**Analysis — issues identified:**
- [issue 1]
- [issue 2]
**Optimized Prompt:**
[full optimized prompt in a code block]
**Key improvements:**
- [improvement 1]
- [improvement 2]
**Usage tips (optional):**
[brief note on further customization]
Step 6: Iterate
Ask if the optimization meets their needs. Offer to adjust tone, length, specificity, or provide alternate formulations based on feedback.
Example 1: Vague → Specific
Input: "Help me write an email to my team"
Output: Optimized prompt specifying purpose (status update vs. request), recipient context (team size/role), key points to cover, desired tone (formal/casual), length limit, and a call-to-action requirement.
Example 2: Implicit context → Explicit
Input: "Fix this code" (with code pasted, no other detail)
Output: Optimized prompt asking model to state assumptions, specify the bug/error being fixed, the language/framework, whether to explain changes or just provide the fix, and to flag if multiple valid fixes exist rather than picking one silently.
Example 3: Single complex prompt → Chain
Input: "Research a topic, write a report, and create a presentation"
Output: Three sequential prompts — (1) research and summarize key findings with sources, (2) turn findings into a structured report with defined sections, (3) convert report into slide outline with one key point per slide — each consuming the prior step's output.
Consult references/examples.md for more before/after examples across domains.
- Preserve the user's fundamental intent — enhance clarity, don't add unwanted requirements
- Match optimization effort to task complexity; don't over-engineer simple prompts
- Modern models follow direct, explicit instructions well — favor directness over cleverness
- Briefly explain why a change helps, so users improve their own prompting skills
- Ask clarifying questions when core intent is genuinely ambiguous, rather than guessing
- Don't rewrite the prompt into something the user didn't ask for — stay faithful to intent
- Don't apply every advanced technique to every prompt — use only what the complexity justifies
- Don't leave format/length/audience unspecified when they materially affect quality
- Don't skip permission for uncertainty on tasks involving facts, data, or citations
- Don't present the optimized prompt without explaining what changed and why