Courseiva

CCNA Prompting And Context Engineering Questions

47 of 122 questions · Page 2/2 · Prompting And Context Engineering topic · Answers revealed

76
MCQhard

A developer on your engineering team is designing a prompt template that includes few-shot examples alongside reference documents and user queries. They place the examples after the user query and use markdown bullet points instead of XML tags. Based on Anthropic prompt engineering best practices, why is this design suboptimal?

A.Placing examples at the bottom consumes twice as many input tokens because the model has to re-read the prefix twice during inference.
B.The prompt order and lack of XML tags violate best practices; few-shot examples and reference documents should precede the user query, and XML tags should enclose each section.
C.Putting few-shot examples after the user query automatically disables prompt caching for the entire prefix of the request.
D.Markdown bullet points cause an HTTP 400 validation error in the Messages API because the parser strictly requires XML syntax for all prompt formatting.
AnswerB

Placing few-shot examples and reference context before the user query establishes the required pattern and background knowledge before the model processes the active task. Using descriptive XML tags for each section ensures Claude accurately distinguishes between instructional examples and the final user input.

Why this answer

Anthropic recommends placing reference materials and few-shot examples near the top of the prompt, followed by the user query at the end, all clearly organized with descriptive XML tags. Placing examples after the query or using weak markdown bullets reduces the structural clarity that helps Claude anchor its formatting and task execution pattern accurately.

Exam trap

Candidates often overlook the ordering of prompt components, placing few-shot examples randomly or at the very end after the user input, which disrupts the model's contextual grounding.

77
MCQmedium

Your team is building an automated document analysis pipeline that processes 80-page technical manuals using Claude. A junior developer suggests placing the massive manual at the very end of the user prompt, right after the specific extraction instructions, to ensure the model pays maximum attention to it. Based on Anthropic's prompt engineering guidance for long documents, how should you advise the developer?

A.Keep the document at the end but wrap it in custom XML tags to force the model to prioritize it over the preceding prompt instructions.
B.Modify the approach by splitting the document into alternating paragraphs interspersed with the prompt instructions to maintain continuous attention.
C.Reject the suggestion and place the long document near the top of the prompt while positioning the specific instructions and questions at the end.
D.Approve the suggestion because modern language models with large context windows exhibit strong recency bias and remember trailing content best.
AnswerC

Placing the lengthy document near the top establishes the necessary background context before the model evaluates the specific task. Putting instructions at the end aligns with recommended structuring practices, ensuring the primary objective is the final piece of information ingested prior to generation.

Why this answer

Anthropic's guidance explicitly recommends placing long documents near the top of the prompt and putting the specific question or instructions at the end. When processing extensive text inputs, positioning the reference document early allows the model to absorb the contextual foundation before encountering the final query. Placing instructions at the end ensures the model acts directly upon the goal after having scanned the upstream context, avoiding degradation in extraction performance caused by burying the instructions inside or beneath unstructured blocks of text.

Exam trap

Candidates often assume that LLMs operate like humans who retain the final paragraphs best (recency bias), leading them to place large reference texts at the end of the prompt.

78
MCQhard

Refer to the exhibit. This request uses a technique to force Claude to output valid JSON. What is the technical name for this technique, and what is its primary benefit?

A.Few-shotting; it provides a single example of the JSON format to follow.
B.System Role Prompting; it defines the model's persona as a JSON generator.
C.Response Prefilling; it eliminates conversational filler and ensures correct formatting.
D.XML Delimitation; it uses the curly braces as tags to separate the data.
AnswerC

Response prefilling involves putting text in the 'assistant' role at the end of the message history. Claude treats this as its own previous words and continues from there. It is highly effective for removing 'Sure!' or other filler and starting directly with the data.

Why this answer

The technique shown is 'prefilling the assistant response.' By starting the assistant's turn with the beginning of a JSON object, the developer forces Claude to continue the pattern. This is the most reliable way to ensure the output starts exactly with the required characters for programmatic parsing, bypassing any conversational preamble.

Exam trap

Candidates attempt to force JSON output using only system instructions, which often fails to prevent conversational filler, rather than using the 'Response Prefilling' technique to dictate the exact start.

79
MCQhard

A legal team asks Claude to summarize contracts and cite the exact clause supporting each summary point. Claude produces accurate summaries but cites clauses that do not exist. The contracts are supplied inside <contract> tags in the same message. Which change most directly reduces the fabricated citations?

A.Increase the contract length limit so Claude has more space to search for the cited clauses.
B.Ask Claude to rank each citation by confidence so reviewers can skip the low-confidence ones.
C.Add a few-shot example showing a correct summary with a correct clause citation.
D.Instruct Claude to quote the exact sentence from the contract for each point and to say 'not found' when no sentence supports it.
AnswerD

Requiring a verbatim quote ties each claim to text actually present in the contract and gives Claude an explicit escape hatch when support is missing. The 'not found' instruction removes the pressure to invent a plausible clause. This directly targets fabricated citations by making the model ground every point in retrievable source text rather than in inferred references.

Why this answer

Fabricated citations occur when a model is asked to attribute claims without being forced to ground them in source text. Requiring a verbatim quote for each point, plus an explicit 'not found' option when no sentence supports a claim, removes the incentive to invent plausible clauses. The other options either layer metadata over unverified citations, rely on examples alone, or enlarge input without changing the grounding requirement.

Exam trap

The trap here is assuming confidence scores or extra examples will cure hallucinated citations when the real fix is forcing verbatim grounding plus permission to say 'not found'.

80
MCQmedium

A junior developer is struggling with a prompt that produces inconsistent outputs when the number of items to process varies. What is the most robust way to ensure consistent output handling?

A.Provide few-shot examples that include both small and large lists to show the desired consistency.
B.Use a prompt that tells the model to calculate the number of items first and then adjust its output format accordingly.
C.Rely on the model's innate ability to handle lists correctly without additional formatting instructions.
D.Instruct the model to stop processing if the list exceeds a certain number of items to prevent errors.
AnswerA

Providing examples that cover the range of expected input sizes is the best way to demonstrate consistent output requirements. This helps the model generalize the formatting rules across different scenarios, ensuring that your downstream application logic receives predictable, well-structured data regardless of the input size.

Why this answer

When the input size is dynamic, the best approach is to define a clear, schema-based output format and use few-shot examples that demonstrate how to handle both small and large lists. By providing a structural template, you reduce the model's reliance on guessing the output format. Furthermore, instructing the model to return an empty list or a specific null value when no items are found ensures that your downstream code can handle the variation predictably without crashing.

Exam trap

Developers often try to write complex logic in the prompt to handle list sizes, but simple examples and structural constraints are much more reliable.

81
MCQeasy

What is the primary benefit of using pre-filling in a Claude API request?

A.It significantly reduces the total number of input tokens consumed by the prompt.
B.It forces the model to complete the user's unfinished sentence.
C.It helps steer the model's response by setting a specific starting sequence for the assistant's output.
D.It allows the model to access real-time external data without function calling.
AnswerC

Pre-filling initializes the assistant role’s output, forcing the model to pick up where the pre-fill left off. This is a powerful technique for enforcing specific output schemas, such as starting a JSON response with a specific key, ensuring consistency across repeated API calls in a production pipeline.

Why this answer

Pre-filling leverages the assistant's tendency to continue a sequence, effectively steering the model toward a specific starting format or tone. By providing the initial content of the assistant's response, you can force the model to adopt a desired structure immediately. This is essential for guiding complex interactions or forcing specific output formats, such as starting a JSON object with a specific curly brace or key.

Exam trap

Candidates often confuse pre-filling with prompt engineering instructions, forgetting that pre-filling is a technical implementation that forces the assistant role to start at a specific point.

82
MCQmedium

You have a complex JSON schema for your data extraction tool. You notice that the model sometimes omits optional fields, even when the data is present in the source text. What is the best way to encourage the model to include these fields when possible?

A.Update the JSON schema to mark all optional fields as 'required'.
B.Increase the model's output token limit to provide more space for the optional fields.
C.Use the 'tool_choice' parameter to force the model to use a custom tool that only handles the optional fields.
D.Include clear, explicit instructions in the prompt to extract all available information, even for optional fields.
AnswerD

Directly instructing the model to prioritize extraction of all available information is the best way to change its behavior. When combined with a well-structured prompt, this ensures the model understands that 'optional' means the field is nullable if data is absent, not that it should be ignored when data is present.

Why this answer

The most effective way to signal that optional fields should be populated when available is to add clear instructions in the system prompt or the tool description. You should emphasize that the model should attempt to extract information for all fields if the source text supports it. Combining these instructions with a few-shot example that includes a fully populated JSON object will reinforce this behavior, making the model more likely to capture the optional data consistently.

Exam trap

Candidates often assume that making a field 'required' in the schema will fix this, but that would break the schema if the data is genuinely missing.

83
MCQeasy

When designing a test set to evaluate prompt quality for a customer support tool, which attribute is most critical for ensuring the results are representative of real-world usage?

A.Make the test set as large as possible, even if it means including many repetitive or identical examples.
B.Ensure the test set contains only the most common, high-frequency user questions.
C.Include a diverse range of inputs, including common questions, edge cases, and intentionally ambiguous queries.
D.Use only synthetic data generated by another LLM to ensure the test set is perfectly formatted.
AnswerC

Diversity is the most important factor for a robust evaluation. Including ambiguous and edge-case scenarios ensures that your prompt is evaluated against the full spectrum of real-world interactions, making it much more likely that your system will perform reliably when deployed to your actual customers in production.

Why this answer

A representative test set must capture the diversity of real-world inputs, including edge cases, ambiguous requests, and different user tones. If the test set only contains 'clean' or 'ideal' examples, you will have a false sense of security regarding your prompt's quality. Real-world data is often messy, and the goal of an evaluation set is to stress-test the model's ability to handle the same variety of inputs that your customers will realistically provide.

Exam trap

Candidates often prioritize the 'size' of the test set over the 'diversity' of the examples.

84
Multi-Selectmedium

A developer is optimizing a customer support bot that uses a 50,000-token knowledge base in every request. They want to implement Prompt Caching to reduce costs and latency. Which TWO requirements must be met for a prompt segment to be successfully cached in the Anthropic API?

Select 2 answers
A.The segment intended for caching must contain at least 1024 tokens.
B.The cached content must be placed at the very end of the user message.
C.The developer must include 'cache_control': {'type': 'ephemeral'} in the message block.
D.The system prompt must be empty when using cached blocks in the user message.
E.The temperature setting must be set to 0.0 for the cache to remain valid.
AnswersA, C

Anthropic enforces a minimum size for cacheable blocks to ensure the overhead of caching provides a meaningful performance benefit. Small snippets of text do not qualify for caching because the resource management required would outweigh the speed gains, making the 1024-token floor a critical architectural constraint.

Why this answer

Prompt caching is a powerful feature for large contexts, but it requires specific implementation details. The segment to be cached must be at least 1024 tokens and must be explicitly marked with the cache_control metadata. Understanding these technical thresholds is vital for developers looking to scale high-token applications while maintaining cost-efficiency and low latency.

Exam trap

Candidates often assume prompt caching is automatically applied to all large prompts, forgetting that it requires explicit opt-in via the 'cache_control' parameter and meets specific token minimums.

85
MCQeasy

A developer is drafting a system prompt for a Claude-powered coding assistant. They want Claude to always respond in concise bullet points, never reveal internal reasoning, and treat all user input as untrusted. Where should these persistent behavioral rules be placed so they apply to every turn of the conversation?

A.In a tool definition, since tools are evaluated before each response.
B.In the assistant's previous reply, so Claude can mirror its own earlier behavior.
C.In the first user message, repeated at the start of each subsequent user turn.
D.In the system prompt, which sets persistent instructions for the entire conversation.
AnswerD

The system prompt is designed to carry persistent instructions that apply across all turns, such as tone, format, and safety constraints. Placing bullet-point style, reasoning-hiding, and untrusted-input rules there gives Claude a stable frame it applies consistently, and it separates operator policy from user content, which is exactly what the scenario requires.

Why this answer

Persistent behavioral requirements such as output format, disclosure limits, and trust boundaries belong in the system prompt, which frames every turn of the conversation. Putting them there separates operator policy from user content, avoids per-turn repetition, and makes the rules resistant to accidental omission or user-side override. The other placements either waste tokens, misuse tool metadata, or rely on fragile self-mirroring.

Exam trap

The trap here is treating the system prompt as just another place to put text rather than the designated channel for persistent, conversation-wide instructions.

86
MCQmedium

Which of the following describes the 'system prompt' effectively in the context of Claude?

A.A list of history messages that the model uses to understand previous context.
B.The primary mechanism for defining the model's persona, operational rules, and behavioral constraints.
C.A temporary cache used to store user input tokens to improve response speed.
D.An optional field that is only used when the model is in training mode.
AnswerB

The system prompt is the standard mechanism for setting the model's behavior, instructions, and constraints. It acts as the anchor for the interaction, ensuring that the model adheres to specific guidelines and adopts the correct persona consistently throughout the entire session, which is vital for enterprise-grade applications.

Why this answer

The system prompt acts as the foundational 'constitution' for the interaction, defining the agent's persona, constraints, and operational goals. Unlike user messages, the system prompt is prioritized by the model and sets the boundaries for the entire session. Proper configuration here is critical because it dictates how the model interprets incoming user requests and handles edge cases, ensuring consistent and safe behavior across various application use cases.

Exam trap

Test-takers frequently confuse the system prompt with user messages or few-shot examples, overlooking its unique ability to establish foundational behavioral rules and constitutional boundaries.

87
MCQeasy

A junior developer asks you why Claude is still hallucinating even though they provided a 50-page manual in the context. What is the most common reason for this behavior in a prompt that lacks an explicit 'I don't know' instruction?

A.The model's temperature is set too high, causing it to be overly creative.
B.The developer did not use XML tags to structure the input document.
C.The model is inherently incapable of handling documents longer than 10 pages.
D.The model is prioritizing being helpful and lacks a clear instruction to admit when information is missing.
AnswerD

Models are designed to be helpful, which often translates into an attempt to answer every query. Without clear, explicit instructions that admitting ignorance is preferred over guessing, the model will naturally attempt to use its broad internal knowledge to provide an answer, which often leads to inaccurate or hallucinated information.

Why this answer

Models are trained to be helpful, and without explicit permission to admit ignorance, they often prioritize generating a response over admitting that they lack information. When a user provides a large amount of context, the model may feel compelled to synthesize an answer even if the specific information is missing, leading it to draw on its pre-training data to fill the void. Explicitly telling the model it is acceptable to say 'I don't know' is a necessary guardrail to align its behavior with the user's requirement for strict factual accuracy.

Exam trap

Candidates often assume the model is simply 'confused' by the long context, whereas the issue is usually a lack of explicit behavioral boundaries regarding unknown information.

88
MCQmedium

You are prompting Claude to adopt a specific tone. Which technique is most likely to ensure consistency across a variety of user queries?

A.Explain the tone in exhaustive detail in the system prompt.
B.Provide multiple examples (few-shot) of the desired tone in the prompt.
C.Use a system prompt that specifies a list of forbidden words.
D.Set the temperature to a high value to increase variety in the tone.
AnswerB

Few-shot examples offer the model a clear, functional pattern of the desired behavior. By providing examples of queries and the corresponding responses in the required tone, you enable the model to learn the nuance and application of the tone, leading to much higher consistency in actual usage.

Why this answer

Few-shot prompting provides concrete examples of the desired tone in action, which is far more reliable than qualitative descriptions. By showing the model exactly how to handle different scenarios, you provide a behavioral template that the model can generalize. This approach removes the guesswork and ensures that the tone remains consistent regardless of the specific topic or nature of the user's inquiry.

Exam trap

Candidates often try to enforce tone using lengthy descriptive paragraphs instead of providing concrete few-shot examples, leading to inconsistent model adherence.

89
MCQhard

You are building a prompt chain to extract data from financial reports. The first step involves identifying the relevant report section, and the second step extracts figures. You have noticed that the second step often fails because it receives the entire document instead of just the relevant section identified in step one. What is the most effective way to ensure the second step receives only the necessary content?

A.Use a single, massive prompt that asks the model to perform both tasks simultaneously to avoid context loss.
B.Use the output of the first step as the input for the second step, ensuring the second step only sees the relevant section.
C.Include a instruction in the second step to 'ignore all text except for the section identified in step one'.
D.Increase the cache TTL for the entire document to ensure the second step has immediate access to the full source.
AnswerB

Isolating the relevant section identified in the first step and passing only that subset as input to the second step is a best practice in prompt chaining that minimizes noise, reduces token usage, and significantly improves the model's ability to focus on the extraction task.

Why this answer

Prompt chaining requires careful management of the context passed between steps. To maintain performance, the orchestrator must explicitly extract the output from the first step and use it as the input for the second. This prevents the model from becoming distracted by irrelevant information in the large document and ensures that the second step operates only on the targeted data, significantly increasing the reliability and accuracy of the extraction process.

Exam trap

Passing the entire original context to every step in the chain, which increases costs and dilutes the model's attention on the specific task at hand.

90
MCQmedium

Refer to the exhibit. Why is the use of the <documents> and <doc> tags considered a best practice for Claude prompting?

A.It is a requirement of the JSON schema for the Messages API.
B.It enables Claude to parse the content as a valid XML object.
C.It improves the model's ability to distinguish context from instructions.
D.It automatically bypasses the model's safety filters for large data.
AnswerC

Using XML tags creates a clear visual and logical boundary between the input data and the user's question. This allows Claude to focus its attention mechanism more effectively on the relevant sections of the prompt, reducing the chances of confusing the content of the documents with the task.

Why this answer

Claude is specifically trained to recognize and utilize XML tags for structural organization. These tags help the model delineate between instructions, metadata, and actual content. In complex prompts, this separation reduces the likelihood of the model misinterpreting data as instructions, thereby increasing the reliability and accuracy of the generated responses.

Exam trap

Candidates often treat XML tags merely as cosmetic styling rather than recognizing them as structural boundaries that prevent the model from confusing data with instructions.

91
Multi-Selecteasy

A user wants to improve the quality of Claude's creative writing. Which TWO prompting techniques are likely to produce more vivid and stylistically consistent results?

Select 2 answers
A.Using a system prompt to assign a specific authorial persona to the model.
B.Providing three examples of the desired writing style in the prompt context.
C.Increasing the 'max_tokens' to allow the model to write longer descriptions.
D.Using only zero-shot prompts to allow the model's 'natural' creativity to shine.
E.Repeating the phrase 'be very vivid' five times throughout the prompt.
AnswersA, B

Assigning a persona (e.g., 'You are a Pulitzer Prize-winning novelist') helps Claude adopt a specific tone, vocabulary, and stylistic approach. This global instruction in the system prompt influences all subsequent output, making it more consistent and aligned with the desired creative 'voice' for the project.

Why this answer

Creative writing benefits from both clear persona definition and illustrative examples. Role prompting sets the 'voice,' while few-shot examples provide a concrete reference for the level of vividness and style expected. Together, these techniques ground the model's creative output in a way that simple instructions cannot.

Exam trap

Candidates often rely solely on generic adjectives like 'creative' or 'vivid' in their prompt, failing to provide the persona and examples necessary to ground the model in a specific style.

92
MCQhard

You are building a prompt that extracts complex project requirements from a series of documents. You decide to use nested XML tags to structure the data. What is a potential risk of over-complicating your XML structure?

A.The API will return a 400 error if the XML nesting depth exceeds three levels.
B.The model will automatically refuse requests that contain more than ten unique XML tags because of safety concerns.
C.Deeply nested XML tags consume more tokens than flat structures, significantly increasing the cost of every request.
D.Overly complex XML hierarchies can introduce unnecessary ambiguity, potentially leading the model to misinterpret the relationships between sections.
AnswerD

Excessively complex or deeply nested tag structures can confuse the model, making it harder for it to parse the intended hierarchy and relationships, which can lead to errors in how the model interprets the information within those tags.

Why this answer

While XML tags are excellent for structure, an overly complex or deeply nested hierarchy can sometimes confuse the model or increase the risk of misinterpretation. If the structure is too convoluted, the model may spend too much 'effort' parsing the structure itself rather than focusing on the actual task, or it might struggle to understand the hierarchical relationship between tags. It is best to keep your XML structure as simple and flat as possible while still providing the necessary separation of information.

Exam trap

Candidates often think that more structure is always better, ignoring the potential for 'structure fatigue' or confusion in the model's understanding.

93
Multi-Selectmedium

You are evaluating the performance of a Claude-based document summarization tool. You have a set of 100 documents and their corresponding human-written summaries. Which TWO of the following metrics or practices are most effective for evaluating the quality of Claude's summaries?

Select 2 answers
A.Measure the word-count similarity between the Claude-generated summary and the human summary.
B.Calculate the ratio of the summary length to the source document length to ensure it is always under 10%.
C.Ask the model to self-grade its summary by asking 'How good is this summary?' on a scale of 1 to 5.
D.Verify that all 'key entities' (names, dates, amounts) from the source appear in the summary.
E.Use an LLM judge to grade the summaries based on factual accuracy and adherence to the source document.
AnswersD, E

Ensuring factual coverage is a key component of summary quality. By programmatically checking that specific, important information has been preserved, you can objectively measure if the model is effectively filtering the noise while retaining the critical facts required for the user's business context, which is a major success criterion.

Why this answer

Effective evaluation of summarization combines objective structural checks with high-level semantic assessment. Comparing against human-written summaries using an LLM judge is a modern best practice because it can evaluate aspects like 'hallucination' and 'tone' which simple string-matching metrics miss. Checking for the inclusion of key information (like dates or specific entities) ensures that the summary maintains the factual integrity of the source document, which is critical for legal or business documents.

Exam trap

Candidates often rely on legacy metrics like word-count similarity, which do not measure comprehension or accuracy.

94
MCQeasy

Your team is developing a prompt to extract data from financial reports. You have a small set of 10 reports and you are manually checking the outputs. As the project scales to 1,000 reports, why is manual evaluation no longer suitable?

A.The API rate limits prevent you from manually checking the output of 1,000 reports in a single day.
B.Manual evaluation is not scalable and lacks the consistency needed to reliably measure accuracy across large, diverse datasets.
C.Automated evaluation is required to ensure that the model is always using the latest version of the system prompt.
D.Manual evaluation is less accurate than automated methods because humans cannot read financial reports as quickly as Claude.
AnswerB

Scaling to 1,000 reports makes manual review impossible to perform consistently. Automated evaluation provides the repeatability and scale necessary to measure accuracy objectively across the entire dataset. It allows you to define success criteria once and apply them uniformly, which is critical for iterating on prompt quality in a production-grade system.

Why this answer

Manual evaluation is inherently limited by human throughput, subjective bias, and the inability to maintain consistent standards across thousands of samples. As you scale, you need an automated evaluation pipeline that uses objective criteria (like code-based validation or LLM-based judges) to ensure consistency and speed. Relying on manual review for high-volume tasks leads to bottlenecks, inconsistent quality assessments, and a failure to capture edge cases that only appear at scale, making it impossible to effectively improve the prompt over time.

Exam trap

Candidates often think manual evaluation is 'more accurate' and should be kept as the primary method, ignoring the need for scalability in production.

95
MCQmedium

You are designing a system to extract structured JSON from unstructured emails. Despite providing a clear schema in the system prompt, Claude occasionally ignores the formatting constraints and includes conversational filler. Which technique best improves instruction adherence?

A.Add a few examples of conversational responses in the prompt.
B.Reduce the total prompt length to minimize cognitive load.
C.Enclose the schema within XML tags and instruct Claude to output only the content within those tags.
D.Increase the temperature setting to allow for more creative adherence.
AnswerC

XML tags provide a clear hierarchy that helps Claude distinguish between meta-instructions and task requirements. By explicitly telling the model to output only the content within the tags, you create a rigid constraint that significantly reduces the likelihood of the model appending conversational filler to the final output.

Why this answer

Utilizing XML tags like <format> or <json_schema> creates a distinct boundary that prevents the model from blending instructions with content. This structural separation helps Claude maintain strict adherence to output requirements by isolating the task logic from the input data. Mastery of delimiters is essential for building reliable, production-grade pipelines that require consistent, machine-readable outputs for downstream applications.

Exam trap

Candidates provide complex JSON schemas in plain text, which the model often treats as suggestions rather than hard constraints, leading to inconsistent outputs mixed with conversational text.

96
MCQmedium

A team is iterating on a prompt for an automated invoice data extraction pipeline. They have a set of 50 diverse invoices and want to track the model's reliability in extracting the 'total_due' field. Which approach provides the most rigorous and repeatable evaluation of their prompt changes?

A.Switch to a more capable model tier if the current model fails to extract the data correctly on the first try.
B.Change the prompt and immediately deploy it to production to see if the user feedback reports decrease.
C.Manually inspect 5 random invoices after every prompt adjustment to ensure the output looks correct.
D.Run the entire test set of 50 invoices through each prompt iteration and automate the comparison of outputs against ground truth values.
AnswerD

Automated evaluation against a fixed test set provides a consistent, quantitative baseline. By comparing the model output to ground truth, the team can measure accuracy, identify specific failure modes, and ensure that changes intended to fix one edge case do not inadvertently break performance on previously successful invoice formats.

Why this answer

Building an evaluation suite with a representative test set and a reliable grading mechanism is the gold standard for prompt engineering. By running the same 50 invoices through each iteration of the prompt and using code or a secondary model to compare the extracted JSON against known ground truth values, the team creates a quantitative metric for success. This allows them to identify if a prompt change improves accuracy for specific invoice formats or introduces regressions, moving the iteration process from subjective guesswork to data-driven refinement.

Exam trap

Candidates might assume that checking a few random outputs manually is sufficient or that simply using a more capable model for the task is a substitute for systematic evaluation.

97
Multi-Selecthard

A developer is optimizing a RAG (Retrieval-Augmented Generation) pipeline using Claude 3.5 Sonnet. Which TWO techniques will most significantly improve the model's ability to extract accurate information from a 50,000-token context window?

Select 2 answers
A.Wrapping each retrieved document in distinct XML tags.
B.Setting top_k to a value of 1 to minimize output variety.
C.Asking the model to think step-by-step before providing the answer.
D.Converting all text to uppercase to improve character recognition.
E.Reducing the temperature to exactly 0.5 for balanced reasoning.
AnswersA, C

XML tags provide a clear hierarchy and boundaries for the model to follow. By encapsulating each document separately, the model can easily reference specific parts of the context, which is critical for maintaining high retrieval accuracy and avoiding the mixing of information from different source documents.

Why this answer

Handling large contexts requires structural clarity and logical transparency. XML tags help the model distinguish between different documents, while Chain of Thought (CoT) prompting forces the model to deliberate on the retrieved information before formulating a final answer. Together, these techniques reduce hallucinations and improve the precision of information extraction in dense context environments.

Exam trap

Candidates often rely purely on raw, unstructured context text, forgetting that LLMs require explicit structural markers and deliberate reasoning steps in dense environments.

98
MCQhard

Your organization builds automated workflows where prompts are assembled from modular template components stored in a database. You notice that minor whitespace differences introduced by the template assembler are occasionally causing cache misses. What architectural adjustment should you make to ensure consistent prompt caching behavior?

A.Move all template variables to the very beginning of the system prompt so that whitespace differences occur only in cached regions.
B.Rely on the Messages API automatic compaction feature to clean up inconsistent whitespace before cache lookup.
C.Normalize and deterministically format the static prefix components in your template assembler to guarantee an identical byte sequence across requests.
D.Set the cache control TTL parameter to zero so that the system bypasses prefix matching and caches every request dynamically.
AnswerC

Because prompt caching requires a precise prefix match, standardizing the assembler output ensures that identical static content generates the exact same byte sequence every time. This eliminates accidental cache misses caused by minor whitespace or formatting discrepancies introduced by dynamic template rendering.

Why this answer

Prompt caching operates as an exact prefix match over tools, system prompts, and messages. Any variation in the prompt string—including extra whitespace, trailing newlines, or reordered template fragments—invalidates the cache for everything after the modification point. To maintain high cache hit rates, your template assembler must produce a strictly deterministic, normalized byte string for all static prefix components before submitting the request to the API.

Exam trap

Engineers often assume that minor formatting variations like trailing spaces are automatically normalized by the API before cache evaluation.

99
MCQeasy

You are designing a prompt chain where the output of step one (a summary) is used as the input for step two (a translation). If the summary step fails to provide a useful output, what is the best way to handle this in your application code?

A.Set the max_tokens parameter to a very low value in the first step to force the model to be more concise.
B.Implement application-level validation logic to check the output of step one before passing it to step two.
C.Instruct Claude in the second step to automatically detect if the input from the first step is poor and ask for a retry.
D.Use the same system prompt for both steps to ensure the model maintains the same context for the entire chain.
AnswerB

Validation logic in your application code is necessary to ensure that the output of one step is suitable for the next. Checking for null values, incorrect formats, or specific error indicators prevents the propagation of errors through the chain and allows you to handle failures gracefully before they impact subsequent steps.

Why this answer

In a prompt chain, you must validate the output of each step before passing it to the next. If a step fails, returning an error or a fallback value is critical. Simply passing an empty or malformed string to the next step will likely result in the second model hallucinating or failing.

Designing your application to catch these errors and either retry the step or inform the user ensures the reliability of the entire workflow.

Exam trap

Candidates often think Claude will automatically 'know' the first step failed and fix it, but the model is stateless and does not know what happened in the previous request.

100
Multi-Selecthard

A legal-tech startup uses Claude to summarize deposition transcripts that are frequently 80,000 to 120,000 tokens long. Early tests show the model sometimes ignores instructions placed near the top of the prompt and produces summaries that omit late sections of the transcript. Which TWO prompt-engineering changes should the developer make to improve instruction adherence across the full context? (Choose two.)

Select 2 answers
A.Repeat the summarization instructions verbatim in the system prompt and again immediately before the transcript.
B.Raise the temperature to encourage the model to explore more of the transcript.
C.Wrap each deposition section in clearly labeled tags such as <section id="12"> and require the summary to cite section IDs.
D.Increase the max_tokens parameter so the summary can be longer.
E.Place the transcript content first and the summarization instructions after it, near the end of the prompt.
AnswersC, E

Structural tags give the model navigable anchors throughout a long document, and requiring section citations forces it to traverse the entire transcript rather than summarizing only the opening. The citation requirement also produces verifiable output, since a missing section ID is immediately visible during review.

Why this answer

Long-context adherence improves when the instruction sits after the material it governs and when the document carries structural anchors the model can traverse. Placing instructions last exploits stronger attention near the end of the prompt, while labeled sections with a citation requirement force coverage of every part of the transcript and make omissions detectable.

Exam trap

The trap here is treating a long-context attention problem as a generation-parameter problem, and reaching for temperature or max_tokens when the real levers are instruction placement and document structure.

101
MCQmedium

You are providing Claude with a 100,000-token technical manual and asking it to troubleshoot a specific error code. Where should the troubleshooting instructions and the specific error code be placed for the best results?

A.At the beginning of the prompt, before the technical manual content.
B.At the end of the prompt, after the technical manual content.
C.In the middle of the manual, near the section that likely contains the answer.
D.Spread across both the system prompt and the very beginning of the user message.
AnswerB

Putting the task and the specific error code at the end is a best practice for long-context engineering. It ensures that the model has already processed the manual and can immediately apply that information to the specific problem, which often results in more accurate and relevant troubleshooting steps.

Why this answer

For long-context prompts, Anthropic recommends placing the most specific instructions and the 'query' at the end of the prompt. This allows Claude to have all the reference material 'in mind' before it sees the actual task, leading to better performance on complex retrieval and reasoning tasks across large datasets.

Exam trap

Candidates place the specific task or error code at the beginning of a long prompt, which causes the model to lose focus on the query after processing the large amount of manual content.

102
MCQmedium

Your team is building a sentiment analysis tool that processes user reviews. You have noticed that when multiple reviews are provided in a single prompt, Claude occasionally confuses the sentiment of one review with another. How should you structure the prompt to prevent this cross-contamination?

A.Use a JSON object to list the reviews instead of XML tags.
B.Instruct the model to process each review one at a time by making multiple API calls.
C.Wrap each review in individual <review> tags within a parent <reviews> container.
D.Add a separator string like '---' between each review to visually break up the text.
AnswerC

The hierarchical structure of <reviews><review>...</review></reviews> creates a clear scope for each item. This allows Claude to isolate the context of each review, effectively preventing the sentiments of one review from influencing the analysis of another, which is a common issue when inputs are not structured.

Why this answer

To prevent cross-contamination when processing multiple items, you should wrap each individual review in its own unique XML tag within a parent container. By using a structure like <reviews><review id='1'>...</review><review id='2'>...</review></reviews>, you provide clear boundaries for every distinct input. This allows Claude to treat each review as a separate entity, ensuring that the sentiment analysis for one does not inadvertently bleed into or influence the evaluation of another, thereby maintaining high accuracy.

Exam trap

Candidates might try to use simple numbering or paragraph breaks, which are less effective than explicit XML-based nesting for maintaining separation in tokenized input.

103
MCQmedium

A developer is creating a template for generating project reports. They want to ensure Claude maintains a consistent structure by injecting dynamic variables, such as 'ProjectName' and 'Budget', into the prompt. Given that the API is stateless, what is the best practice for handling these variables before sending the request to Claude?

A.Use the API's built-in variable substitution parameter to inject metadata into the system prompt.
B.Use the metadata field to pass variables, which the model will automatically merge into the system prompt.
C.Send the raw template string with placeholders and rely on Claude's internal reasoning to fetch the variable values.
D.Perform variable interpolation in your client-side application code before submitting the full prompt to the Messages API.
AnswerD

Client-side processing is necessary because the API is stateless and does not support server-side template rendering. By injecting the required project data into the string before sending it to the Messages API, you ensure the model receives a fully contextualized, valid prompt that adheres to the expected structure and input requirements for the task.

Why this answer

Since the Anthropic API is stateless, the client application is entirely responsible for constructing the full message sequence every time. The most reliable approach is to perform string interpolation or variable substitution on the client-side to generate the final, fully-formed prompt text before submitting it to the Messages API. This ensures that Claude receives a complete and coherent prompt in every request, avoiding issues related to missing context or incomplete templates that could arise if the model were expected to resolve placeholders dynamically within the prompt chain.

Exam trap

Candidates often assume the model can natively handle placeholders like {{variable}} or that the API has a server-side template engine to resolve these values automatically.

104
MCQhard

Refer to the exhibit. The developer notices the model often hallucinates data not present in the <data> tags. Which adjustment is most likely to mitigate this behavior?

A.Reduce the temperature to 0.0 to make the model's output more deterministic.
B.Add an explicit instruction in the system prompt to only use information contained within the <data> tags.
C.Increase the max_tokens to ensure the model has enough room to explain its reasoning.
D.Change the model to an older version that is less prone to creative generation.
AnswerB

Explicitly grounding the model's response within the provided XML tags creates a clear boundary for the model's knowledge. By setting a strict rule that it must only use the provided context, you significantly reduce the likelihood of the model pulling from its pre-training data during generation.

Why this answer

Adding a strong negative constraint to the system prompt, such as 'If the information is not present in the provided <data>, state that you do not have sufficient information,' directly addresses hallucination. This forces the model to prioritize factual grounding over generative completion. In production systems, explicit constraints about the source material are essential for maintaining the integrity of data processing workflows and preventing the propagation of false information.

Exam trap

Candidates often select answers that rely solely on few-shot examples inside the user message, failing to recognize that system-level constraints are far more effective for enforcing strict source-grounding behavior.

105
MCQmedium

You are building a tool that extracts invoice totals. The model occasionally adds currency symbols or notes, causing your `float()` conversion to fail. How should you fix this without using prefill?

A.Add a constraint in the system prompt to 'only output the raw numeric value'.
B.Use a few-shot example that shows the model how to extract only the number.
C.Pre-process the input invoice text to remove all symbols before sending it to Claude.
D.Use `output_config.format` to define the total as a numeric type in your JSON schema.
AnswerD

Defining the field as a number in your JSON schema via `output_config.format` is the most reliable way to ensure the output is a raw number. This API-level constraint forces the model to comply with the schema, preventing the inclusion of symbols, notes, or other non-numeric characters that cause runtime failures.

Why this answer

The most effective way to handle type-specific extraction is by using the `output_config.format` parameter with a JSON schema that explicitly defines the field type (e.g., number). By constraining the schema to a numeric type, you force the model to output only the raw number, preventing the inclusion of currency symbols or extra notes that would otherwise cause your downstream code to crash during type conversion.

Exam trap

Candidates often try to 'fix' the model's output with more prompt instructions, rather than using structural API constraints.

106
MCQhard

A data scientist is using Claude to classify customer feedback into categories: 'bug', 'feature request', 'complaint', or 'praise'. The feedback is often short and informal. The data scientist wants to maximize classification accuracy. Which prompting strategy is most effective?

A.Use a high temperature to encourage diverse interpretations of the feedback.
B.Include a few examples of feedback for each category in the prompt.
C.Provide a detailed definition of each category in the system prompt.
D.Ask Claude to think step-by-step about the sentiment before classifying.
AnswerB

Providing a few labeled examples for each category gives Claude a clear pattern to follow. It can learn the boundaries between categories from the examples, improving accuracy on informal and varied feedback. This few-shot approach is highly effective for classification tasks, especially when the input language is diverse.

Why this answer

For classification tasks with informal and varied input, providing a few labeled examples per category is the most effective prompting strategy. Examples allow Claude to learn the specific patterns and boundaries between categories, improving accuracy. This few-shot approach outperforms detailed definitions alone because it demonstrates how to handle nuances like slang or brevity.

It also avoids the potential confusion of step-by-step reasoning for a straightforward task.

Exam trap

The trap here is thinking that step-by-step reasoning always improves performance, but for simple classification, few-shot examples are more direct and effective.

107
MCQhard

An enterprise application dynamically assembles system prompts by combining a core enterprise compliance policy with department-specific rules injected via a template. The department rules change weekly, while the core policy changes monthly. How should you structure this template hierarchy to maximize cache efficiency?

A.Place the weekly department rules first, the monthly core policy second, and the user variables last.
B.Concatenate all three text sources into a single unformatted string with department rules randomized on each turn.
C.Put the per-request user variables first, followed by the weekly department rules, and place the core policy last.
D.Place the monthly core compliance policy first, the weekly department rules second, and the per-request variables last.
AnswerD

Ordering content by decreasing stability allows Claude to match the longest stable prefix possible. When department rules update weekly, the core compliance policy cache remains valid, saving significant token costs across all departments sharing that core text.

Why this answer

Prompt caching is a sequential prefix match. To maximize savings, you must order static content from most stable to least stable before appending volatile user inputs. Placing the monthly core policy first, followed by the weekly department rules, and finally the per-request user variables creates nested cache breakpoints that preserve the shared core policy cache even when department rules update.

Exam trap

Engineers often group all dynamic or template-driven text together at the top, failing to realize that changing a mid-level template variable invalidates all subsequent cached tokens.

108
MCQeasy

A user wants Claude to provide a response in Markdown format with specific headers. Which approach is best for achieving this consistently?

A.Request the format in the system prompt and provide a Markdown template.
B.Only mention 'Markdown' once at the beginning of the user prompt.
C.Use the word 'IMPORTANT' in all caps before the Markdown request.
D.Hope that the model defaults to Markdown since it is common.
AnswerA

Combining a high-level instruction in the system prompt with a concrete template provides both the 'what' and the 'how'. This dual approach is highly effective for structural tasks, as it sets the expectation and then provides a visual reference for the model to emulate.

Why this answer

Clear formatting instructions combined with structural examples are the most effective way to guide Claude's output format. By explicitly naming the desired format (Markdown) and providing a template or list of required headers, the developer gives the model a clear blueprint to follow during the generation process.

Exam trap

Candidates often try to instruct the model to use Markdown in the user message. This is less effective than defining the format in the system prompt for consistent application.

109
MCQmedium

Refer to the exhibit. Why might the model struggle to answer the final question if you are not using a stateful chat implementation?

A.The model's internal memory resets every time you send a new API request.
B.The model has a maximum token limit that prevents it from remembering history.
C.The system prompt is preventing the model from accessing past information for safety.
D.The model is not optimized for question-answering tasks and lacks long-term recall.
AnswerA

The Anthropic API is stateless. Each request is a standalone interaction. To maintain the appearance of a conversation, you must send the entire message history (user and assistant turns) in the 'messages' parameter of the API request so the model can see the full thread and provide consistent answers.

Why this answer

In a stateless API architecture, the model does not automatically remember previous turns. To ensure the model has access to the full conversation history, you must include the full chat thread in every API request. If you only send the most recent user message, the model loses the context of previous messages, making it impossible to answer questions that depend on historical interactions.

Exam trap

Candidates incorrectly believe the model has a persistent 'session' memory. They fail to realize that each API call is isolated and requires the full history to maintain context.

110
MCQmedium

When creating a system prompt for a multi-step agentic workflow, why is it better to define the agent's role rather than just listing specific tasks?

A.It allows the model to better navigate ambiguous scenarios and maintain consistency.
B.It significantly reduces the number of input tokens consumed.
C.The API requires all system prompts to be framed as role definitions.
D.Role definitions are the only way to enable adaptive thinking features.
AnswerA

Role definition establishes a behavioral framework that helps the model make decisions during complex, multi-step workflows. This is more effective than a rigid task list because it provides context for the model's actions, allowing it to adapt to unexpected inputs while staying aligned with its core responsibilities.

Why this answer

Defining a role in the system prompt provides the model with a behavioral framework that guides its reasoning and decision-making across the entire workflow. A well-defined role helps the model interpret ambiguous situations and maintain consistency in its approach to different tasks. By focusing on the 'who' and 'why' of the agent, you create a more flexible and robust system that can handle edge cases better than a static list of instructions that might not cover every possible scenario.

Exam trap

Assuming that a detailed list of instructions is superior to a clear persona or role definition.

111
MCQhard

Refer to the exhibit. When using 'tool_choice': {'type': 'auto'}, how does Claude determine whether to use the 'get_stock_price' tool?

A.It executes the tool automatically if the word 'stock' appears in the prompt.
B.It only uses the tool if the user explicitly mentions the tool name.
C.The model decides based on whether the tool's description matches the user's request intent.
D.It randomly selects a tool whenever the user asks a question about finance.
AnswerC

When tool_choice is set to 'auto', Claude uses the description and schema provided for each tool to judge if calling that tool would help it respond to the user. This involves a high-level reasoning step where the model balances its internal knowledge with the available external tools.

Why this answer

In 'auto' mode, Claude evaluates the user's intent against the provided tool descriptions and schemas. If the model determines that a tool is necessary to fulfill the request, it will generate a tool-use block. This process is driven by the model's internal reasoning and its understanding of the tool's utility in context.

Exam trap

Candidates often assume the model uses external search or database queries automatically. They fail to recognize that the model relies solely on the provided tool descriptions to determine relevance.

112
MCQmedium

A marketing team wants Claude to generate blog posts that strictly adhere to a specific brand voice. They find that the model occasionally deviates into a generic tone. Which strategy is most effective for ensuring consistent adherence to the brand voice?

A.Add 'Do not be generic' to the system prompt.
B.Provide five examples of existing high-quality blog posts within XML tags.
C.Set the temperature to 1.0 to encourage creative writing.
D.Use a single-sentence instruction at the very end of the prompt.
AnswerB

Providing concrete examples allows the model to map the desired tone, vocabulary, and structure directly from the context. This few-shot technique is a fundamental pillar of prompt engineering for Claude, as it provides a clear reference point that significantly outperforms zero-shot instructions when trying to capture complex styles.

Why this answer

Few-shot prompting provides the model with specific patterns and stylistic nuances that are difficult to describe through instructions alone. By including several high-quality examples, the developer leverages Claude’s ability to perform in-context learning. This approach stabilizes the output quality and ensures the brand voice is maintained throughout the generated content, reducing stylistic drift during long generations.

Exam trap

Candidates often rely solely on generic system instructions like 'be professional' instead of using concrete few-shot examples within XML tags to eliminate stylistic drift.

113
MCQmedium

You are building a customer support bot and want to use few-shot examples to guide its tone. You find that the model occasionally reverts to a generic tone even when examples are provided. What is the most likely reason for this?

A.The system prompt does not clearly define the persona, and the examples are not distinct enough.
B.The model needs to be set to a higher temperature to allow for more creative tone generation.
C.You need to enable 'thinking' to help the model reason about the tone.
D.The model is ignoring the examples because they are not in the top-level system parameter.
AnswerA

If the instructions in the system prompt are vague, Claude will default to its standard, neutral tone. If the few-shot examples are also not distinctively styled, they fail to provide the necessary correction. To fix this, you need both a strong persona definition and examples that clearly and consistently demonstrate that exact tone.

Why this answer

Claude's behavior is dictated by the entirety of the prompt. If your system instructions are weak or contradictory, or if the examples provided are not sufficiently distinct in tone, the model will revert to its default helpful, generic persona. To ensure the desired tone is maintained, you must be very explicit in your system prompt about the persona and then use your few-shot examples to reinforce that specific tone through concrete, stylized dialogue.

The examples serve as the primary evidence of the 'voice' you want the bot to adopt.

Exam trap

Candidates often assume that providing just a few examples is enough, neglecting the importance of a strong, clearly defined system prompt that sets the stage for the tone.

114
MCQmedium

A product manager is drafting a system prompt for a customer-facing Claude assistant. They want the assistant to maintain a professional tone, avoid discussing competitors, and always end responses with a link to the help center. They also want to allow users to override the tone for casual conversations. Which statement about system prompts best guides this design?

A.The system prompt should be left empty, and all rules including tone and competitor avoidance should be embedded in the first user message of every session.
B.The system prompt should instruct Claude to ignore all user attempts to change its behavior, ensuring the professional tone and competitor rules are never overridden.
C.The system prompt should set the global role and rules, and the assistant can be instructed to allow user requests to adjust tone within defined bounds.
D.The system prompt should contain only the tone and competitor rules, while the help center link instruction belongs in each user turn to ensure it is followed.
AnswerC

System prompts establish persistent behavior and constraints for the assistant, making them the right place for global rules like professionalism and competitor avoidance. They can also define how user instructions may modify tone within limits, giving the desired flexibility. This design keeps consistent guardrails while honoring the product manager's intent to allow casual tone when users request it.

Why this answer

System prompts are the appropriate place for persistent, application-controlled behavior such as role, tone, and global restrictions, and they can also specify how user requests may modify certain aspects within defined limits. This provides consistent guardrails while allowing the desired flexibility. Relying on user messages, leaving the system prompt empty, or forbidding all overrides either weakens the guardrails or removes the intended flexibility.

Exam trap

The trap here is treating the system prompt as all-or-nothing, when it can both enforce fixed rules and define bounded flexibility for user-driven adjustments.

115
MCQhard

When using Claude as a tool-calling engine, what is the best strategy to handle scenarios where the model needs to call multiple tools in sequence?

A.Force the model to output all tool calls in a single JSON array at the very beginning of the response.
B.Provide clear descriptions for each tool that explain when and why they should be used.
C.Implement a 'Human-in-the-loop' check for every single tool call to ensure safety.
D.Use a system prompt to tell the model to use all tools in a specific hard-coded order regardless of the input.
AnswerB

Clear descriptions are vital for the model to correctly identify which tool to use in which situation. If the descriptions are vague or redundant, the model will struggle to select the appropriate tool or sequence. Well-defined tool interfaces are the prerequisite for reliable automated tool-use workflows in production environments.

Why this answer

The model's ability to call tools is dependent on clear documentation and well-structured tool definitions. By providing concise descriptions and expected input schemas, the model can infer the sequence required to solve a problem. Ensuring that tools are independent where possible, or clearly linked in intent, allows the model to chain them effectively to achieve complex tasks without manual intervention from the user.

Exam trap

Candidates often over-engineer prompts by trying to manually dictate the exact tool sequence, rather than trusting the model's ability to infer the correct order from clear tool descriptions and intent.

116
MCQmedium

You are building an application using Claude to extract structured data from messy user emails. The model occasionally ignores your schema constraints when the input text is ambiguous. Which strategy most effectively ensures strict adherence to the requested format?

A.Increase the temperature parameter to 1.0 to allow the model more creative flexibility in formatting.
B.Add a preamble asking the model to act as a helpful assistant that tries its best to output JSON.
C.Enclose the user input in <user_input> tags and include a few-shot example of the expected JSON structure within the system prompt.
D.Ask the model to output the result in a markdown code block without providing a schema definition.
AnswerC

XML tags provide clear delimiters that help Claude distinguish between instructions and data, reducing instruction leakage. Incorporating few-shot examples provides a concrete pattern for the model to follow, which is a highly effective way to enforce strict schema adherence, even when the input content is messy or ambiguous.

Why this answer

Using XML tags to delineate user input from instructions, coupled with a few-shot example of the desired JSON output, significantly improves schema adherence. This technique leverages Claude’s architectural strength in processing structured markup, reducing the likelihood of the model conflating input data with system instructions. Consistent formatting is vital in production pipelines where downstream systems expect rigid data schemas, as failure to comply can cause parsing errors and data loss.

Exam trap

Candidates frequently rely solely on system prompt instructions to enforce schema, failing to realize that few-shot examples and XML tagging are far more effective at anchoring the model.

117
MCQeasy

A support team wants Claude to classify incoming customer emails into one of five categories: Billing, Technical, Account, Feature Request, or Other. The team needs consistent, machine-readable output that a downstream script can parse reliably. Which prompt design best meets this requirement?

A.Ask Claude to choose the best category and, if multiple categories seem to apply, list them all separated by commas.
B.Ask Claude to explain its reasoning in a paragraph and end with the category name in bold.
C.Provide three examples of emails and their categories, then ask Claude to respond with the category and a confidence score between 0 and 100.
D.Instruct Claude to output only the category label, chosen from the predefined list, with no additional text.
AnswerD

Constraining the output to exactly one label from a predefined list produces consistent, easily parsed results. It eliminates ambiguity and reduces the chance of extraneous text breaking the downstream script. This directly satisfies the need for machine-readable output and consistent classification, making it the most reliable design for an automated pipeline.

Why this answer

When output feeds an automated script, the prompt should constrain the response to a single value from a predefined set and forbid extra text. This minimizes parsing complexity and ambiguity. Few-shot examples can improve consistency, but adding confidence scores or allowing multiple labels reintroduces variability.

Narrative explanations with formatting are human-friendly but not reliably machine-readable, so they fail the stated integration requirement.

Exam trap

The trap here is treating a human-readable answer with bold formatting or reasoning as machine-readable, when automation actually requires a strictly constrained, single-token-style label.

118
Multi-Selectmedium

A developer is building a Claude-based assistant that must answer questions about a 90,000-token product manual. The manual is provided in the prompt on every request. The developer wants to improve answer accuracy and reduce the chance of the model overlooking relevant sections. Which TWO techniques are most appropriate? (Choose two.)

Select 2 answers
A.Ask Claude to summarize the entire manual first, then answer the question based only on that summary.
B.Instruct Claude to answer only from the provided manual and to say 'I don't know' if the answer is not present.
C.Place the long manual content before the user's question and the specific instructions, so the model reads the source material first.
D.Increase the temperature to 1.0 so Claude considers a wider range of interpretations from the manual.
E.Split the manual into random fragments and include only a few fragments per request to keep the prompt short.
AnswersB, C

Explicitly grounding the answer in the provided manual and allowing a 'I don't know' response reduces hallucination and encourages the model to rely on the source. This is especially important with long documents where the model might otherwise fill gaps with general knowledge. It also gives users a clear signal when the manual lacks the needed information.

Why this answer

Long-context accuracy improves when the source material is placed before the question and instructions, and when the model is explicitly told to answer only from that source with a not-found fallback. These two techniques together reduce overlooking and hallucination. Raising temperature, summarizing first, or randomly sampling fragments either adds noise, loses detail, or risks omitting the relevant content entirely.

Exam trap

The trap here is assuming that shortening a long prompt by random sampling or summarizing is always beneficial, when it can remove the exact evidence needed to answer correctly.

119
MCQeasy

What is the primary purpose of a 'System Prompt' in the Anthropic Claude API?

A.To provide a place for users to input their variable data.
B.To define the model's persona and overarching behavioral rules.
C.To reduce the latency of the API response for small tasks.
D.To encrypt sensitive information before it reaches the model.
AnswerB

System prompts are specifically designed to set the context for how the model should behave. This includes defining its role, such as a 'helpful coding assistant' or a 'formal legal researcher,' and setting global rules that the model must follow throughout the entire interaction.

Why this answer

The system prompt serves as a foundation for the model's behavior, establishing its persona, operational constraints, and high-level goals. By separating these instructions from the user's specific request, the system prompt provides a consistent framework that persists across a multi-turn conversation, guiding the model's overall 'personality' and boundaries.

Exam trap

Candidates often place role definitions and overarching guardrails inside the user message, rather than utilizing the dedicated system prompt parameter.

120
MCQmedium

A product team drafts a system prompt for a customer-facing assistant. The draft is 4,000 words and mixes persona description, tone guidance, formatting rules, escalation policy, and several anecdotes about past incidents. Reviewers find that Claude follows the formatting rules but frequently ignores the escalation policy. Which change best improves adherence to the escalation policy?

A.Shorten the system prompt by deleting the formatting rules so the escalation policy receives more attention.
B.Restructure the system prompt into clearly labeled sections and place the escalation policy in its own section with explicit trigger conditions.
C.Convert the entire system prompt into a numbered list of every rule in the order it was originally written.
D.Move the escalation policy to the last line of the system prompt without changing its wording.
AnswerB

Isolating the escalation policy in a labeled section with concrete triggers makes it a distinct, findable instruction rather than one clause buried among thousands of words of narrative. Structured system prompts reduce interference between unrelated instructions, so the policy is more likely to be applied when a triggering condition appears in the conversation.

Why this answer

The escalation policy is being lost among unrelated narrative content. Giving it a dedicated, labeled section with explicit trigger conditions turns it into an unambiguous, retrievable instruction. Structural organization reduces interference between competing directives, which is why the fix is about clarity and grouping rather than length alone or ordering alone.

Exam trap

The trap here is assuming that a long system prompt is the root cause and that shortening it will fix compliance, when the actual defect is that the escalation policy lacks structure and explicit trigger conditions.

121
MCQmedium

Your team is evaluating a prompt for extracting data from technical manuals. You have discovered that the model often ignores specific sections of the manual when the content is very long. Which evaluation strategy best helps you identify the extent of this 'lost in the middle' phenomenon?

A.Instruct the model in the system prompt to 'pay closer attention to the entire document'.
B.Increase the `max_tokens` parameter significantly to ensure the model has enough output capacity.
C.Create a test set where the target information is placed at various positions in the manual to measure extraction success.
D.Enable prompt caching for the entire technical manual to speed up the processing of the document.
AnswerC

Systematically testing information retrieval across different positions in a document is the standard way to identify performance degradation. This approach provides empirical evidence of where the model struggles, allowing you to optimize your prompt or document organization based on actual retrieval patterns.

Why this answer

To find out whether the model is missing parts of a long document, build a test set that places the key information at different positions (beginning, middle and end) and measure extraction success at each position. This quantifies how well the model handles long inputs and tells you whether to restructure the document, split it, or reduce the context you provide.

Exam trap

Candidates often assume that simply adding more context or increasing max_tokens will automatically solve retrieval issues, ignoring the document's structure.

122
MCQeasy

A junior developer asks why they should use few-shot examples in their Claude prompt for a document classification task. What is the most accurate explanation for the benefit of this technique?

A.Examples clarify the expected transformation logic and output style, reducing ambiguity compared to instructions alone.
B.They effectively increase the context window size by allowing you to compress more information into the prompt.
C.They force the model to use its internal reasoning capabilities more effectively than descriptive system prompts.
D.They allow the model to permanently learn the new classification categories without the need for model fine-tuning.
AnswerA

Few-shot examples act as a bridge between your abstract instructions and the concrete reality of the task. By seeing examples, the model gains a clearer understanding of how to apply your instructions to real inputs, which leads to more accurate classification and consistent output formatting.

Why this answer

Few-shot examples provide the model with a concrete, observable pattern of how to interpret inputs and generate the desired output. For tasks like classification, where the definitions of categories might be subtle or dependent on specific nuances, examples clarify the requirements far better than a purely descriptive instruction. This technique helps the model 'see' the expected output for various inputs, reducing ambiguity and improving consistency across different, potentially complex documents.

Exam trap

Candidates often think few-shot prompting is for 'training' the model, which is incorrect; it is about providing context for the current task.

← PreviousPage 2 of 2 · 122 questions total

Ready to test yourself?

Try a timed practice session using only Prompting And Context Engineering questions.