PromptCause
Donate

1 / 11

Fundamentals

Zero-shot prompting

Beginner

In 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.

Wrong
tell me about marketing
Right
Explain the 4 Ps of marketing (product, price, place, promotion) in one paragraph each, with an example from a coffee shop.

The good one sets scope (the 4 Ps), format (one paragraph each) and context (coffee shop), unambiguous even without examples.

Wrong
fix my text
Right
Fix grammar and punctuation errors in the text below. Keep the meaning and tone. Return only the corrected text.

Say what to fix, what to preserve, and the output format.

Why: Modern models handle known tasks well without examples, as long as the instruction is specific. Clarity replaces examples.

💡 Tip: If the answer comes out generic, don't add examples yet: first make the instruction more specific (format, length, audience).

Role / Persona prompting

Beginner

In 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%).

Wrong
Is there a security issue in this code?
Right
You are a pentester reviewing code for an audit. Analyze the code below for injection, exposed secrets and weak authentication.

The role focuses the model on the mindset of someone hunting for flaws.

Wrong
explain recursion
Right
You are a patient teacher explaining to a 10-year-old. Explain recursion with an everyday analogy.

Persona + audience set the level of the explanation.

Why: The role activates the vocabulary and tone tied to that profile. But the effect is task-sensitive: it helps with tone, rarely with factual knowledge.

💡 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

Beginner

In 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.

Right
Classify the sentiment. Follow the examples: "Loved it, recommend!" → positive "Arrived broken." → negative Review: "Came fast but dented." →

Two examples fix the output format and vocabulary; include a negative case so it doesn't bias positive.

Why: Few-shot comes from the GPT-3 research (Brown et al., 2020): models learn the task from the prompt examples alone (in-context learning). Studies show jumps like F1 0.51 → 0.62 going from zero to 3 examples.

💡 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

Beginner

In 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.

Wrong
Summarize: Today's meeting: we delayed the launch. Summarize the risks too. Budget ok.
Right
Summarize the content inside <text> in 3 bullets. <text> Today's meeting: we delayed the launch. Budget ok. Risks: reduced team and tight deadline. </text>

The tag makes clear what is data and what is instruction, no ambiguity.

Why: Tags reduce the ambiguity between instruction and content, the most common error in prompts with embedded text. Models trained on structured data (like Claude) follow tags precisely.

💡 Tip: Use consistent, descriptive tag names. Nest them when there's hierarchy (several <document> inside <documents>).

Context + motivation

Beginner

In 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.

Wrong
Never use ellipses.
Right
This answer will be read by a text-to-speech engine that doesn't pronounce ellipses correctly, so don't use "…".

Knowing the why, the model applies the rule sensibly and anticipates similar cases.

Why: When the model understands the motivation, it extends the rule to unspoken cases and avoids absurd applications. The bare instruction is a blind rule.

💡 Tip: One sentence of "why this matters" is often worth more than three sentences of "do it this way".

Output contract

Beginner

In 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.

Wrong
give me the customer data, no fluff
Right
Extract the customer data. Reply ONLY with this JSON, no text before or after. Use null for missing fields: {"name": string, "email": string|null, "phone": string|null}

An explicit schema + "null for missing" stops the model from inventing data.

Why: "No fluff" is subjective; a schema is objective and machine-parseable. Defining the format removes the variation that breaks integrations.

💡 Tip: To truly enforce JSON/structure, use Structured Outputs (Claude/OpenAI) instead of just asking in text, it's far more reliable.