# Few-shot examples for consistent output

*Claude Certified Architect - Foundations Study Guide · Prompt Engineering & Structured Output · Last updated October 22, 2026 · https://www.certifyforce.com/study-guide/claude-certified-architect-foundations/prompt-engineering-and-structured-output/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.

- Certification: Claude Certified Architect - Foundations
- Exam section: Prompt Engineering & Structured Output
- Study guide: https://www.certifyforce.com/study-guide/claude-certified-architect-foundations

**Official exam objective:**

> Apply few-shot prompting to improve output consistency and quality

## 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

| Fact | Detail | Source |
|---|---|---|
| Examples vs instructions | Examples are more effective than abstract instructions for consistent output | [Increase output consistency](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/increase-consistency) |
| How many | Exam guide: 2-4 targeted examples for ambiguous cases; docs: 3-5 for best results | [Exam guide](https://everpath-course-content.s3-accelerate.amazonaws.com/instructor%2F6nizmqk8tpzpfjvt6qmmav7rh%2Fpublic%2F1783542750%2FClaude+Certified+Architect+%E2%80%93+Foundations+Exam+Guide.pdf), [Prompting best practices](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices) |
| Good examples | Relevant, diverse (edge cases), structured in `<example>` / `<examples>` tags | [Prompting best practices](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices) |
| Worked examples | Problem, method to apply, expected answer | [Prompting best practices](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices) |
| Prefill | Not supported on Claude 4.6 and later models | [Increase output consistency](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/increase-consistency) |
| Saying "I don't know" | Explicit permission drastically reduces false information | [Reduce hallucinations](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/reduce-hallucinations) |
| `input_examples` validity | Each must validate against `input_schema`; invalid returns 400 | [Define tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools) |
| `input_examples` cost | About 20-50 tokens simple, 100-200 complex nested | [Define tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools) |
| `input_examples` scope | Not supported on server tools such as web search | [Define tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools) |

## Check yourself

- 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`?

## Sources

- [Prompting best practices](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices)
- [Claude Certified Architect – Foundations Exam Guide v1.0](https://everpath-course-content.s3-accelerate.amazonaws.com/instructor%2F6nizmqk8tpzpfjvt6qmmav7rh%2Fpublic%2F1783542750%2FClaude+Certified+Architect+%E2%80%93+Foundations+Exam+Guide.pdf)
- [Increase output consistency](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/increase-consistency)
- [Reduce hallucinations](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/reduce-hallucinations)
- [Define tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 11 linked practice questions, and unlimited timed mock exams are included with the Claude Certified Architect - Foundations pack (USD $19): https://www.certifyforce.com/practice-exams
