Prompt Engineering & Structured Output20% of the exam

Few-shot examples for consistent output

When and how to add few-shot examples: format demonstrations, targeted ambiguous cases with reasoning, acceptable-versus-genuine pairs, varied document structures and informal values left null, diverse examples in <example> tags, worked examples, and tool input_examples.

Official exam objective
Apply few-shot prompting to improve output consistency and quality

~8 min read · 11 practice questions ·

What the exam expects

  • Recognise few-shot examples as the most effective fix when detailed instructions alone produce inconsistent, unactionable output, and reject restating, capitalising or prefilling as alternatives.
  • Write 2-4 targeted examples for ambiguous cases (tool selection, branch-level coverage gaps, resolve-or-escalate) that explain why one action beat a plausible alternative, covering both sides of the line.
  • Demonstrate an exact output format (location, issue, severity, suggested fix) and pair acceptable patterns with genuine issues to cut false positives while generalising to new code.
  • Use examples to fix extraction from varied document structures and to keep informal values as raw text with null fields instead of invented numbers.
  • Make examples diverse, wrap them in <example> / <examples> tags, show intermediate steps in worked examples, and know the rules for tool input_examples.

Key terms: few-shot (multishot) prompting (putting a few input-output examples in the prompt); targeted example (an example chosen for a case Claude gets wrong, not a typical one); contrastive pair (an acceptable pattern and a genuine issue side by side, each with its reason); worked example (problem, method, intermediate results, answer); input_examples (optional tool-definition field of schema-valid example inputs).

Key facts

Examples vs instructions
Detail
Examples are more effective than abstract instructions for consistent output
How many
Detail
Exam guide: 2-4 targeted examples for ambiguous cases; docs: 3-5 for best results
Good examples
Detail
Relevant, diverse (edge cases), structured in <example> / <examples> tags
Worked examples
Detail
Problem, method to apply, expected answer
Prefill
Detail
Not supported on Claude 4.6 and later models
Saying "I don't know"
Detail
Explicit permission drastically reduces false information
input_examples validity
Detail
Each must validate against input_schema; invalid returns 400
input_examples cost
Detail
About 20-50 tokens simple, 100-200 complex nested
input_examples scope
Detail
Not supported on server tools such as web search
Sources for this section (5)
  • Why do three near-identical examples sometimes make extraction worse?
  • When are targeted few-shot examples the right fix rather than more instructions?
  • Why wrap samples in <example> tags?
  • What happens if an input_examples entry does not match the tool's input_schema?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the Claude Certified Architect - Foundations pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 30 lessons of the Claude Certified Architect - Foundations guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (11 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the Claude Certified Architect - Foundations exam

Certifyforce is an independent study resource and is not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic.