Few-shot prompting means giving Claude concrete examples of desired input/output pairs. Itβs one of the most reliable ways to control response quality.
<instructions>
Classify the customer message as one of: billing, technical, account, other.
Respond with JSON only.
</instructions>
<examples>
<example>
<input>I can't log into my account</input>
<output>{"category": "account"}</output>
</example>
<example>
<input>My invoice shows the wrong amount</input>
<output>{"category": "billing"}</output>
</example>
<example>
<input>The app crashes when I upload a file</input>
<output>{"category": "technical"}</output>
</example>
</examples>
<message>
I want to change my subscription plan
</message>
Why this works: Claude infers your desired format, length, tone, and classification logic from examples far more reliably than from lengthy written instructions alone. Three to five examples is the sweet spot, enough to establish a pattern without wasting tokens.
Pro tip: Include at least one edge case or ambiguous example to show Claude how you want those handled.