1 / 11
Fundamentals
Zero-shot prompting
BeginnerIn short: Ask directly, with no examples.
What is: Give a clear instruction without showing example answers, the model uses only what it learned in training. "Zero-shot" = zero examples. It's the starting point of everything.
When to use: Common, well-defined tasks the model already handles: translating, summarizing, answering a factual question, rewriting a text.
When to avoid: When the exact format, tone, or edge cases matter. Then a few examples (few-shot) beat any instruction.
The good one sets scope (the 4 Ps), format (one paragraph each) and context (coffee shop), unambiguous even without examples.
Say what to fix, what to preserve, and the output format.
💡 Tip: If the answer comes out generic, don't add examples yet: first make the instruction more specific (format, length, audience).
Role / Persona prompting
BeginnerIn short: Tell the model "who it is" before the task.
What is: Assign a role ("You are a senior tax lawyer") to calibrate tone, vocabulary and depth. A single sentence already changes the result.
When to use: When tone or technical level matter, writing, support, opinions, teaching.
When to avoid: On pure knowledge questions (facts, math, multiple choice) the persona can HURT. On the MMLU benchmark, "expert" personas dropped accuracy (from ~71.6% to ~68%).
The role focuses the model on the mindset of someone hunting for flaws.
Persona + audience set the level of the explanation.
💡 Tip: Use persona for TONE and STYLE; don't expect "You are a math genius" to improve the arithmetic. For accuracy, prefer clear instructions and verification.
Few-shot / Multishot
BeginnerIn short: Show 2 to 5 example answers before asking for your case.
What is: Include a few input→output examples for the model to imitate the pattern. "Few-shot" = few examples. It's the strongest lever for format, tone and consistency.
When to use: When the exact format matters (JSON, table), tone must be consistent, or the classification is hard.
When to avoid: On trivial tasks (zero-shot already works) or when examples bias toward a single pattern, then diversify or reduce.
Two examples fix the output format and vocabulary; include a negative case so it doesn't bias positive.
💡 Tip: 3 to 5 examples is the sweet spot. Use DIVERSE examples (cover edge cases) and mind the ORDER, example permutation can shift accuracy a lot.
Structuring with XML / delimiters
BeginnerIn short: Separate instruction and data with "tags".
What is: Wrap each part of the prompt in markers (<context>, <data>, <instructions>) so the model doesn't confuse a command with the material to process.
When to use: Whenever the prompt mixes instruction with data, especially long data or data with its own formatting. It's the recommended pattern for Claude.
When to avoid: On short one-line prompts with no embedded data, it's unnecessary.
The tag makes clear what is data and what is instruction, no ambiguity.
💡 Tip: Use consistent, descriptive tag names. Nest them when there's hierarchy (several <document> inside <documents>).
Context + motivation
BeginnerIn short: Explain the why behind the instruction, not just the order.
What is: Give background and the reason behind the request. The model generalizes better when it understands the goal, not just the rule.
When to use: Whenever a rule could be misread if taken literally without understanding its purpose.
When to avoid: It rarely hurts, but don't pad with irrelevant context, which becomes noise and wastes the model's attention.
Knowing the why, the model applies the rule sensibly and anticipates similar cases.
💡 Tip: One sentence of "why this matters" is often worth more than three sentences of "do it this way".
Output contract
BeginnerIn short: State the EXACT format of the answer.
What is: Specify how the output should come: JSON schema, tags, "result only, no preamble", length. Say what to do, not what to avoid.
When to use: Whenever the answer is consumed by a system (parsing) or needs a consistent format across calls.
When to avoid: In free or exploratory conversation, a rigid contract can straitjacket answers that would benefit from flexibility.
An explicit schema + "null for missing" stops the model from inventing data.
💡 Tip: To truly enforce JSON/structure, use Structured Outputs (Claude/OpenAI) instead of just asking in text, it's far more reliable.