ClaudePrompt EngineeringStructured OutputCCA-FAnthropicJSON

Structured Output & Prompt Engineering for Claude (CCA-F)

Preporato TeamJuly 10, 202612 min readCCA-F
Structured Output & Prompt Engineering for Claude (CCA-F)

The moment you put Claude inside a program instead of a chat window, a new requirement appears: the output has to be parseable, every time, not just usually. A summary a human reads tolerates a stray sentence of preamble; a JSON object your code parses does not. Getting structure out of a probabilistic model reliably is a distinct skill, and together with prompting technique it makes up 20% of the CCA-F exam.

This guide covers the structured-output methods and the prompt-engineering patterns the exam tests, from the model's side of the tool-use relationship the tool design guide covers from the tool's side.

Getting Reliable JSON: Best to Worst

The exam expects you to rank the approaches, because reaching for the fragile one when a robust one exists is the classic wrong answer.

1. Tool use / function calling (most reliable). Define a tool whose input schema is the structure you want, and the model returns arguments matching that schema. This is the strongest method because the schema constrains generation: the model is filling a validated form, not free-writing JSON and hoping. When a scenario needs guaranteed-parseable structured data, this is the answer.

2. Prefilling the response. Start the assistant turn with { so the model continues from valid JSON rather than opening with "Sure, here's the JSON:". Prefilling steers the model into the format and skips the preamble that breaks parsers. Cheap and effective for straightforward shapes.

3. Explicit format instruction with an example. Tell the model the exact schema and show one filled example. Weaker than schema-constrained tool use because nothing enforces compliance, but fine for lenient consumers.

4. "Please return JSON" and hope (worst). Unconstrained requests produce preambles, trailing commentary, and markdown fences around the JSON. Any exam option that relies on this is the distractor.

A production pattern worth knowing: pair schema-constrained generation with validation on your side (parse, and on failure feed the parse error back for one retry). The model plus a validation loop is more robust than either alone.

Preparing for CCA-F? Practice with 390+ exam questions

XML Tags: Claude's Native Structure

Claude is specifically tuned to respect XML-style tags, and the exam leans on this. Tags do two jobs:

  • Delimit inputs unambiguously. Wrapping a document in <document>...</document> and the question in <question>...</question> tells the model exactly what is data and what is instruction, which also hardens against injection where user content might otherwise read as commands.
  • Shape outputs. Asking for <analysis> then <answer> lets you request reasoning and a final answer, then extract just the <answer> block for your program while keeping the reasoning available.

Tags are the recommended way to structure complex prompts for Claude specifically; a question that describes messy prompt concatenation is usually asking you to reach for tags.

Core Prompting Techniques the Exam Tests

Be explicit and specific. Claude follows instructions closely, so vagueness produces vague results and precision produces precise ones. "Summarize" underperforms "Summarize in three bullets, each under fifteen words, focused on financial risks."

Give the model room to think. For reasoning-heavy tasks, letting the model work through steps (in a scratchpad or a tagged reasoning block) before the final answer improves quality. The exam frames this as separating reasoning from the extractable result: think in <thinking>, answer in <answer>.

Few-shot examples. Two or three examples of the input/output pattern often beat paragraphs of description, especially for format and tone. Examples are instructions the model can pattern-match.

Assign a role via the system prompt. A focused role ("You are a contract-review assistant that flags liability clauses") sharpens behavior more than burying the same intent in the user turn.

Positive, affirmative instructions. Tell the model what to do rather than only what to avoid; "respond in formal English" outperforms a list of prohibitions.

Prompt engineering, hands-on

Force structure out of a real model

Build structured-output and function-calling flows against live models and watch prompt and schema choices change what comes back.

Master These Concepts with Practice

Our CCA-F practice bundle includes:

  • 6 full practice exams (390+ questions)
  • Detailed explanations for every answer
  • Domain-by-domain performance tracking

30-day money-back guarantee

Reliability: When Structure Still Breaks

Professional questions go past the happy path:

  • Validate, then retry with the error. A parse failure fed back to the model ("that was not valid JSON; the error was: unexpected token at position 40") usually fixes on the second try. Blind retries do not.
  • Constrain the space. Enums, length limits, and required fields in the schema remove room for the model to go wrong, the same discipline as tool design.
  • Prefer tool use for anything mission-critical. When a downstream system will choke on malformed output, schema-constrained generation plus validation is the answer the exam wants, not cleverer prose.

How This Shows Up on the Exam

  • You need guaranteed-parseable structured data for a downstream service. Which method? (Tool use / function calling with a schema, not a "return JSON" instruction.)
  • The model keeps prefacing its JSON with a sentence that breaks the parser. Cheapest fix? (Prefill the assistant turn with {.)
  • User-supplied text sometimes hijacks the instruction. What hardens the prompt? (Wrap data in XML tags to separate it from instructions.)
  • Output quality on a multi-step reasoning task is poor. What helps? (Let the model reason in a tagged block before the answer; extract the answer.)

The Claude Code course covers prompting and structured output in Level 2, and Preporato's CCA-F practice tests carry this 20% domain across 390 explained questions, with the flashcard deck drilling the reliability ranking.

Key Takeaways

  • Reliability ranking: tool-use schemas > prefilling > format+example > "please return JSON"
  • XML tags are Claude's native structure: delimit inputs, shape outputs, harden against injection
  • Be explicit, give room to reason, use few-shot examples, assign a role, instruct affirmatively
  • Validate structured output and retry with the parse error rather than blindly
  • For mission-critical structure, schema-constrained generation plus validation beats prose

Return to the exam domains breakdown to see how this domain sits against the rest.


Sources:

Last updated: July 10, 2026

Ready to Pass the CCA-F Exam?

Join thousands who passed with Preporato practice tests

Instant access30-day guaranteeUpdated monthly
CCA-F
6 Practice Exams
Detailed Explanations
Performance Analytics
Get Full Access - $19.99Try Free Questions →