CCAR-F Prompt Engineering and Structured Output Practice Question
A developer wants Claude to summarize a long support thread and return the result as a JSON object with a single field "summary". They want to minimize the chance that Claude adds commentary outside the JSON. Which is the most direct Anthropic-recommended technique to apply?
⚠ Common exam trap
The trap here is believing that a stop sequence on the closing brace will cleanly end the JSON, when it actually removes the brace and produces invalid JSON.
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
✓
Prefill the assistant turn with `{"summary": "` so Claude continues directly with the summary text and closing quote.
Prefilling the assistant turn with `{"summary": "` constrains Claude to continue inside the JSON string value, so the response cannot contain commentary before the object or wrap it in markdown. Instructions, stop sequences, and sampling parameters do not structurally enforce the format. The prefill is the most direct Anthropic-recommended technique for this single-field JSON 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.
- ✗
Use the `stop_sequences` parameter set to '}' to end generation after the JSON object.
Why it's wrong here
A stop sequence of '}' would halt generation just before the closing brace, producing invalid JSON that is missing its final character. Stop sequences match literal strings and are not a way to detect the end of a JSON object. This option actively breaks the output format rather than constraining it, so it is not a recommended technique for this scenario.
- ✗
Set `temperature` to 0 and `top_p` to 1 to make the output more deterministic.
Why it's wrong here
Temperature and top_p control sampling randomness, not output format. Even at temperature 0, Claude can produce a deterministic preamble before the JSON. These parameters do not enforce structure, so they do not minimize the chance of commentary outside the JSON. They are useful for consistency of content but irrelevant to the formatting concern described here.
- ✗
Add the phrase 'Return only JSON' to the end of the user message.
Why it's wrong here
An instruction at the end of the user message biases the model toward JSON but does not structurally prevent commentary. Claude may still emit a sentence like 'Here is the summary:' before the object. Instructions are soft guidance, whereas a prefill enforces the starting token. For minimizing commentary with high confidence, the prefill is more reliable than an instruction alone.
- ✓
Prefill the assistant turn with `{"summary": "` so Claude continues directly with the summary text and closing quote.
Why this is correct
Prefilling with `{"summary": "` forces Claude to continue from inside the JSON value, so it cannot add commentary before the object or wrap it in markdown. The model simply completes the string value and closes the brace. This is the most direct Anthropic technique for constraining output to a specific JSON shape and is ideal for a single-field object like this one.
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.