CCAR-F Prompt Engineering and Structured Output Practice Question
An application requires Claude to consistently return JSON data for a configuration parser. Which technique most effectively ensures the model adheres to a specific schema?
⚠ Common exam trap
Candidates often suggest using extensive few-shot examples or complex system prompts to force JSON, ignoring that pre-filling the assistant response is a more direct, reliable structural constraint.
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
✓
Use the assistant pre-fill feature to start with '{'.
Using pre-filling with a starting brace is the most effective way to constrain the model's output in the Claude API. By providing the opening '{' inside the assistant block, you force the model to continue the sequence in valid JSON format. This architectural pattern reduces hallucinations and ensures the downstream parser successfully processes the structured output without requiring complex post-processing or excessive few-shot examples.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Add a system prompt stating 'Output only JSON'.
Why it's wrong here
While system instructions are helpful for setting the persona, they do not provide technical enforcement of syntax. Models can still include markdown code blocks or conversational text before the JSON object, which often breaks strict downstream parsers that expect clean, raw machine-readable output from the API call.
- ✗
Include 50 examples of JSON in the prompt.
Why it's wrong here
Extensive few-shot prompting consumes significant context window tokens and increases latency. It does not provide the same structural guarantee as pre-filling. Relying solely on examples can lead to variability in output formatting, especially if the schema requirements change slightly or the model encounters an edge case input.
- ✓
Use the assistant pre-fill feature to start with '{'.
Why this is correct
Pre-filling the assistant response with the opening curly brace forces the model to complete the string as a valid JSON object. This technique is a robust architectural pattern in the Claude API that minimizes non-JSON tokens and ensures the generated content is immediately ready for schema validation.
- ✗
Set the temperature to 0.0 without other changes.
Why it's wrong here
Setting temperature to zero reduces randomness but does not force the model to output valid syntax. The model might still preface the output with conversational text or markdown formatting. Temperature control governs the probability distribution of token selection rather than enforcing specific output formatting or schema compliance.
About these practice questions
This CCAR-F question is part of Courseiva's 271-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.