When a prompt isn't working as expected, systematically diagnose why and fix it. Identifies common failure patterns (ambiguity, conflicting instructions, missing context, wrong format specification), tests variations, and produces an improved version.
Use when: "why isn't this prompt working", "debug my prompt", "improve this prompt", "the AI keeps doing X instead of Y", "prompt not producing expected output", "prompt optimization", or iterating on system prompts.
diagnose — Analyze a Failing Prompt#Given a prompt and its undesired output, identify the root cause.
Read the prompt and check for common failure patterns:
Ambiguity Checks:
Conflict Checks:
Context Checks:
Instruction Clarity:
Categorize the issue:
Failure ModeSymptomsCommon FixInstruction FollowingIgnores specific requirementsMove to top, bold, repeatFormat ViolationWrong output structureAdd explicit format exampleHallucinationMakes up factsAdd "only use provided info"Scope CreepAnswers more than askedAdd "only address X, nothing else"Scope DeficitAnswers less than askedBreak into numbered sub-questionsTone MismatchWrong voice/registerProvide tone examplesOverthinkingToo verbose/philosophicalAdd "be direct, no preamble"UnderthinkingToo shallow/genericAdd "think step by step" + require specificsContext WindowLoses early instructionsRepeat key constraints at end
For each identified issue, propose specific prompt edits:
text
Issue 1: Ambiguous instruction "analyze the data"
→ Fix: "Analyze the data by calculating the mean, median, and standard deviation for each column. Report any outliers (>2 standard deviations from mean)."
Issue 2: Missing output format
→ Fix: Add "Output format: JSON with keys {summary, findings, recommendations}"
Issue 3: Conflicting constraints
→ Fix: "Prioritize accuracy over brevity. If you must choose between being complete and being concise, be complete."
compare — A/B Test Prompt Variations#Generate 3-5 variations of a prompt, each targeting a different failure mode fix.
markdown
## Variation A: Original (baseline)
[original prompt]
Expected improvement: none (baseline for comparison)
## Variation B: Explicit format
[prompt + format specification]
Target fix: format violation
## Variation C: Role + examples
[prompt + persona + 2 examples]
Target fix: tone mismatch, underthinking
## Variation D: Constraints tightened
[prompt + explicit constraints + negative examples]
Target fix: scope creep, hallucination
## Variation E: Restructured
[reordered prompt with critical instructions first/last]
Target fix: instruction following
For each variation, explain what was changed and why.
rewrite — Produce an Improved Prompt#Apply all identified fixes to produce a single improved prompt.
Rewrite principles:
Before/After format:
markdown
### Before
[original prompt — highlight problematic areas]
### After
[improved prompt — annotate what changed and why]
### Changes Made
1. Added role specification ("You are a senior data analyst...")
2. Replaced "analyze" with specific analytical steps
3. Added output format (JSON schema)
4. Moved length constraint to the end (recency)
5. Added negative example ("Do NOT include...")
patterns — Common Prompt Patterns Library#Reference of proven prompt patterns for common tasks:
Chain of Thought:
text
Think through this step by step:
1. First, identify...
2. Then, analyze...
3. Finally, recommend...
Show your reasoning for each step.
Few-Shot:
text
Here are examples of the expected output:
Input: [example 1 input]
Output: [example 1 output]
Input: [example 2 input]
Output: [example 2 output]
Now process:
Input: [actual input]
Output:
Constraint Sandwich:
text
[CRITICAL CONSTRAINTS — read first]
[Main task instructions]
[CRITICAL CONSTRAINTS — repeated for emphasis]
Persona + Task + Format:
text
You are [specific role] with [specific expertise].
Your task is to [specific action] for [specific audience].
Output as [specific format] with [specific requirements].
Self-Verification:
text
After generating your response, verify:
- Does it address all N requirements?
- Is it under X words?
- Does it follow the specified format?
If not, revise before outputting.
score — Rate Prompt Quality#Score a prompt on multiple dimensions (0-10 each):
DimensionScoreAssessmentClarity7/10Instructions are clear but "analyze" is ambiguousSpecificity4/10Missing format, length, audienceCompleteness6/10Has context but no examplesConsistency8/10No conflicting instructionsTestability3/10No success criteria definedOverall****5.6/10Needs format spec and examples
Provide the top 3 improvements that would most increase the score.
anti-patterns — Detect Common Prompt Anti-Patterns#Scan a prompt for known problematic patterns:
{diagnosis: {issues: [], failure_modes: [], fixes: []}, rewrite: "", score: {}, anti_patterns: []}