Suryanand/ Bootcamp
suryanand.com ↗Let's talk
← FoundationsAI guideBeginner#foundations#prompting#prompt-engineering
Frame · ai-engineering / foundations / 06-prompt-engineering-patterns.mdGuide 006 / 103

Prompt engineering patterns that still matter

A lot of 2023-era prompt folklore has aged badly. You no longer need to bribe the model, threaten it, or chant "think step by step" at a reasoning model that already thinks. What survived is less magical and more like writing a good brief for a smart contractor who has zero context about your company: say what you want, why, what good looks like, and how to format it. This doc collects the patterns I still use every week.

Why it matters

The prompt is the cheapest lever you have. A clearer instruction costs nothing at runtime, while a bigger model costs money on every call. Good prompts also make systems easier to maintain: when a teammate can read the system prompt and understand the intended behavior, they can debug it. And as Anthropic's context engineering guide points out, the prompt is now one component of a larger context, so it needs to play well with tools, retrieved documents and history.

How it works

A modern prompt has a predictable anatomy. The system prompt sets role, goal, constraints and output format. The user turn carries the task and its inputs, clearly delimited. Examples show the target behavior. Optional prefill or structured output settings lock down the format.

Rendering diagram…

The patterns

  1. Be explicit about the goal and the reader. "Summarize this" is vague. "Summarize this incident report for an on-call engineer who needs to decide in 30 seconds whether to page the database team" gets a different, better answer.
  2. Explain why a rule exists. "Never use ellipses because a text-to-speech engine will read this aloud" generalizes better than the bare rule, because the model can reason about related cases.
  3. Delimit inputs. Wrap documents, user content and data in tags such as <document>, <email> or <data>. Anthropic's docs note there are no special tag names Claude was trained on; pick descriptive names and use them consistently. Delimiters also reduce prompt injection risk by making it clear what is data and what is instruction.
  4. Show, do not just tell. A few diverse examples (Anthropic's guidance suggests a handful, covering edge cases) beat paragraphs of description. Wrap them in <examples> so they are not confused with the real input.
  5. Specify the output contract. Say exactly what shape you want. For machine-read output, use structured outputs instead of prose instructions.
  6. Tell the model what to do, not only what to avoid. "Write in flowing paragraphs" works better than "do not use bullet points".
  7. Give an escape hatch. "If the document does not contain the answer, reply exactly NOT_FOUND" is the simplest hallucination reducer there is.
  8. Put long documents first, question last. For long contexts, placing reference material above the instructions and query tends to work better.
  9. Ask for evidence. Request quotes or section references alongside answers so you can verify them.

Chain-of-thought prompting (asking the model to reason before answering) was a big deal for older models. For reasoning models, use the provider's thinking controls instead of hand-written "think step by step" instructions.

Reference architecture

Treat prompts as versioned artifacts with tests, not strings buried in code.

Rendering diagram…

Code

A classification prompt that uses most of the patterns: a clear goal, reasons, tagged input, examples and an escape hatch.

import anthropic

client = anthropic.Anthropic()

SYSTEM = """You triage customer support emails for a payments company.
Your label decides which team sees the email first, so precision matters more than speed.

Labels: billing, fraud, technical, other.
Use fraud whenever money moved without the customer's consent, even if they also mention a bug,
because fraud cases have a legal response deadline.
Reply with only the label. If the email is empty or not a support request, reply other."""

EXAMPLES = """<examples>
<example><email>I was charged twice for my March invoice.</email><label>billing</label></example>
<example><email>There's a $400 payment I never made, and the app crashed when I tried to dispute it.</email><label>fraud</label></example>
<example><email>Webhook deliveries are failing with 500 errors since this morning.</email><label>technical</label></example>
</examples>"""

def triage(email: str) -> str:
    response = client.messages.create(
        model="claude-haiku-4-5",
        max_tokens=10,
        system=SYSTEM,
        messages=[{
            "role": "user",
            "content": f"{EXAMPLES}\n\nClassify this email.\n<email>{email}</email>",
        }],
    )
    return response.content[0].text.strip()

print(triage("Someone used my card in another country and the dashboard won't load."))

The second example deliberately shows the tricky case (fraud plus a bug), which teaches the priority rule better than the instruction alone.

Trade-offs and pitfalls

  • Over-specified prompts. Pages of rules make models rigid and contradictory. Prefer principles plus examples, and prune rules that evals show are unnecessary.
  • Examples that are too similar. The model copies surface features. Vary length, tone and topic across examples.
  • Emphatic shouting. ALL CAPS and "CRITICAL" can cause overreaction in capable models, applying a rule where it does not belong. Calm, specific wording works better.
  • Prompt drift across models. A prompt tuned for one model may underperform on another. Re-run evals when you switch.
  • Injection. Delimiters help but do not solve prompt injection. Never give a model tools or permissions that untrusted input could abuse without checks.
  • Untested changes. A one-word edit can shift behavior. Version prompts and run an eval before deploying.

Checklist

  • The system prompt states the goal, the audience and why key rules exist.
  • Inputs are wrapped in consistent, descriptive tags.
  • Three to five varied examples cover the hard cases.
  • There is an explicit fallback answer for missing information.
  • Machine-read outputs use structured output features, not prose instructions.
  • Prompts live in version control with an eval suite.
  • Prompts are re-evaluated whenever the model changes.

Further reading

Why this exists README

I learn best by explaining things, so I record the explanations. Everything here is free, with no sign-up. If a lesson helps you ship something, I'd love to hear about it.