Claude Partner Certificate — 4 · Prompting & Output
CC — 06

Domain 4 · Prompt Engineering & Structured Output

This domain covers writing prompts that give precise, consistent results, forcing structured output with schemas, validating and retrying extractions, and choosing between real-time and batch processing.

Read time9 min
Exam weight20%
Tasks4.1 to 4.6
SectionClaude Partner Certificate

Videos: Ep 14 to Ep 17

Key terms: Prompt: the instructions you give Claude. Few-shot example: a worked example placed inside the prompt. JSON schema: a description of the exact shape of the data you want back. Extraction: pulling structured data out of documents. Batch: many requests processed together, later.

01 — task 4.1

4.1 Design prompts with explicit criteria to improve precision and reduce false positives

What it is: A prompt works best when it says exactly what to report and what to ignore. Vague instructions like "be careful" or "only report if you are confident" do not make Claude more accurate; named categories do. Fewer false alarms means developers keep trusting the results.

Severity levels: Name them explicitly, for example CRITICAL, HIGH and MEDIUM, and define each one with a short code example instead of describing it in words.

The exam tests: why specific, categorical criteria beat general instructions. Video: Ep 14.

Full notes

Rule: Explicit criteria beat vague instructions. "Flag a comment only when its claim contradicts what the code does" works better than "check that comments are accurate".

Rule: General instructions such as "be conservative" or "only report high-confidence findings" do not improve precision the way specific categories do. Define what to report (bugs, security) and what to skip (minor style, local patterns).

Rule: A category with many false positives undermines trust in the accurate ones. Disable it temporarily while you improve its prompt. The course uses a 60% or higher false positive rate as an example.

Rule: Define each severity level with a concrete code example, so classification stays consistent. Do not describe severity only in words.

✗
Trap
Adding "be conservative" or "report only if confident" and expecting precision to improve.

Deep dive

02 — task 4.2

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

What it is: A few-shot prompt includes a small number of worked examples, so Claude can see what a good answer looks like. It is the best fix when instructions alone give inconsistent output, especially for borderline cases.

The exam tests: what few-shot examples do that instructions cannot. Video: Ep 15.

Full notes

Rule: Few-shot examples are the most effective way to get consistently formatted, actionable output when detailed instructions alone give inconsistent results. Instructions describe what you want. Examples show what it looks like.

Rule: Use 2 to 4 targeted examples for ambiguous cases. Show the reasoning for why one action was chosen over the plausible alternatives. Reasoning-driven examples beat output-only ones.

Rule: Include examples of the exact output format you want, such as location, issue, severity and suggested fix.

Rule: Show acceptable code patterns next to genuine issues. This cuts false positives and lets the model generalize to patterns you did not list.

Rule: For extraction, examples of varied document structures (inline citations versus bibliographies, methodology sections versus details embedded in text) reduce hallucination and empty or null results.

✗
Trap
Writing a longer instruction when the real gap is that the model has never seen what a good answer looks like.

Deep dive

03 — task 4.3

4.3 Enforce structured output using tool use and JSON schemas

What it is: Structured output means getting data in a fixed shape, like JSON, that other code can use. The reliable way is to define a tool with a JSON schema and have Claude fill it in. That guarantees the shape of the data, but not that the values are correct.

The exam tests: how tool use with a schema guarantees structure, and what it does not guarantee. Video: Ep 16.

Full notes

Rule: tool_use with a JSON schema is the most reliable way to get schema-compliant output. It removes JSON syntax errors.

Rule: A valid schema does not prevent semantic errors, such as line items that do not add up to the total or a value in the wrong field. Structurally correct is not the same as logically correct.

Rule: tool_choice set to "any" guarantees a tool call when several extraction schemas exist and the document type is unknown. A forced tool, {"type": "tool", "name": "extract_metadata"}, makes one specific extraction run first.

Rule: Make fields optional (nullable) when the source may not contain the information. A required field pushes the model to invent a value.

Rule: Add an "unclear" enum value for ambiguous cases, and "other" plus a detail string for categories that can grow.

Rule: Put format normalization rules in the prompt alongside the strict schema, to handle inconsistent source formatting.

✗
Trap
Treating output that matches the schema as output that is correct.

Deep dive

04 — task 4.4

4.4 Implement validation, retry and feedback loops for extraction quality

What it is: Even a well-formed extraction can contain mistakes, such as totals that do not add up. A validation loop checks the result and, if something is wrong, asks Claude again with the specific error. This works for format mistakes, but not when the information is missing from the source.

The exam tests: how to correct a failed extraction, and when retrying is pointless. Video: Ep 16.

Retry only when the information is in the source

flowchart LR E["Extract<br/>tool_use + JSON schema"] --> V{"Validate<br/>schema and semantic checks"} V -- pass --> D["Done<br/>use the extraction"] V -- fail --> Q{"Is the information in the source document?"} Q -- yes --> R["Retry with feedback<br/>original + failed output + the specific error"] R --> E Q -- no --> S["Stop retrying<br/>return null or route to human review"]

Full notes

Rule: Retry with error feedback. The follow-up request includes the original document, the failed extraction and the specific validation error.

Rule: Retries fix format and structure problems. They cannot fix a field whose information is absent from the source, such as data that lives in an external document you did not provide.

Rule: Semantic validation errors (values that do not add up, a value in the wrong field) are separate from schema syntax errors, which tool use already removes.

Rule: Build self-correction checks: extract calculated_total next to stated_total to flag a mismatch, and add a conflict_detected boolean for inconsistent source data.

Rule: A detected_pattern field in each finding lets you analyze which constructs trigger findings, and spot false positive patterns when developers dismiss them.

✗
Trap
Retrying again and again on a field that is simply not in the document. Stop and route it to human review.

Deep dive

05 — task 4.5

4.5 Design efficient batch processing strategies

What it is: The Message Batches API processes many requests together at half the cost, but results can take up to 24 hours, so nobody can wait on them. It suits overnight or weekly jobs, not checks that block a developer. Each request carries a custom ID so you can match answers back to questions.

The exam tests: which workloads suit the Message Batches API, and how to run it reliably. Video: Ep 17.

Use Batch only when nobody waits and no turns are needed

flowchart LR A{"Is anyone waiting for the response to continue?"} -- no --> B{"Do we need to take turns to get the result (tool calls)?"} B -- no --> C["Batch API"] A -- yes --> S["Standard API (Messages API)"] B -- yes --> S
Standard (Messages API)Batch
CostFull price50% less
ResponseReal timeUp to 24 hours, no guaranteed latency
Tool callingMulti-turn supportedNot within a single request

Full notes

Rule: The Message Batches API gives 50% cost savings, a processing window of up to 24 hours, and no guaranteed latency SLA.

Rule: Use it for non-blocking, latency-tolerant work such as overnight reports, weekly audits and nightly test generation. Do not use it for blocking work such as a pre-merge check.

Rule: Use custom_id to match each response to its request. When some fail, resubmit only the failed documents, found by custom_id, with a fix such as chunking documents that exceeded the context limit.

Rule: Work out submission frequency from the SLA. Example: submitting every 4 hours plus a 24-hour processing window is 28 hours at worst, which fits inside a 30-hour SLA.

Rule: Refine the prompt on a small sample before you process a large volume, to raise first-pass success and avoid costly resubmission.

✗
Trap
Moving a blocking pre-merge check to batch to save money.

Deep dive

06 — task 4.6

4.6 Design multi-instance and multi-pass review architectures

What it is: Claude is less likely to find faults in work it just produced, because it remembers its own reasoning. A better review uses a fresh, independent instance. For large changes, review each file on its own, then check how the files fit together.

The exam tests: why a model reviews its own work poorly, and how to structure larger reviews. Video: Ep 17.

Multi-pass review: depth, then breadth

flowchart LR A["Per-file review"] --> X["Cross-file review<br/>breadth: dependency mismatches, integration issues"] B["Per-file review"] --> X C["Per-file review"] --> X

Depth comes from parallel, independent per-file instances.

Full notes

Rule: A model keeps the reasoning from when it generated the work, so it is less likely to question its own decisions in the same session.

Rule: An independent instance, with no access to the generator's reasoning, catches subtle issues better than self-review instructions or extended thinking.

Rule: Split a large review into per-file passes for local issues (depth) plus a separate cross-file pass for data flow and integration (breadth). This avoids attention dilution and contradictory findings.

Rule: In a verification pass, have the model report its confidence with each finding, so you can route reviews by calibrated confidence.

✗
Trap
Asking the same session to "review more carefully". Running several full passes and keeping only issues found twice is also wrong, because it can hide real bugs.

Deep dive