Questions? Call 1.800.716.8955

Chapter 12

Drill bank

Sixty extra scenario questions for targeted practice, each followed immediately by its answer and explanation. Unlike the practice exams, these are meant to be worked one domain at a time: pick your weakest domain from your practice-exam score report and drill it here.

Applications and Integration drills (D1 to D20)

D1. A team's Python service creates a new Anthropic() client inside every request handler. What is the best improvement?

  • A. Create one client at startup and reuse it.
  • B. Create two clients per request for redundancy.
  • C. Switch to raw HTTP.
  • D. Disable retries.

Answer: A. Clients hold connection pools and configuration; reusing one avoids overhead and keeps retry behavior consistent.

D2. A developer sets the SDK timeout to 30 seconds and sees timeouts on long reports with max_tokens of 32,000. What is the best fix?

  • A. Lower max_tokens to 1,000.
  • B. Stream the response (or raise the timeout).
  • C. Switch to Haiku.
  • D. Use the Batch API for an interactive request.

Answer: B. Long generations take time; streaming returns data continuously and avoids request timeouts.

D3. Which header tells the API which version of the request format you are using?

  • A. x-api-key
  • B. anthropic-beta
  • C. anthropic-version
  • D. content-type

Answer: C. anthropic-version pins the API version; anthropic-beta opts into beta features. D4. A developer enables a beta feature by adding an unknown value to the anthropic-beta header. What error is likely?

  • A. 400 invalid request
  • B. 429 rate limit
  • C. 529 overloaded
  • D. 200 with a warning

Answer: A. An unrecognized or non-enabled beta value is rejected as an invalid request. D5. An app sends a 300-page PDF for every question about it, base64-encoded. Which two changes most reduce cost and payload? (Choose two.)

  • A. Upload via the Files API and reference the file_id.
  • B. Add a cache breakpoint after the document.
  • C. Increase max_tokens.
  • D. Remove the system prompt.

Answer: A, B. Files avoid re-uploading; caching makes the repeated document cheap to process. D6. A response contains a text block, then a tool_use block. What should the app do with the text?

  • A. Discard the whole response.
  • B. Show it as the final answer.
  • C. Keep it in the assistant turn in history, and optionally display it as progress, while running the tool.
  • D. Send it back as a tool_result.

Answer: C. Assistant content must be preserved in full; text before a tool call is often a short explanation of what Claude is about to do. D7. A Batch job is not needed until tomorrow, but each request is small and there are only 40 of them. Is the Batch API still sensible?

  • A. No, batches require at least 10,000 requests.
  • B. Yes, if the 50% saving matters and a delay is acceptable; there is no minimum size.
  • C. No, batches only accept Haiku.
  • D. Yes, but only with streaming.

Answer: B. The Batch API has limits on maximum size, not a minimum.

D8. A team wants to build its own retrieval over 2 million support articles. Where should the retrieval happen?

  • A. Paste all articles into the context window.
  • B. In the application: search an index, then put the top results in the request (or expose search as a tool).
  • C. Ask Claude to memorize them.
  • D. Upload them all as one file per request.

Answer: B. The Messages API only sees what you send; retrieval selects the relevant few. D9. What is the main design risk when caching a system prompt that contains customer-specific data in a multi-tenant app?

  • A. Caching is slower.
  • B. Each tenant gets a separate cache entry, reducing reuse, and mixing tenant data into shared prefixes risks leakage if done wrongly.
  • C. Cached content is visible to other customers by default.
  • D. Caching disables tools.

Answer: B. Keep shared instructions identical across tenants and bring tenant data in after the breakpoint or via tools.

D10. An integration uses REST calls written by hand in a Python service. What is the main benefit of switching to the official SDK?

  • A. Lower token prices.
  • B. Typed responses, built-in retries, streaming helpers, and typed errors.
  • C. Access to secret models.
  • D. No need for an API key.

Answer: B. The SDK wraps the same REST API with conveniences; pricing is unchanged. D11. A developer receives a tool_use block whose input arrives as a string with unusual escaping. How should they read it?

  • A. With string matching on the raw text.
  • B. With a real JSON parser (or the SDK's parsed object), never raw string matching.
  • C. By asking Claude to resend it.
  • D. By lowercasing the string.

Answer: B. JSON escaping can vary between models; parse properly.

D12. Users in Japan report slower responses than users in the US. Which factor is in the developer's control?

  • A. Model weights.
  • B. Platform and region choices, streaming, and response length.
  • C. The speed of light.
  • D. Anthropic's internal scheduling.

Answer: B. Choose deployment options and regions appropriately, stream, and keep outputs concise.

D13. A product needs answers grounded in documents with exact quotes and also wants a strict JSON response. What is the constraint?

  • A. Citations and structured outputs cannot be combined in one request, so split into two steps or validate quotes in code.
  • B. Documents cannot be used with JSON.
  • C. JSON requires Haiku.
  • D. There is no constraint.

Answer: A. Plan the pipeline around that limitation.

D14. Which practice best supports "systems life cycle" maintenance of a Claude app?

  • A. Never updating the model.
  • B. Scheduled reviews of model deprecations, cost, quality metrics, and prompt versions, with an eval-gated upgrade path.
  • C. Rewriting the app every quarter.
  • D. Relying on users to report problems.

Answer: B. Operate and maintain deliberately with measurement.

D15. In a code review, you find a prompt string built by concatenating raw user input into the system prompt. What is the issue?

  • A. Performance only.
  • B. It mixes untrusted input with trusted instructions, enabling injection, and breaks caching.
  • C. Python strings are slow.
  • D. Nothing; this is standard.

Answer: B. User input belongs in the user turn, tagged as data.

D16. A team runs Claude on Bedrock and wants a feature just announced for the first-party API. What should they do first?

  • A. Assume it is available.
  • B. Check Bedrock's documentation for availability and any differences.
  • C. Switch clouds.
  • D. Use a beta header on Bedrock.

Answer: B. Feature availability can differ or lag on partner platforms.

D17. Which statement about the system parameter is true?

  • A. It can be a string or a list of text blocks (for example to add cache breakpoints).
  • B. It must be the first message in messages.
  • C. It is ignored by the API.
  • D. It is limited to 100 characters.

Answer: A. A list of blocks lets you attach cache_control to parts of the system prompt. D18. A developer wants Claude to stop generating as soon as it writes </answer>. Which parameter?

  • A. max_tokens
  • B. stop_sequences
  • C. tool_choice
  • D. metadata

Answer: B. Stop sequences end generation at a chosen string; stop_reason becomes stop_sequence.

D19. A non-functional requirement says "99.9% availability." Which design element addresses it most directly?

  • A. Better prompts.
  • B. Retries with backoff, graceful degradation, monitoring, and possibly a fallback model or platform.
  • C. Higher effort.
  • D. More few-shot examples.

Answer: B. Availability is an infrastructure concern addressed by resilience patterns. D20. An app mixes claude-sonnet-5-5 for chat and claude-haiku-5-5 for classification. Where should these IDs be defined?

  • A. Hard-coded in many files.
  • B. In one configuration source, versioned, so changes are reviewed and consistent.
  • C. In the system prompt.
  • D. In user settings.

Answer: B. Configuration management keeps model versions explicit and auditable.

Model Selection and Optimization drills (D21 to D30)

D21. Which change reduces output-token cost without changing the model?

  • A. Ask for concise answers and a specific format.
  • B. Raise max_tokens.
  • C. Add more examples.
  • D. Use a longer system prompt.

Answer: A. You pay for tokens generated; shorter requested outputs cost less. D22. A team measures cost per request but not per resolved ticket. Why might this mislead them?

  • A. It does not.
  • B. A cheaper configuration may need more turns or human fixes, raising total cost per outcome.
  • C. Cost per request includes salaries.
  • D. Tickets are free.

Answer: B. Judge cost per completed task.

D23. What does temperature historically control, and what is its status on current models?

  • A. Speed; still required.
  • B. Sampling randomness; removed on recent models and rejected from API version 2026-10-21.
  • C. Context size; optional.
  • D. Cost; deprecated in 2024.

Answer: B. Design for variability with validation instead of relying on sampling settings. D24. A developer sees cache_creation_input_tokens of 40,000 on every request in a multiturn chat. Turns arrive every 2 minutes. What is the most likely cause?

  • A. The TTL is too long.
  • B. Something before the breakpoint changes each turn, such as edited history or a varying system value.
  • C. The model does not support caching.
  • D. Streaming disables caching.

Answer: B. Two-minute gaps are within the 5-minute TTL; a changing prefix forces rewrites. D25. Which statement about extended or adaptive thinking cost is true?

  • A. Thinking is free.
  • B. Thinking tokens are billed as output tokens, so effort affects cost.
  • C. Thinking is billed as cached input.
  • D. Thinking costs only on Haiku.

Answer: B. Higher effort generally means more tokens and latency.

D26. A breaking change in a new model release is best caught by what?

  • A. Reading marketing pages.
  • B. Running your integration tests and eval suite against the new model before switching.
  • C. Waiting for user complaints.
  • D. Restarting servers.

Answer: B. Test request compatibility and quality before migration.

D27. Which is the best reason to choose an Opus-tier model over Sonnet for a feature?

  • A. It is newer.
  • B. Evals show the task needs its extra capability, and the value justifies the cost.
  • C. It has a larger logo.
  • D. It is always faster.

Answer: B. Choose by measured quality against requirements.

D28. What is "fast mode"?

  • A. A cheaper Haiku tier.
  • B. A research-preview option on some Opus models that generates output faster at premium pricing.
  • C. The Batch API.
  • D. Streaming.

Answer: B. It trades price for output speed on supported models.

D29. A developer integrates via an SDK that wraps REST, but their front end needs live updates from the backend. Which technology fits the backend-to-browser hop?

  • A. Server-sent events or websockets.
  • B. Batch API.
  • C. Files API.
  • D. Cron jobs.

Answer: A. Either can relay a stream to the browser; the Claude API itself streams over SSE. D30. Your token counts rose 25% after a model upgrade with identical prompts. What should you update?

  • A. Nothing.
  • B. Cost models, budgets, and context-limit checks, re-measured with the token counting endpoint.
  • C. The API key.
  • D. The SDK timeout only.

Answer: B. Tokenizers change across generations; re-baseline.

Agents and Workflows drills (D31 to D38)

D31. An agent sometimes stops after one tool call and gives a partial answer. The loop exits when the response contains any text. What is wrong?

  • A. Nothing.
  • B. The model is too small.
  • C. The context window is full.
  • D. The loop should continue while stop_reason is tool_use, not exit on the presence of text. Answer: D. Responses often contain text and tool calls together; stop_reason is the correct signal. D32. A team wants a quick internal agent with built-in file tools, but must also intercept every tool call for approval. Which product features combine for this?
  • A. The Agent SDK with permission settings and PreToolUse hooks.
  • B. The Batch API with streaming.
  • C. Structured outputs.
  • D. Prompt caching.

Answer: A. The Agent SDK provides built-in tools; permissions and hooks provide approval control. D33. When is a single LLM call better than a workflow?

  • A. Never.
  • B. Always.
  • C. When one well-designed prompt (with retrieval or examples) reliably meets the requirement.
  • D. Only on Haiku.

Answer: C. Start with the simplest tier that works.

D34. A supervisor agent passes the full conversation history to every subagent. What problem does this cause?

  • A. It removes the main benefit of subagents (context isolation) and wastes tokens.
  • B. Subagents run faster.
  • C. It improves privacy.
  • D. None.

Answer: A. Give each subagent only the context its task needs.

D35. Which component makes an agent's "never email outside the company" rule enforceable?

  • A. A capitalized system-prompt instruction.
  • B. A recipient allow-list check in the email tool's code (or a hook).
  • C. A few-shot example.
  • D. Higher effort.

Answer: B. Enforcement happens in code.

D36. What does a self-hosted agent deployment give you that Anthropic-hosted Managed Agents does not?

  • A. Lower model prices.
  • B. Built-in tools.
  • C. Full control of the execution environment and network boundary.
  • D. No need for an API key.

Answer: C. You own and operate the infrastructure.

D37. A planning agent produces good plans but the executing agent ignores them. What helps most?

  • A. Pass the plan as an explicit, structured artifact (such as a checklist file) that the executor reads and updates.
  • B. Raise temperature.
  • C. Remove the planner.
  • D. Use the Batch API.

Answer: A. Persist shared state outside conversational context.

D38. Which situation most clearly calls for memory?

  • A. A one-shot classification.
  • B. A daily assistant that should remember a user's ongoing projects across sessions.
  • C. A batch translation job.
  • D. A stateless API proxy.

Answer: B. Cross-session continuity needs persistent memory.

Prompt and Context Engineering drills (D39 to D45)

D39. Claude's answers are accurate but too long for a mobile widget. What is the most effective prompt change?

  • A. "BE SHORT."
  • B. Lower max_tokens to 50 and accept truncation.
  • C. Explain the constraint and target: "This appears in a small mobile widget; answer in at most two sentences."
  • D. Remove the system prompt.

Answer: C. Context and a concrete target beat shouting or hard truncation.

D40. Which placement is most robust for operator instructions that must apply to every turn?

  • A. Repeated in every user message by the end user.
  • B. The system prompt (or mid-conversation system messages on models that support them).
  • C. An assistant message.
  • D. A tool result.

Answer: B. Operator instructions belong in the system channel.

D41. A prompt asks Claude to "think step by step" and also enables adaptive thinking at high effort. What is a reasonable cleanup?

  • A. Add more "think" instructions.
  • B. Disable thinking.
  • C. Switch to Haiku.
  • D. Remove the manual instruction and rely on the thinking setting, then confirm with evals. Answer: D. Prompts written for older models often carry redundant scaffolding. D42. Tool results in a long agent session are large logs. Which technique reduces context bloat most directly?
  • A. Context editing to clear old tool results, plus tools that return summaries.
  • B. Bigger context window.
  • C. More examples.
  • D. Higher effort.

Answer: A. Remove what is no longer needed and keep results compact.

D43. A customer pastes a 2,000-line log and asks "why did this fail?" Where should the question go?

  • A. Before the log.
  • B. After the log, at the end of the user message.
  • C. In the system prompt.
  • D. In a separate request without the log.

Answer: B. For long inputs, put the question last.

D44. Output must feed a downstream program. Which approach is most reliable?

  • A. Ask nicely for JSON.
  • B. Regex the response.
  • C. Use structured outputs with a schema and validate business rules in code.
  • D. Use a stop sequence.

Answer: C. Guaranteed shape plus validation.

D45. An extraction prompt works well on clean PDFs but fails on scanned ones. What is the best first step?

  • A. Add scanned examples to the eval set and inspect what text Claude actually received.
  • B. Raise temperature.
  • C. Give up on scans.
  • D. Use a smaller model.

Answer: A. Check the input before changing the prompt; measure the new case.

Tools and MCPs drills (D46 to D52)

D46. Which tool name is best?

  • A. do_it
  • B. tool1
  • C. data
  • D. billing_get_invoice

Answer: D. Namespaced, specific names help selection.

D47. A tool can take 30 seconds to run. What should the agent harness do?

  • A. Run it and let Claude wait; tool time does not count against generation, but set timeouts and consider asynchronous patterns for very long jobs.
  • B. Cancel every tool after 1 second.
  • C. Skip the tool.
  • D. Return a fake result immediately.

Answer: A. Handle latency with timeouts and, for very long jobs, start-and-poll tools.

D48. An MCP server returns errors as raw stack traces. What should change?

  • A. Return concise, actionable error messages as tool results, and log full details server-side.
  • B. Hide all errors.
  • C. Crash the server.
  • D. Return success with empty data.

Answer: A. Claude needs actionable errors; operators need full logs.

D49. Your MCP server should let users invoke a "weekly report" template from a slash menu. Which primitive?

  • A. Tool
  • B. Resource
  • C. Prompt
  • D. Root

Answer: C. Prompts are user-invoked templates.

D50. Which is a client-side Anthropic-defined tool rather than a server tool?

  • A. Web search
  • B. Bash
  • C. Web fetch
  • D. Code execution

Answer: B. Anthropic defines the bash schema, but your environment executes it. D51. A remote MCP server is shared by many users. What must it do on every tool call?

  • A. Authenticate and authorize the calling user for that action.
  • B. Trust the model's claims about who the user is.
  • C. Log nothing.
  • D. Use a single shared admin token.

Answer: A. Authorization belongs in the server.

D52. When is strict: true on a tool most valuable?

  • A. When a tool has no parameters.
  • B. When downstream code will break on malformed or missing arguments.
  • C. Only in batches.
  • D. Only for server tools.

Answer: B. Strict mode guarantees inputs match the schema.

Security and Safety drills (D53 to D57)

D53. Which is a data-leakage risk specific to LLM apps?

  • A. Slow responses.
  • B. Sensitive data in prompts appearing in logs, caches, or outputs to the wrong user.
  • C. High token prices.
  • D. Using streaming.

Answer: B. Control what goes into prompts and where prompts and outputs are stored. D54. A reviewer asks how your agent prevents an attacker-controlled document from triggering a wire transfer. Which answer is strongest?

  • A. "Our prompt tells it not to."
  • B. "We use the biggest model."
  • C. "We trust our users."
  • D. "The transfer tool is not available in document-processing flows, and transfers require human approval enforced in code." Answer: D. Capability separation and enforced approval.

D55. Where should content-policy guardrails sit for a public chat product?

  • A. Input screening, the system prompt, output screening, and abuse monitoring, in layers.
  • B. Only in the system prompt.
  • C. Only in user terms of service.
  • D. Nowhere; the model handles it.

Answer: A. Layer controls.

D56. A developer leaves an API key in a public GitHub gist. What is the first action?

  • A. Delete the gist and hope.
  • B. Revoke the key immediately, then issue a new one and review usage.
  • C. Change the password on the developer's laptop.
  • D. Wait for the monthly rotation.

Answer: B. Revoke first.

D57. Which hook use most directly prevents destructive actions?

  • A. A PostToolUse hook that logs results.
  • B. A Stop hook that summarizes.
  • C. A PreToolUse hook that denies matching commands before they run.
  • D. A session-start hook that prints a greeting.

Answer: C. Only a pre-execution check can stop the action.

Claude Code drills (D58 and D59)

D58. A team wants a reusable /review-pr command with a standard checklist. What should they create?

  • A. A custom slash command or Skill in .claude/ committed to the repository.
  • B. A personal note.
  • C. A new model.
  • D. A batch job.

Answer: A. Shared commands and Skills live in the project's .claude/ folder. D59. Which statement about CLAUDE.md in subfolders is correct?

  • A. They are ignored.
  • B. They replace the root file entirely.
  • C. They add folder-specific guidance when Claude works in that part of the repository.
  • D. They must contain settings JSON.

Answer: C. The hierarchy layers more specific guidance on top of broader files.

Eval, Testing, and Debugging drill (D60)

D60. A prompt change improves overall eval accuracy from 88% to 91%, but accuracy on the "cancellation" category drops from 95% to 70%. What should the team do?

  • A. Ship it; the average went up.
  • B. Investigate the regression, check per-category results, and fix it before shipping, because cancellations may matter more than their share of tickets.
  • C. Delete the cancellation cases from the eval.
  • D. Switch models.

Answer: B. Look beyond averages; weight results by business impact.

Use ← → to move between sections