Prompt Patterns for Real Work: Summarize, Extract, Classify, Transform
Most teams re-invent the same four prompts every quarter: “Summarize this,” “Pull out the key numbers,” “Tag the topic,” “Convert to JSON.” Below is a small, copy-paste library of prompt patterns that we have seen run reliably at scale. Each pattern includes (1) a minimal template, (2) an explicit input/output contract, and (3) a short quality checklist you can wire into CI. Treat the snippets as internal open-source: fork, rename, and version them in your prompt repo.
How to Use This Library
- Pick the pattern that matches your business goal.
- Copy the template into a new prompt file.
- Fill the bracketed blanks only—do not trim the guardrails.
- Attach the suggested evaluation set before you merge.
- Tag the version that passes all assertions; ship via feature flag.
If you need a refresher on staging prompts through dev/test/prod, see our repeatable prompt workflow first.
Pattern 1. Summarize
Goal
Condense long text to a fixed length while preserving salient facts.
Template
1. Role: You are a concise business analyst.
2. Context:
###
{text_to_summarize}
###
3. Task: Summarize the above in {3|5|7} bullet points of ≤ 15 words each.
4. Rules:
- Drop marketing fluff; keep quantitative facts and named entities
- Use sentence case and active voice
- If the text is shorter than 150 words, return "Text too short to summarize"
Output example:
- Revenue grew 12 % to $4.2 M in Q2
- North America added 3 enterprise clients
- Operating margin slipped 2 % on hosting costs
Input contract
Plain UTF-8 text, 150–5 000 words. No markup required.
Output contract
JSON array of strings, max length 7 items. Empty array if text too short.
Quality checks
- Assert
len(bullets) <= 7 - Assert each bullet ≤ 15 words
- Spot-check 5 % of outputs for hallucinated numbers against source text
When to use
Executive briefing emails, support ticket triage, call-transcript digests.
Cost note
A 2k-token article → 180-token summary. At 1 M calls/month that is ~$180 on gpt-4o-mini.
Pattern 2. Extract
Goal
Pull named entities or data points into a predictable schema.
Template
1. Role: You are a data extractor that never invents facts.
2. Context:
###
{document}
###
3. Task: Return a JSON object with keys: vendor_name, invoice_date, total_amount, currency.
4. Rules:
- Extract only values literally present
- If a key is missing, set value to null
- Currency must be the 3-letter ISO code
- Dates must be ISO-8601 (YYYY-MM-DD)
Output example:
{
"vendor_name": "Acme Corp",
"invoice_date": "2024-03-18",
"total_amount": 1234.56,
"currency": "USD"
}
Input contract
PDF OCR text or email body, ≤ 10k tokens, English or Spanish.
Output contract
Single JSON object, 4 keys, no nesting.
Quality checks
- JSON decode must succeed
- Regex
\d{4}-\d{2}-\d{2}on invoice_date when not null - total_amount castable to float
- Cross-check 50 random extractions against human labels; target F1 ≥ 0.95
When to use
AP automation, receipt scanning, contract metadata harvesting.
Pattern 3. Classify
Goal
Tag text into one (or few) predefined buckets with a confidence score.
Template
1. Role: You are a neutral content classifier.
2. Context:
###
{text}
###
3. Task: Classify the text into exactly one category: {A, B, C}.
4. Rules:
- Respond only with the category letter
- If confident, reply "A", "B", or "C" with no punctuation
- If unsure, reply "UNCLEAR"
- Do not explain
Input contract
Ticket subject + first 200 words of body.
Output contract
Single uppercase token: A|B|C|UNCLEAR.
Quality checks
- Assert response in allowed set
- Confusion matrix tracked in evaluation dashboard
- UNCLEAR rate ≥ 5 % triggers review (labels may be ambiguous)
When to use
Support routing, sentiment triage, compliance risk buckets.
Few-shot boost
If label imbalance > 10:1, add 3 examples of the rare class; see our shot-selection guide for token math.
Pattern 4. Transform (Schema-Mapping)
Goal
Convert semi-structured text into a target machine-readable format.
Template
1. Role: You are a strict data converter.
2. Context:
###
{raw_text}
###
3. Task: Rewrite the above as valid JSON that matches the schema below.
4. Schema:
{
"product": string,
"price": number,
"in_stock": boolean
}
5. Rules:
- price is unit price, no currency symbol
- If in_stock mentions "no", "sold out", or "0", set false
- Output only JSON, no code fence
Input contract
Chat message, email snippet, or web scrape, ≤ 500 tokens.
Output contract
Minified JSON satisfying the provided schema.
Quality checks
- Validate against JSON-Schema in CI
- price ≥ 0 and ≤ 1 000 000
- in_stock is strictly boolean (no string "true")
When to use
Slack-to-ERP orders, lead-form normalisation, webhook payload shaping.
Complex transforms
For nested arrays or unions, split into two prompts: (1) extract raw, (2) validate/transform. Smaller prompts compose better.
Growing the Library
Once these four patterns are team muscle memory, extend the library vertically:
- Domain specialisation (medical, finance, legal)
- Multi-step chains (summarise → classify → extract)
- Conditional routing (if summary length > 300 words, use abstractive pattern B)
Store each extension as a branched variant so the original remains untouched. Future you will thank present you when audit season arrives.
Takeaway
Prompt patterns turn one-off prompt hacking into repeatable components. Start with the four above, enforce the I/O contracts, and wire in the tiny quality checks. When the next fire-drill lands, you will spend minutes swapping a version tag, not hours rewriting prompts from scratch.
Copy the templates, commit them to your prompt repo, and make prompt patterns as boring—and reliable—as any other library in your stack.