Prompt Patterns

Specification Extraction

Extracts the implicit specification from a finished artifact, working backward from output to the rules that produced it.

Also known asReverse PromptingPrompt RecoveryOutput-to-Prompt Inference
Specification Extraction pattern diagram

Problem

Effective writing follows conventions that are subtle and implicit. Extracting these conventions manually is time-consuming and unreliable. When asked to describe what makes their work effective, authors tend to offer high-level generalities that miss the structural and tonal conventions that actually drive quality.

Solution

Provide the model with an exemplar of excellent work and ask it to extract the specification. The model extracts multiple convention dimensions from a single exemplar. The specification can then be reviewed, refined, embedded in a system prompt, or shared as a style guide.

Example

One worked example. The book has 2–4 per technique.

Prompt
Here is a customer support response from our highest-rated agent. Analyze it and extract the rules, structure, and conventions it follows. Produce a specification I could use to instruct an AI assistant to write responses like this consistently.

"I understand you are having trouble with a double charge. Let me look into this right away.

I can see your account was charged $49.99 on March 3 and again on March 5. The second charge appears to be a retry after the first payment timed out — both went through. I have initiated a refund for the duplicate charge. You should see it within 3–5 business days.

If the refund does not appear by Friday, reply to this thread and I will escalate to our billing team within one hour."
Response
Specification extracted from the exemplar:

Structure: Every response follows a four-part sequence — (1) acknowledge the issue with empathy, (2) state what was found using specific account details, (3) state the action already taken with a concrete timeline, (4) define the fallback action and escalation trigger.

Tone: Lead with understanding, not apology. Be direct about findings. Use specific numbers (amounts, dates, timelines) rather than vague reassurance. Never suggest the user contact their bank as a first step.

Data use: Reference specific account details (amounts, dates, transaction events) when available. Do not use generic placeholders when real data is accessible.

Escalation: If the resolution might not hold, provide a fallback with a specific trigger ("if X does not happen by Y") and a committed response time for escalation.

Closure: End with a concrete next-step trigger, not an open-ended offer of help.

Techniques

Concrete ways to implement Specification Extraction. Each technique fits a different situation.

  • 01

    Prompt Reconstruction

    Start from a finished artifact and infer the instruction that would reliably produce outputs like it, yielding a usable prompt you can deploy.

  • 02

    Convention Extraction

    Pull selected convention dimensions (structure, tone, vocabulary, detail level) from one or more exemplars for modular reuse.

  • 03

    Differential Extraction

    Compare two similar artifacts and identify the conventions that explain the difference, producing rules to turn a weaker version into a stronger one.

Prompt Patterns book cover

Full treatment in the book

Specification Extraction — the complete chapter

  • Mechanism — why this pattern works
  • 2–4 worked examples per technique
  • Placement, sequencing, and debugging rules
  • Composition with related patterns