Skip to main content

Prompting by Example

Use Examples When Rules Are Hard to Describe

Few-shot prompting gives the model input/output examples before the real task. Instead of describing every rule, you show the pattern you want completed.

No examples
Classify this onboarding complaint:

"I wanted to try the dashboard, but it asked me to invite teammates before I knew what the product did."
Few-shot
Classify onboarding friction reports into one primary category: Copy, Flow, Permissions, Data model, Reliability.

Examples:
Input: "I don't understand what a workspace is."
Output: Copy — terminology blocks comprehension.

Input: "It asks me to invite teammates before I see value."
Output: Flow — sequence creates premature commitment.

Input: "I can't connect the billing data source without admin access."
Output: Permissions — access boundary blocks activation.

Now classify:
Input: "I wanted to try the dashboard, but it asked me to invite teammates before I knew what the product did."
Output:

Start with one example when the pattern is simple. Add more only when the output stays inconsistent, and prefer diverse examples that cover real boundary cases.

Reverse Prompt From an Ideal Output

When you already have an ideal output, don't guess the prompt from scratch. Give that output to the model and ask it to infer the instructions, constraints, structure, and validation criteria that would reproduce it.

Here is an example of the architecture decision record I want from an AI coding assistant:

[Paste one complete decision record whose structure and quality you want to reuse.]

Reverse-engineer the prompt that would produce this kind of decision record.

Infer:
- intended audience and decision scope
- required sections
- evidence requirements
- expected trade-off language
- constraints the reviewer must preserve

Return:
1. A reusable prompt template
2. The variables I should fill in for each decision
3. A validation checklist for testing whether the prompt reproduces this decision quality

Use multiple examples when the target output is complex. A single example helps you move fast, but several examples make the shared structure clearer and reduce invented constraints.


Next: Steering Retrieval and Multistep Work