Skip to content
Claude Certified Architect – Foundations (CCAR-F) Exam Prep

Lesson 20 of 30 · 6 min

x
20/30

Few-Shot Prompting

Video lesson: CCAR-F 20/30: Few-Shot Prompting

Guidance

Examples are "one of the most reliable ways to steer Claude's output format, tone, and structure". Make them:

  • Relevant: mirror your real use case.
  • Diverse: cover edge cases and vary enough that Claude does not pick up unintended patterns.
  • Structured: wrap in <example> tags (several in <examples>) so they are not confused with instructions.

Anthropic suggests 3 to 5 examples, and says you can ask Claude to evaluate your examples for relevance and diversity or to generate more from your initial set.

When examples help most (design guidance)

  • Ambiguous cases where a rule is hard to state but easy to show (is this complaint a billing issue or a product defect?).
  • Format consistency (exact JSON shape, tone, length).
  • Boundary cases: include examples that look reportable but are not, and say why.
  • Extraction from messy input: show a messy source and the exact target record, including how missing information is represented.

Building a good set

  1. Start from real failures: add an example for each mistake pattern you see.
  2. Include the reasoning or label rationale briefly where the distinction is subtle.
  3. Cover negative examples (what not to output).
  4. Keep examples consistent with the instruction text; a mismatch teaches the wrong thing.
  5. Re-evaluate on a held-out test set after adding examples, since examples can overfit narrow patterns.

Examples vs tool input_examples

For tools, use the input_examples field (schema-validated, adds tokens) to show valid inputs; see 2.1.

Exam traps

  • Examples that are all the same shape, so Claude copies the surface pattern.
  • One example only, or dozens that bloat the prompt.
  • Examples that contradict the instructions.
  • Using examples to hide an unclear criterion instead of stating it (4.1).
  • No negative examples for borderline cases.

References

  1. Prompting best practices — checked Oct 16, 2026

Check your understanding

  • A classifier mislabels borderline cases despite a clear rule. Next step?Show answer

    Answer

    Add few-shot examples of the borderline cases with correct labels.
  • Recommended number of examples?Show answer

    Answer

    Around 3 to 5, relevant and diverse.
  • How do you mark examples so Claude does not treat them as instructions?Show answer

    Answer

    Wrap in <example> / <examples> tags.
Previous

Progress is saved in this browser.

Next Lesson