Prompt Engineering & Structured Output
Key terms and definitions for Domain 4. Each entry includes a concise definition, exam context, and links to the relevant lesson.
10 of 10 terms
Chain of Thought
A prompting technique that asks Claude to show its reasoning step-by-step before providing a final answer. Improves accuracy on complex reasoning tasks by forcing intermediate reasoning steps.
Exam Context
Use chain of thought for complex reasoning, math, and multi-step analysis. Can be combined with XML tags to separate thinking from the final answer. Extended thinking is the API feature for this.
Few-Shot Example
Concrete input-output pairs included in the prompt to demonstrate the desired behavior. Examples teach Claude the expected format, style, and reasoning pattern more effectively than abstract instructions alone.
Exam Context
Include 2-5 diverse examples that cover edge cases. Place examples after instructions but before the actual input. Use consistent formatting between examples and the real task.
Output Validation
Verifying that Claude's response meets expected criteria before using it downstream. Includes JSON schema validation, content safety checks, format verification, and semantic correctness checks using a second LLM call.
Exam Context
Always validate structured output. Use tool_use for schema enforcement. For critical applications, add a separate validation step or LLM-as-judge evaluation.
Prefilling
Starting the assistant's response with specific text to guide Claude's output format or direction. Done by including a partial assistant message in the API call. Forces Claude to continue from the provided prefix.
Exam Context
Useful for forcing JSON output (prefill with opening brace), maintaining format consistency, or steering response direction. The prefilled content appears in the final response.
Prompt Chain
A sequence of Claude API calls where the output of one call feeds into the input of the next. Each step performs a focused transformation, validation, or decision. Chains decompose complex tasks into manageable steps.
Exam Context
Know when to chain versus when to use a single call. Chain when steps have different requirements (model, temperature, tools). Each step should have a clear, verifiable output.
Prompt Optimization
The iterative process of refining prompts to improve output quality, reduce cost, or increase reliability. Techniques include prompt compression, example selection, instruction clarification, and A/B testing against evaluation datasets.
Exam Context
Optimization is empirical: measure before and after with a consistent eval set. Common wins: clearer instructions, better examples, removing ambiguity, and adding output format constraints.
Structured Output
Techniques for getting Claude to respond in a specific format like JSON, XML, or a defined schema. Achieved through tool use (forces JSON matching the schema), system prompt instructions, or prefilling the assistant response.
Exam Context
Tool use is the most reliable method for structured output. Prefilling with an opening brace or tag is a useful technique. Always validate output against the expected schema.
System Prompt
The initial instruction block sent to Claude that establishes behavior, persona, constraints, and context for the entire conversation. System prompts are processed first and influence all subsequent responses.
Exam Context
Know that system prompts set the behavioral foundation. Keep them focused: role, constraints, output format. Avoid putting dynamic content in system prompts when it should be in user messages.
Temperature
A parameter (0.0 to 1.0) controlling randomness in Claude's responses. Lower values produce more deterministic, focused output. Higher values increase creativity and variation. Default is 1.0.
Exam Context
Use temperature 0 for structured output, classification, and extraction. Use higher temperature for creative tasks. Temperature does not affect the quality of reasoning, only the diversity of outputs.
XML Tags
A prompting technique using XML-style tags to structure input and output. Claude responds well to tags like <instructions>, <context>, <example>, and <output> for clearly delineating sections of complex prompts.
Exam Context
XML tags improve Claude's ability to follow complex multi-part prompts. Use them to separate instructions from data, mark example boundaries, and define output sections.