Prompt Engineering · 92 pages
Prompt Engineering Patterns
A field guide to reliable prompting patterns — structure, examples, guardrails, and injection defense.
Contents
- Structure over cleverness
- Few-shot and chain-of-thought
- Structured output and schemas
- Instruction hierarchy and injection defense
- Testing and versioning prompts
Free preview
Good prompting is less about clever wording and more about structure. Models follow clearly separated instructions, context, and examples far more reliably than a wall of prose. The patterns in this guide are the ones that survive contact with production.
Separate the parts
Wrap instructions, retrieved context, and user input in distinct tagged sections. This makes long prompts maintainable and, crucially, helps the model tell trusted instructions apart from untrusted input — the foundation of injection defense.
<system>Answer only from the context. If unsure, say you don't know.</system>
<context>{{retrieved_docs}}</context>
<user>{{question}}</user>- Put durable rules in the system section
- Give 2–3 diverse few-shot examples for format, not volume
- Ask for structured output when code will parse the result
- Treat retrieved and user text as lower-priority than system rules
Prompts are software. Version them, lint them for missing variables, and gate changes behind an eval — a reworded instruction can quietly regress quality.
Want the full guide?
Join the newsletter and we'll send you the complete guide and new releases.