TechNuggets Academy

Prompt Engineering and Structured Output

Free Claude Certified Architect - Foundations practice — 6 questions on Prompt Engineering and Structured Output, with explanations. No sign-up. Full 12-question mixed test →

Question 1 of 6 · Prompt Engineering and Structured Output
You're building a document extraction pipeline that calls Claude with three available tools: extract_invoice, extract_receipt, and extract_contract. For a given document type, you already know with certainty which single tool must be called every time, and you need the response to always be that exact tool call with no possibility of Claude choosing a different tool or responding in plain text. Which tool_choice configuration should you use?
Setting tool_choice to {"type": "tool", "name": "extract_invoice"} forces Claude to call exactly that named tool on every turn, guaranteeing both that a tool call happens and which one it is -- the only configuration that removes all ambiguity.
Question 2 of 6 · Prompt Engineering and Structured Output
You maintain a classification prompt with few-shot examples for a support-ticket router with 6 possible categories. Accuracy has plateaued even after you grew the example set from 4 examples to 14 examples, all drawn from the same 'typical' tickets. What is the most likely cause and correct fix according to few-shot prompting best practice?
Few-shot performance is driven far more by example diversity and coverage of edge cases/rare classes than by raw quantity; once examples are homogeneous, adding more near-duplicates yields diminishing or zero returns, and the fix is to curate a smaller, more representative set.
Question 3 of 6 · Prompt Engineering and Structured Output
Your pipeline calls Claude with a tool definition requiring a strict JSON schema, then programmatically validates the tool input against that schema. Roughly 4% of responses fail schema validation (missing required fields or wrong types). What retry strategy best fits production reliability practice for structured output?
Feeding the specific validation failure back to Claude (the exact missing/invalid fields and the schema violation) lets the model make a targeted correction, which is far more reliable than blind retries and is the standard validate-then-repair loop pattern for production structured output.
Question 4 of 6 · Prompt Engineering and Structured Output
A company needs to generate structured summaries for 120,000 archived support tickets once per night as a backfill job; results are consumed by an analytics dashboard the next morning, and no individual ticket result is needed sooner. Which approach BEST meets these requirements?
The Message Batches API is purpose-built for exactly this profile: large volume, no real-time latency requirement, processed asynchronously within a 24-hour window, at a substantial cost discount versus synchronous calls -- a clear architectural fit for an overnight batch job.
Question 5 of 6 · Prompt Engineering and Structured Output
You've written a single, carefully engineered prompt for generating compliance-sensitive customer communications, with explicit instructions covering tone, required disclosures, and prohibited claims. Despite this, roughly 1 in 20 outputs still violates one of the prohibited-claims rules. Which architectural change best addresses this without abandoning the existing prompt?
This is the multi-pass review pattern: a dedicated second pass whose sole job is to check the first pass's output against explicit success criteria catches violations that single-pass generation misses, because evaluation and generation are different tasks and benefit from separate, focused prompts.
Question 6 of 6 · Prompt Engineering and Structured Output
A prompt for a legal-document summarizer currently instructs Claude to 'write a clear, accurate summary of the contract.' Summaries vary widely in length, level of detail, and whether clause citations are included, making automated downstream validation impossible. What change best establishes explicit, testable success criteria for this prompt?
Explicit success criteria must be concrete and testable -- specific numeric constraints (word count), structural requirements (citing section numbers), and concrete prohibitions (no jargon) each give both the model and an automated validator something unambiguous to check, which vague adjectives like 'clear' and 'accurate' cannot provide.
Ready for the real thing?

The full course has two full-length practice tests, video lessons for every exam domain, hands-on labs and detailed answer explanations.

Start my full course on Udemy →