Course Content
Anatomy of a Prompt
Instructions, context, examples, and output format — the four components of every prompt
The Four Components of Every Effective Prompt
Every prompt — from a simple one-liner to a complex multi-step instruction — is built from four components. You don’t always need all four, but understanding them helps you diagnose why a prompt fails and how to fix it.
1. Instruction
The instruction is what you want the model to do. Be explicit and specific.
Weak: Summarize this.
Strong: Write a 3-sentence executive summary focusing on the business impact.
2. Context
Context is background information the model needs to complete the task. Without context, the model guesses — and guesses wrong.
You are reviewing a support ticket. The customer has been with us for 3 years and has a premium subscription.
Ticket: [TICKET TEXT]
Draft a response that acknowledges their loyalty and resolves their issue.3. Examples
Examples (few-shot) show the model exactly what you want. Often more effective than describing it.
Classify the sentiment. Reply with only the label.
Review: "Fast delivery, great product" → Positive
Review: "Broken on arrival" → Negative
Review: "It's fine, nothing special" →4. Output Format
Specify format explicitly — length, structure, tone, and medium.
- “Respond in exactly 3 bullet points”
- “Return valid JSON only, no explanation”
- “Write in second person, present tense”
Putting It Together
A complete prompt for a code review task:
You are a senior software engineer doing a code review. [ROLE]
The PR adds a new user authentication endpoint. Security is the top priority. [CONTEXT]
For each issue found, format your response as:
- **Severity**: Critical / High / Medium / Low
- **Location**: file:line
- **Issue**: one sentence
- **Fix**: one sentence
[FORMAT]