CCAR-F Prompt Engineering and Structured Output Practice Question
A team uses Claude to generate release notes from git commit messages. The output must be a JSON array of objects with 'title' and 'summary' fields. The model sometimes wraps the JSON in markdown fences or adds a conversational preamble. Which approach most reliably yields parseable JSON?
⚠ Common exam trap
The trap here is believing that a JSON-only instruction or a '{' prefill guarantees valid JSON, when only schema-enforced tool use removes fences and preamble structurally.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Define a tool with an 'input_schema' describing the array of release note objects and set 'tool_choice' to that tool.
Forcing a tool call whose 'input_schema' describes the release note array makes the model's output a structured tool_use block that must conform to the schema. This removes markdown fences and conversational text because the response is not free-form. Downstream code can consume the tool call arguments as JSON directly, giving deterministic parsing.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Set 'max_tokens' to a small value so the model cannot add extra text around the JSON.
Why it's wrong here
Limiting 'max_tokens' can truncate the JSON mid-structure, producing invalid output that is harder to parse than extra prose. It does not prevent markdown fences or preamble if they appear early. Token limits control length, not format, so this approach risks incomplete arrays and does not reliably yield valid JSON.
- ✗
Use a system prompt that says 'Do not use markdown' and rely on Claude to follow it.
Why it's wrong here
Negative instructions in a system prompt are not guaranteed to be followed consistently, especially when the model has learned to format code-like output with fences. Without structural constraints, occasional violations will break the parser. Relying on a single instruction is weaker than schema-enforced tool use, which mechanically prevents fences and preamble by design.
- ✗
Instruct Claude to respond only with JSON and include a prefilled assistant message starting with '{'.
Why it's wrong here
Adding a JSON-only instruction plus a prefill of '{' reduces preamble but does not prevent markdown fences or trailing commentary in all cases. The model may still close the object and then add explanation, or produce invalid JSON inside. Prefill is a helpful nudge, yet it lacks the structural enforcement that a schema-based tool call provides, so parsing failures can persist.
- ✓
Define a tool with an 'input_schema' describing the array of release note objects and set 'tool_choice' to that tool.
Why this is correct
A tool definition with an 'input_schema' that models the array of objects, combined with forcing that tool through 'tool_choice', makes Claude emit a 'tool_use' block whose 'input' is validated against the schema. This eliminates markdown fences and preamble because the output is a structured tool call, not free-form text. The application can then read the JSON arguments directly without cleanup.
About these practice questions
Courseiva writes every CCAR-F question from scratch — 271 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Anthropic exam blueprint
This CCAR-F practice question is part of Courseiva's free Anthropic certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CCAR-F exam.