---
name: xml-prompt-optimizer
description: >
  Transforms any raw, unstructured prompt into a precisely structured XML prompt
  that maximizes Claude's output quality and precision. Use this skill whenever
  the user wants to improve a prompt, asks how to phrase something better, says
  "help me write a prompt for...", "optimize this prompt", "structure this for
  Claude", "make this prompt better", or pastes a rough request and wants Claude
  to handle it perfectly. Also trigger when the user is about to do something
  complex (multi-document analysis, long reasoning chains, role-based evaluation,
  structured output generation, session continuity) and hasn't structured their
  prompt — proactively offer to optimize it. This skill works for ANY domain:
  patents, investor materials, sales, writing, coding, research, or anything else.
---

# XML Prompt Optimizer

Transforms any raw prompt into a precisely structured XML prompt that maximizes
Claude's output quality. Works universally — no domain assumptions.

---

## Your Job

When this skill triggers, you will:

1. **Diagnose** the raw prompt using the Pattern Detection Algorithm below
2. **Identify** which structural elements are missing or weak
3. **Reconstruct** the prompt using the appropriate XML structure
4. **Deliver** the optimized prompt + a brief explanation of what you changed and why

Do NOT ask clarifying questions before producing the optimized prompt. Make your
best structural judgment, deliver it, then ask if anything needs adjustment.

---

## Pattern Detection Algorithm

Read the raw prompt and score it against these five structural dimensions.
Each missing or weak dimension is a gap you must fill.

### Dimension 1: Role Clarity
**Ask:** Does Claude know what evaluative lens to apply?

Signs it's missing:
- No persona or expert framing
- The task requires specialized judgment (legal, technical, financial, creative)
- The output quality depends on *who* is doing the evaluation

Fix: Add `<role>` tag before any content. Be specific — not "expert" but "patent
attorney specializing in software claims" or "Series A investor who has reviewed
200+ AI pitches."

### Dimension 2: Input Separation
**Ask:** Are multiple distinct inputs clearly delineated?

Signs it's missing:
- Multiple documents, sources, or data types are referenced
- Content from different origins is mixed together
- Claude would have to guess where one input ends and another begins

Fix: Wrap each distinct input in its own named tag with meaningful attributes:
`<document id="1" source="prior_art" date="2023">`, `<claim version="current">`, etc.

### Dimension 3: Task Precision
**Ask:** Is the specific operation Claude must perform unambiguous?

Signs it's missing:
- The request is implicit ("analyze this", "help with this")
- Multiple interpretations are possible
- Success criteria aren't defined

Fix: Add explicit `<task>` tag with: the operation, the success criteria, and any
constraints. Make it impossible to misread.

### Dimension 4: Output Specification
**Ask:** Does Claude know exactly what format to return?

Signs it's missing:
- No mention of format, length, structure, or schema
- The task has a natural structured output (table, list, sections, JSON)
- The user will need to copy/paste or process the output downstream

Fix: Add `<output_format>` tag specifying: structure type, required sections,
length guidance, any schema or column names, tone.

### Dimension 5: Reasoning Scaffolding
**Ask:** Does the task require multi-step reasoning before a conclusion?

Signs it's missing:
- The task involves tradeoffs, evaluation, or judgment
- Getting it right requires working through intermediate steps
- A hasty answer would miss nuance

Fix: Add `<reasoning_approach>` tag instructing Claude to reason step-by-step
before concluding. Or structure the prompt with `<step_1>`, `<step_2>` phases.

---

## Universal XML Prompt Template

Every optimized prompt follows this skeleton. Include only the tags relevant
to the diagnosed gaps — never add tags that don't serve a purpose.

---

## The Six Structural Patterns

### Pattern 1: Role + Evaluation
**When:** The quality of output depends on *who* is doing the judging.
**Examples:** Investor Q&A sim, code review, legal review, editorial feedback, pitch critique

### Pattern 2: Multi-Document Reasoning
**When:** Claude must reason *across* multiple sources, not just summarize each.
**Examples:** Gap analysis, comparison, synthesis, cross-reference, conflict detection

### Pattern 3: Structured Output Generation
**When:** The user needs a specific deliverable in a specific format.
**Examples:** Reports, briefs, emails, decks, plans, templates

### Pattern 4: Chain of Thought Reasoning
**When:** The task requires working through a problem before arriving at a conclusion.
**Examples:** Strategic decisions, architecture choices, diagnosis, tradeoff analysis

### Pattern 5: Session Continuity
**When:** This conversation continues work from a prior session.
**Examples:** Patent prosecution, long-form writing, iterative builds

### Pattern 6: Critique + Improve
**When:** Claude should evaluate something AND produce an improved version.
**Examples:** Rewriting, strengthening arguments, improving code, tightening copy

---

Built by @ErikG1776 — https://github.com/ErikG1776