What is Prompt Engineering?
Read a little, play a little. No scary maths, and no rush.
Programming in English (with a forgetful genius)
Prompt engineering is writing instructions a brilliant, literal-minded, context-free assistant will follow reliably. The model doesn't know your task, your data, or your format standards — everything must arrive in the prompt. Think of prompts as contracts with five clauses:
- Instruction — the job: "Summarize this ticket."
- Context — the material: pasted text or RAG chunks.
- Examples — 1–3 input→output pairs showing the pattern (few-shot).
- Output contract — format, length, tone: "3 bullets, under 20 words each."
- Fallback — what to do when stuck: "say NOT FOUND instead of guessing."
Bad vs good, side by side
Bad: "Summarize docs." (Which docs? How long? What format? Guess?)
Good: "Using only the CONTEXT below, write 3 bullets under 20 words each, cite sources like [1], else say NOT FOUND." Every clause earns its place: scope (only context), shape (3 bullets), size (20 words), trust (citations), honesty (fallback).
Why this is engineering, not vibes
Prompts get versioned, A/B-tested on eval sets, and reviewed like code — because a one-word change can flip behavior. The discipline from software applies directly: be explicit, handle the failure case, and never trust what you haven't measured.
A worked example: three passes on one prompt
A team wants short summaries of support tickets for a dashboard.
- Pass 1: "Summarize this ticket." Summaries range from one line to four paragraphs. Some include the customer's phone number. On 20 test tickets, only 8 fit the dashboard's layout.
- Pass 2: add the contract. "Write one sentence under 25 words stating the customer's problem. Do not include contact details." Now 17 of 20 fit, but tickets with no clear problem produce invented ones.
- Pass 3: add a fallback and an example. "If the ticket does not describe a problem, write UNCLEAR," plus one example ticket and its ideal summary. All 20 now fit, and the 2 vague tickets are honestly marked.
Nothing about the model changed. Each pass closed a gap that the previous version left open, and each one was confirmed on the same 20 tickets rather than judged by eye.
Common mistakes
- Contradictory rules. "Be thorough" and "keep it brief" in the same prompt force the model to pick one at random.
- Only saying what not to do. "Don't be wordy" is weaker than "Answer in at most 3 sentences." Give the target, not just the thing to avoid.
- Too many jobs in one prompt. Summarize, classify, translate, and draft a reply all at once, and quality drops on each. Split the work into separate calls.
- Examples that disagree with the rules. If the rule says 3 bullets and the example shows 5, the example usually wins.
- Expecting wording to supply missing facts. No phrasing makes a model know your new policy. That needs retrieval, not a better prompt.
Remember this
- Instruction + context + examples + contract + fallback. Miss one and the model fills the gap with imagination.
Check your understanding
5 questions · first-try answers earn the most XP
My notes
Saved in this browser. Highlight a line above and save it, or write it in your own words.
Nothing saved yet. Your highlights will live here.
References
Finished reading?
Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.
Related chapters
Spotted a mistake or want a topic covered? Report an issue