Prompt Engineering Fundamentals
The cheapest lever in this whole track, and the one worth exhausting before reaching for RAG or fine-tuning.
Beginner
| System prompt | User prompt | |
|---|---|---|
| Set by | The application developer | The end user (or the app, on their behalf) |
| Purpose | Role, constraints, tone, output format, tools available | The actual task/question for this turn |
| Trust level | Instructions here are given more weight by most models | Should be treated as untrusted input if it comes from an end user — see Safety & Guardrails |
# zero-shot: just ask
"Classify the sentiment of this review as positive, negative, or neutral: {review}"
# few-shot: show 2-3 worked examples first, then the real input
Review: "Fast shipping, exactly as described." -> positive
Review: "Broke after two days." -> negative
Review: "It's fine, does the job." -> neutral
Review: "{review}" ->
Asking the model to reason step by step before giving a final answer measurably improves accuracy on multi-step problems (arithmetic, logic, multi-hop questions) — because each generated token can only depend on tokens already in the context, forcing intermediate steps into the output gives the model "scratch space" it wouldn't otherwise have. The failure mode: on simple tasks, forcing reasoning steps adds latency and cost for no quality gain, and can occasionally introduce errors that weren't there in a direct answer.
"Q: A store had 23 apples, sold 15, then received a shipment of 8.
How many apples now? Think step by step, then give the final answer."
| Pattern | Use it when |
|---|---|
| Ask for a specific output format up front (JSON schema, XML tags, markdown table) | Downstream code needs to parse the response reliably — see Structured Output |
| "If you don't know, say so" / explicit uncertainty instruction | Reducing confident wrong answers matters more than always producing an answer |
| Give the model a persona or role | Steering tone/register cheaply; less effective for steering actual capability |
| Break a complex task into an explicit numbered checklist in the prompt | Multi-part tasks where the model tends to skip a sub-step |