AI Codex
Prompt Engineering

Few-shot Prompting

Giving Claude examples of what you want before asking it to do the thing. Instead of just saying "classify this customer message as positive, neutral, or negative," you first show it 3-4 examples of messages with the right label, then give it the new message. Seeing examples helps Claude understand exactly what you mean — especially when your definition of "positive" or "formal" might differ from Claude's default interpretation.

In practice

You want Claude to extract product names from messy customer feedback in a specific format. Instead of just describing the format, you show it three examples: input → output, input → output, input → output. Then you give it the real input. The examples teach it exactly what you want — that's few-shot prompting, and it often works better than instructions alone.

Related concepts