CCAR-F Prompt Engineering and Structured Output Practice Question
You are designing a prompt for Claude to convert a customer email into a JSON object with fields "customer_name", "order_id", and "issue_summary". During testing, about 15% of outputs include the JSON inside markdown code fences (```json ... ```) or add a friendly sentence before the JSON. You need the raw JSON object only, with no extra text, every time. Which approach is most effective?
⚠ Common exam trap
The trap here is assuming that a strong instruction like 'output only JSON' is sufficient, when in practice only a structural constraint such as an assistant-turn prefill guarantees the format.
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
✓
Add a prefill to the assistant turn containing the opening brace `{` so Claude must continue directly with the JSON body.
Prefilling the assistant turn with the opening brace of the JSON object forces Claude to continue directly from that character, structurally preventing any preamble or markdown fence. Instructions and sampling parameters only bias the model toward the desired format; they do not enforce it. The prefill is the deterministic, Anthropic-recommended technique for guaranteeing raw structured output.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase the max_tokens parameter to give the model more room to complete the full JSON object.
Why it's wrong here
max_tokens controls how long the response can be, not whether the response contains conversational preamble or markdown fences. If the model is truncated mid-JSON, raising max_tokens can help, but here the problem is formatting, not length. This does not stop Claude from writing 'Here is the JSON:' before the object, so it fails to solve the stated issue.
- ✗
Lower the temperature to 0 and rely on deterministic sampling to remove the extra text.
Why it's wrong here
Temperature 0 makes sampling more deterministic but does not guarantee removal of markdown fences or polite preambles. The model may still deterministically produce 'Here is the JSON:' as the most likely continuation. Determinism is not the same as format enforcement, so this does not reliably produce raw JSON-only output for every input.
- ✗
Add the instruction 'Do not use markdown' to the system prompt and repeat it in the user turn.
Why it's wrong here
Instructions are soft guidance and Claude may still wrap JSON in fences or add a sentence, especially across varied inputs. Repeating the instruction increases compliance but does not enforce the format at the token level. Without a structural constraint such as a prefill, some percentage of outputs will still include extra text, failing the requirement of raw JSON only.
- ✓
Add a prefill to the assistant turn containing the opening brace `{` so Claude must continue directly with the JSON body.
Why this is correct
Prefilling the assistant turn with `{` forces the model to continue from that exact token, eliminating any preamble or markdown fence before the object. Because the response is a continuation of the prefilled turn, Claude cannot emit a sentence or a code fence opener first. This is the canonical Anthropic technique for guaranteeing raw JSON output and is the most reliable fix here.
About these practice questions
One of 271 original CCAR-F practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.