course contents
Architect Foundations · 20% of the exam
prompt engineering and structured output
share
Domain 3 configured the files around Claude. Domain 4 is about the output that comes back: the same shape every time, the right values inside it, and a check on both before anything downstream trusts them.
You are building a structured data extraction system with Claude. It reads unstructured documents, extracts the fields a downstream ledger needs, and validates each record against a JSON schema before it loads. Invoices, contracts, support emails and research reports arrive together, and nobody labels which is which. A record the system is unsure of goes to human review instead of the ledger.
The pieces you are responsible for:
max_tokens or refused. That near-zero is the trap, because a record can be valid JSON and still be wrong. Invoice INV-7731's line items sum to 1,140.00 under a printed total of 1,410.00, and an invoice marked "payable on receipt" came back with a due date because the schema required one. Both records parse, pass the schema and load into the ledger as correct.Each of the six sections below closes one gap between "valid" and "right", and the table after the vocabulary shows which mechanism closes which.
Start hereThe words this domain is built on
- structured output
- A response your code can parse into fields, which in this domain means JSON that matches a schema.
- JSON schema
- A JSON document describing the shape of other JSON: field names, their types, and which fields are
required. - enum
- A schema keyword listing the only values a field may take, such as
"freight"or"other". - extraction tool
- A tool definition whose
input_schemais the record you want, so theinputof Claude's call is your extracted data. - tool_choice
- The request parameter that says whether Claude may or must call a tool, which 4.3 covers.
- few-shot examples
- Worked input/output pairs placed in the prompt to show the model what to do with a case.
- semantic error
- A value with the right type in the right place that is still wrong, such as line items that do not sum to the total.
- false positive
- A finding that reports a problem that is not there, or, in extraction, a value the document does not support.
- Message Batches API
- An asynchronous endpoint that takes many requests at once, costs 50% less, and returns results within 24 hours.
- tool_use, tool_result
- The response block in which Claude calls a tool, and the block your code sends back with the tool's output. Domain 1 covers both.
- stop_reason, max_tokens
- The response field saying why Claude stopped, and the request's output limit, which cuts off a response that reaches it.
- extended thinking
- A request setting that gives Claude a budget of reasoning tokens before it answers.
- Claude Code
- Anthropic's command-line coding agent, which
claude -pruns non-interactively in the CI scenario. - subagent
- A separate Claude session with its own context window.
| Only findings worth reporting (4.1) | Categories to report and to skip, with a code example for each severity level, rather than a request to be careful. |
| Consistent handling of ambiguous cases (4.2) | Two to four targeted few-shot examples, each with the reasoning for its answer. |
| Valid JSON, right types (4.3) | A tool with a strict JSON schema, plus a stop_reason check for a cut-off or refused response, since prompting for JSON only makes it likely. |
| Values that are actually right (4.3, 4.4) | Your validator, with a retry that sends the specific errors if the value is in the document, and otherwise null or a conflict flag for human review. |
| Results in time, at the lowest cost (4.5) | The synchronous API when someone is waiting. Otherwise the Message Batches API, submitted often enough to fit the SLA. |
| A review that questions the code (4.6) | A second independent Claude instance, with one pass per file plus an integration pass. |