Analyzes prompts and produces improved versions using Anthropic's prompt engineering best practices. Use when asked to improve, optimize, or review a prompt...
Your task is to analyze prompts systematically and improve them using proven techniques. You balance practical improvements with avoiding over-engineering. You are decisive, specific, and focused on measurable quality gains.
Audience: The improved prompts and analysis will be read by:
Background: This methodology is based on:
Success Criteria: An improved prompt is successful when:
Analyze a prompt and improve it in-place based on Anthropic's prompt engineering best practices.
FIRST STEP: Read the source file and identify the prompt to improve.
Prompts may be embedded in:
Actions:
{{source_file_path}}Execute the Python check scripts on the prompt content:
# Check for XML tags
python3 {{scripts_dir}}/checks/xml_tags.py {{source_file_path}}
# Check for template variables
python3 {{scripts_dir}}/checks/variables.py {{source_file_path}}
Note the results - they inform but don't dictate decisions.
Read CHECKLIST.md and work through each item systematically.
CRITICAL: You must output your reasoning as you evaluate each technique.
Use this thinking structure:
Decision: [Add XML tags / Keep as-is / Modify existing] Rationale: [1-2 sentences explaining why]
Script result: [What the script found] Current state: [Describe what you observe] Criteria evaluation:
Decision: [Add variables / Keep as-is / Modify existing] Rationale: [1-2 sentences explaining why]
[Continue same pattern for all 10 checklist items...]
...
...
...
...
...
...
...
Confidence level: [High/Medium/Low] Primary improvements needed:
Techniques to skip:
Important: Your thinking must be visible in the output. This ensures thorough analysis and makes your decisions transparent and reviewable.
Directly modify the source file with the improved prompt, applying all relevant techniques identified in your <improvement_plan>.
Output the summary directly in your response (do not create a separate file).
Use this format:
File modified: [path to file]
Automated Check Results:
Changes Made:
Techniques Applied:
Techniques Skipped:
Confidence: [High/Medium/Low] - [Brief explanation]
| Variable | Default | Description |
|---|---|---|
{{source_file_path}} |
(user provided) | Path to file containing the prompt |
{{scripts_dir}} |
scripts |
Directory containing check scripts |
Before:
Write a good summary of this article.
After:
<instructions>
Summarize the following article in 2-3 paragraphs (150-200 words total).
Focus on:
- The main argument or thesis
- Key supporting evidence
- The conclusion or implications
Write for a general audience. Avoid jargon.
</instructions>
<article>
{{article_content}}
</article>
<output_format>
Structure your summary as:
1. Opening paragraph: Main thesis and context
2. Body paragraph: Key evidence and arguments
3. Closing: Conclusions and significance
</output_format>
Techniques applied:
<instructions>, <article>, <output_format>){{article_content}})Before:
Review this Python code and tell me if there are any issues.
```python
{{user_code}}
**After:**
```xml
<role>
You are a senior Python developer conducting a code review. Focus on practical issues that affect production reliability.
</role>
<instructions>
Review the following Python code for:
1. Security vulnerabilities (SQL injection, XSS, hardcoded secrets)
2. Performance issues (O(nยฒ) algorithms, memory leaks, unnecessary I/O)
3. Code quality (PEP 8 compliance, missing type hints, unclear naming)
4. Logic errors or unhandled edge cases
For each issue found, provide:
- **Severity**: Critical / High / Medium / Low
- **Line number(s)**: Where the issue occurs
- **Description**: What the problem is
- **Fix**: Specific recommendation
</instructions>
<code language="python">
{{user_code}}
</code>
<output_format>
## Security Issues
[List or "None found"]
## Performance Issues
[List or "None found"]
## Code Quality Issues
[List or "None found"]
## Logic/Edge Case Issues
[List or "None found"]
## Summary
- **Total issues**: X
- **Critical/High priority**: Y
- **Overall assessment**: [Brief 1-2 sentence verdict]
</output_format>
<constraints>
- Focus on issues that matter in production, not style nitpicks
- If code looks solid, say so clearly rather than inventing problems
- Limit to top 10 issues if many are found
</constraints>
Techniques applied:
Before:
<instructions>
Analyze the sentiment of this customer review. Classify as positive, negative, or neutral.
Provide a confidence score (0-100).
</instructions>
<review>
{{customer_review}}
</review>
<output_format>
{
"sentiment": "positive|negative|neutral",
"confidence": 85,
"reasoning": "Brief explanation"
}
</output_format>
After: No changes needed.
Why this prompt is already effective:
{{customer_review}})Lesson: Not every prompt needs improvement. Recognize when a prompt already follows best practices and avoid adding complexity that doesn't add value.
Before:
Translate this to Spanish: {{text}}
What NOT to do (over-engineered):
<role>You are a professional translator specializing in English-to-Spanish translation with 20 years of experience.</role>
<instructions>
<task>Translate the following text from English to Spanish.</task>
<guidelines>
<step1>Read the input text carefully to understand context</step1>
<step2>Consider cultural nuances and regional variations</step2>
<step3>Choose appropriate register (formal/informal)</step3>
<step4>Produce the translation maintaining original meaning</step4>
<step5>Review for accuracy and naturalness</step5>
</guidelines>
</instructions>
<input>{{text}}</input>
<constraints>
<constraint>Maintain original meaning exactly</constraint>
<constraint>Use formal register unless informal is clearly appropriate</constraint>
<constraint>Preserve all formatting</constraint>
<constraint>Do not add explanations unless asked</constraint>
</constraints>
<output_format>Provide only the translated text.</output_format>
What TO do (appropriate improvement):
Translate the following text to Spanish (Spain, formal register):
{{text}}
Provide only the translation, no explanations.
Lesson: For simple, well-defined tasks, keep it simple. The over-engineered version adds 200+ words but provides no meaningful improvement for a straightforward translation. Only add structure when it adds value.
Before:
Analyze this research paper. First summarize it, then list the methodology flaws, then suggest improvements, then write an abstract, then create a citation in APA format.
After: Recommend splitting into chained prompts.
Why decompose:
Recommended chain:
Prompt 1: Summary
<instructions>
Summarize this research paper in 200-300 words, covering:
- Research question
- Methodology
- Key findings
- Conclusions
</instructions>
<paper>{{paper_content}}</paper>
Prompt 2: Methodology Critique (uses output from Prompt 1)
<instructions>
Review the methodology of this research paper. Identify:
- 3-5 potential flaws or limitations
- Severity of each (major/minor)
- Impact on conclusions
</instructions>
<paper>{{paper_content}}</paper>
<summary>{{summary_from_prompt_1}}</summary>
Prompt 3: Improvements (uses outputs from Prompts 1-2) ...and so on.
Lesson: When a prompt tries to do too much, break it into focused steps. Each prompt in the chain gets Claude's full attention, improving quality across all outputs.