Prompt Engineering — Quick Reference
Prompt Engineering & Structured Output · 20% of the exam. Density over narrative — this is for review, not first-pass learning.
Where instructions live
System prompt: role, constraints, behavior for the whole conversation. User message: per-turn task/content. Don't put per-turn specifics in the system prompt.
When to use few-shot
Desired output format is precise but hard to describe in words — show, don't just tell.
When to use chain-of-thought
Genuinely multi-step reasoning tasks. Skip it for simple lookups or classification — it adds latency/cost without benefit.
Guaranteeing format
Prefill the start of the response (e.g. with {) to force structure at the source, then validate the full output against a schema.
Handling invalid structured output
Re-prompt with the specific validation error, not a generic 'try again.' A bare retry tends to repeat the same mistake.
Batch vs real-time
Large non-interactive workload, latency not critical → Batches API. Anything a user is waiting on → standard synchronous call.
Self-review anti-pattern
A single call asked to generate and then check its own work tends to rubber-stamp itself. Use a separate call/pass for review.