Free CCAR-F Prompt Engineering & Structured Output Practice Questions

The Prompt Engineering & Structured Output domain makes up 20% of the Anthropic CCAR-F exam. Practice free questions covering system prompts, XML tags, few-shot examples, chain-of-thought, prefilling, and enforcing JSON and structured output — each with the correct answer and a detailed explanation.

CCAR-F Prompt Engineering & Structured Output Sample Questions with Answers

Sample Question 1 — Prompt Engineering & Structured Output

A team uses Claude Code in CI to review pull requests. Developers complain that the reviewer reports harmless formatting preferences, speculative risks, and inconsistent severity labels. The team wants findings limited to defects supported by evidence in the changed code. Which prompt change is MOST appropriate?

  1. A. Ask the reviewer to find every possible issue and let developers dismiss low-value findings.
  2. B. Define report, skip, evidence, and severity criteria, with examples at the decision boundaries. (Correct answer)
  3. C. Ask the reviewer to focus on serious issues while independently deciding what serious means.
  4. D. Increase the response token limit so the reviewer can explain every observation in detail.

Correct answer: B

Explanation: Correct answer (B): Defining explicit report and skip criteria tells the reviewer which observations qualify as findings, while evidence requirements and calibrated severity definitions reduce speculation and inconsistency. The underlying principle is that production prompts should make decision boundaries explicit rather than delegate undefined judgments to the model. This matters in CI because predictable, actionable findings preserve developer trust and reduce review noise. Why the other options are wrong: - Option A: This may maximize recall during exploratory auditing, but it preserves the false-positive burden the team needs to reduce. - Option C: This prioritizes important defects in principle, but the undefined meaning of serious permits inconsistent severity judgments. - Option D: More output space can improve explanations, but it does not define which observations should be reported or skipped.

Sample Question 2 — Prompt Engineering & Structured Output

An insurer uses Claude to extract cancellation dates from customer letters. Some letters quote dates from policy examples or mention a date the customer considered but rejected. The production system must not treat those references as actual cancellation requests, and uncertainty must not be converted into a guessed date. What is the BEST prompt design?

  1. A. Extract every date near the word cancellation and rely entirely on downstream date validation.
  2. B. Return the earliest valid date because customers usually discuss events in chronological order.
  3. C. Require one cancellation date in every response and ask Claude to infer it from context.
  4. D. Define positive, negative, and ambiguous cases, and permit an explicit uncertain or missing result. (Correct answer)

Correct answer: D

Explanation: Correct answer (D): Positive criteria identify genuine cancellation requests, negative criteria exclude examples and rejected dates, and ambiguous criteria allow uncertainty to be represented without fabrication. The underlying principle is that precise prompt boundaries complement downstream validation by controlling semantic interpretation. This matters in production because a syntactically valid but unsupported cancellation date could trigger an incorrect policy action. Why the other options are wrong: - Option A: Proximity-based extraction is simple and favors recall, but date-format validation cannot determine whether a date was illustrative or rejected. - Option B: A chronological heuristic may help in some document types, but it is unsupported here and can select an unrelated date. - Option C: Requiring a value simplifies downstream handling, but forcing inference violates the requirement not to guess when evidence is uncertain.

Sample Question 3 — Prompt Engineering & Structured Output

A CI reviewer correctly identifies security defects but also reports intentional naming conventions and hypothetical failures that cannot occur on the changed execution path. The response format is already defined. The architect can add three examples to calibrate reporting. Which set will BEST reduce unwanted findings without hiding real defects?

  1. A. Three confirmed security defects, each using the same vulnerability pattern and severity label.
  2. B. Three non-reportable style comments showing that naming preferences should always be ignored.
  3. C. A reportable defect, a non-reportable convention, and a speculative concern lacking code-path evidence. (Correct answer)
  4. D. A complete review of one large repository containing many unrelated findings and explanations.

Correct answer: C

Explanation: Correct answer (C): The mixed set directly demonstrates the boundary between supported defects, intentional conventions, and unsupported speculation while preserving the expected response behavior. The underlying principle is that few-shot examples are most valuable when they calibrate ambiguous decisions using both positive and negative cases. In production, this improves precision without teaching the reviewer to suppress genuine defects categorically. Why the other options are wrong: - Option A: Positive defect examples can improve recognition, but repetitive examples do not teach when style or speculative observations must be omitted. - Option B: Negative style examples address one source of noise, but they omit positive findings and unsupported code-path concerns. - Option D: A large review may contain useful material, but unrelated findings consume context and provide less focused calibration.

Sample Question 4 — Prompt Engineering & Structured Output

A CI service exposes three tools to Claude: submit_review, fetch_file, and search_symbol. The final pipeline stage accepts only a submit_review call conforming to its JSON schema; a natural-language final response or a call to another tool would fail the job. Which tool-choice configuration is MOST appropriate for that final stage?

  1. A. Use automatic tool choice and emphasize in the prompt that structured output is preferred.
  2. B. Use no tool-choice constraint and parse a JSON object from any natural-language response.
  3. C. Require any available tool so Claude can select whichever tool best matches its reasoning.
  4. D. Force the designated submit_review tool and validate its arguments before accepting the result. (Correct answer)

Correct answer: D

Explanation: Correct answer (D): Forcing submit_review guarantees selection of the designated output tool, while argument validation confirms that the call satisfies structural and application requirements. The underlying principle is that mandatory machine-consumed output requires enforced tool selection rather than a preference or unrestricted choice. This matters in CI because an optional prose response or the wrong tool call creates nondeterministic pipeline failures. Why the other options are wrong: - Option A: Automatic choice is useful when tool use is optional, but it does not require Claude to call the designated output tool. - Option B: Text parsing can support legacy integrations, but it is less reliable and does not enforce use of the schema-bound tool. - Option C: Requiring any tool guarantees some tool use, but Claude could select fetch_file or search_symbol instead of submitting the final review.

Sample Question 5 — Prompt Engineering & Structured Output

Claude extracts product registrations into valid JSON, but 4% of records fail business validation because model_code contains spaces or region uses a value outside the permitted enum. The source contains enough information to correct these records. Which retry strategy BEST improves reliability while controlling cost?

  1. A. Return field-specific validation errors and invalid values to Claude, then allow a bounded correction retry. (Correct answer)
  2. B. Repeat the original request unchanged until the output passes every business validation rule.
  3. C. Accept schema-valid records and let downstream users manually discover invalid business values.
  4. D. Discard each failed document and rerun the complete daily workload with a larger token limit.

Correct answer: A

Explanation: Correct answer (A): Specific feedback gives Claude actionable information about the failed field and constraint, while a bounded retry prevents uncontrolled loops. The underlying principle is that semantic validation should feed correctable errors back into a controlled self-correction process. This matters in production because targeted retries improve recovery rates with less cost and operational risk than blind repetition. Why the other options are wrong: - Option B: Retrying can recover some model errors, but unchanged and unbounded repetition provides no correction signal and can waste resources. - Option C: Schema validity confirms structure, but it does not establish compliance with business rules such as allowed region values. - Option D: A larger context may help truncated requests, but replaying successful work is unnecessary and does not target the reported failures.

Sample Question 6 — Prompt Engineering & Structured Output

A pull request changes authentication logic across eight files. Per-file reviews identify local defects but miss an inconsistent token-lifetime assumption between the API and worker. The same Claude instance also tends to approve conclusions from its first pass. The team requires an independent assessment, system-level analysis, confidence values, and deduplicated comments. Which design BEST satisfies these requirements?

  1. A. Use one instance for per-file review, then ask it to shorten and rank its own findings.
  2. B. Replace per-file analysis with one repository-wide pass and publish every observation independently.
  3. C. Run the same per-file prompt twice in one session and merge identical findings as high confidence.
  4. D. Use focused per-file passes, a separate reviewer instance, and a cross-file consolidation pass with confidence. (Correct answer)

Correct answer: D

Explanation: Correct answer (D): Focused passes preserve local review quality, a separate instance provides greater independence, and a cross-file consolidation pass detects integration issues while assigning confidence and removing duplicates. The underlying principle is to separate generation from independent review and combine local with system-level analysis. This matters in production because self-review can preserve initial blind spots, while unconsolidated multi-pass output creates duplicate noise. Why the other options are wrong: - Option A: Ranking and summarization can improve usability, but the same instance is not an independent reviewer and may preserve its initial assumptions. - Option B: A repository-wide pass can identify interactions, but eliminating focused analysis may miss local details, and publishing every observation creates duplicate noise. - Option C: Repeated passes may reveal variability, but a shared session can retain context, and identical answers do not establish independent correctness.

Sample Question 7 — Prompt Engineering & Structured Output

A team uses Claude Code in CI to review pull requests. The current prompt says, "Find all possible issues." Reviewers receive many speculative findings about style and hypothetical behavior. The team wants reports limited to defects that can cause incorrect behavior, security exposure, or data loss, and every finding must cite relevant code. What is the BEST prompt change?

  1. A. Ask Claude to rank every possible concern by confidence and report the ten highest-ranked findings.
  2. B. Define reportable impacts, require code evidence, and instruct Claude to skip stylistic or unsupported concerns. (Correct answer)
  3. C. Ask Claude to review the pull request twice and retain concerns mentioned during both review passes.
  4. D. Increase the prompt's emphasis on thoroughness and request detailed explanations for every potential concern.

Correct answer: B

Explanation: Correct answer (B): Defining concrete impact thresholds, evidence requirements, and skip conditions directly establishes what belongs in the report. The underlying CCAR-F principle is that explicit report and exclusion criteria reduce prompt ambiguity. In production, this improves precision and prevents speculative findings from consuming reviewer time. Why the other options are wrong: - Option A: Ranking can help prioritize findings, but it does not prevent unsupported or stylistic concerns from entering the candidate set. - Option C: A second pass may improve consistency, but repeated speculation can still satisfy this rule without meeting the team's reporting threshold. - Option D: Greater thoroughness and detail can increase the volume of low-value findings because neither report nor skip boundaries are defined.

Sample Question 8 — Prompt Engineering & Structured Output

A logistics service extracts shipment records through a tool. Every record must include shipment_id and transport_mode. transport_mode must be one of air, sea, rail, or road. A customs_reference may be absent from a document, but downstream systems require the property to exist with null when it is unknown. Which schema design BEST meets these requirements?

  1. A. Require shipment_id, transport_mode, and customs_reference; constrain transport_mode with an enum and allow customs_reference to be a string or null. (Correct answer)
  2. B. Require shipment_id only; describe the accepted transport modes and null behavior in each property's natural-language description.
  3. C. Require all three properties as strings; instruct Claude to use an empty string when the customs reference is unavailable.
  4. D. Require shipment_id and customs_reference; leave transport_mode optional so unrecognized modes cannot cause schema validation failures.

Correct answer: A

Explanation: Correct answer (A): The schema must require the two universally required business values, constrain transport_mode to known categories, and require customs_reference while permitting either a string or null. The underlying CCAR-F principle is to encode structural guarantees directly in the tool's JSON schema, distinguishing nullable fields from optional properties. In production, this creates predictable contracts for downstream consumers while representing genuinely unknown data honestly. Why the other options are wrong: - Option B: Descriptions can guide generation, but they do not enforce required property presence, enum membership, or the nullable type contract. - Option C: An empty string conflates a known textual value with missing information and weakens downstream interpretation of the field. - Option D: Making transport_mode optional violates the requirement that every record include it and avoids rather than models category validation.

Keep Practicing

Take the 10-question CCAR-F quick-start test across all 5 domains, or return to the CCAR-F practice test hub for 250+ questions, exam details, and a study plan. Drill the other domains: Agentic Architecture & Orchestration, Claude Code Configuration & Workflows, Prompt Engineering & Structured Output, Tool Design & MCP Integration, and Context Management & Reliability.