You are integrating Claude Code into your Continuous Integration/Continuous Deployment (CI/CD) pipeline. The system runs automated code reviews, generates test cases, and provides feedback on pull requests. You need to design prompts that provide actionable feedback and minimize false positives.
Your CI pipeline performs security-focused code reviews on approximately 50 pull requests daily, currently costing $150 per day using the synchronous API. Reviews are non-blocking---developers merge after tests pass and address findings in follow-up commits. You are evaluating the Message Batches API for its 50% cost reduction.
What factor most determines whether batch processing is appropriate for this use case?
Answer : C
Option C identifies the fundamental trade-off introduced by batch processing: lower cost in exchange for asynchronous completion and potentially substantial latency. Anthropic states that most Message Batches complete within one hour, but results may become available only when all requests finish or after 24 hours, whichever occurs first. Therefore, the workflow must remain useful even if security findings arrive considerably later than they would through synchronous requests.
The reviews are explicitly non-blocking, so batch processing can be suitable if developers can still act on delayed findings through follow-up commits. Option B describes an implementation requirement because batch results may be returned out of submission order, but Anthropic provides a deterministic solution through each request's unique custom_id. Option A incorrectly focuses on near-instant feedback, which batch processing does not provide. Option D is not decisive because batches support independent Messages API requests containing system prompts, tool use, and multi-turn conversation content. The primary decision is therefore whether the maximum practical feedback delay is acceptable to the development workflow. Anthropic Message Batches documentation
================
You are building a multi-agent research system using the Claude Agent SDK. A coordinator agent delegates to specialized subagents: one searches the web, one analyzes documents, one synthesizes findings, and one generates reports. The system researches topics and produces comprehensive, cited reports.
The synthesis agent receives summarized findings from the web-search and document-analysis agents, then passes a consolidated summary to the report generator. During testing, you discover that the generated reports make factual claims without proper citations. The report generator cannot attribute statements to their original sources because that metadata was lost during the summarization steps.
What is the most effective approach to ensure proper source attribution in the final reports?
Answer : A
Option A preserves provenance as first-class data throughout the pipeline. Each finding should contain the summarized claim, supporting excerpt, source identifier, URL or document title, and location information such as a page or content-block index. The synthesis agent can combine findings without severing the association between evidence and source, while the report generator can render citations directly from the structured records. Anthropic's Citations documentation explains that reliable citations identify the supporting passage and its precise source location, including PDF page ranges or content-block indices. Passing all raw output, option B, preserves evidence but introduces excessive context and makes source selection harder. Inline references in prose, option C, are vulnerable to being altered, omitted, or detached from claims during subsequent summarization. Option D repeats research after report generation and may locate a different source rather than the evidence originally used. A structured provenance contract should therefore be required in every subagent's output and validated at each handoff. The report generator should reject or flag factual claims that lack an associated evidence record instead of inventing or retrospectively reconstructing citations.
================
You are building a customer support resolution agent using the Claude Agent SDK. The agent handles high-ambiguity requests like returns, billing disputes, and account issues. It has access to your backend systems through custom Model Context Protocol (MCP) tools (get_customer, lookup_order, process_refund, escalate_to_human). Your target is 80%+ first-contact resolution while knowing when to escalate.
Anthropic's tool use documentation states: ''Write instructive error messages. Instead of generic errors like 'failed', include what went wrong and what Claude should try next.'' A billing dispute agent uses lookup_order, which catches all exceptions and returns a tool_result with is_error: true and the message ''Tool execution failed''. Monitoring shows two failure modes: the agent retries the identical call until hitting the turn limit, or it immediately calls escalate_to_human without trying alternative tools.
Which change follows the documented recommendation and gives Claude the information it needs to select the correct recovery action for each error type?
Answer : B
Option B preserves the formal failure indicator while making the returned content operationally useful. Anthropic's tool-use guidance states that when a tool fails, the application should return the error through tool_result content and mark it with is_error: true. Claude can then use that information to retry with corrected input, seek clarification, or explain the limitation. (https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/bash-tool)
The two example messages identify both the cause and the appropriate recovery path. ''Order not found'' indicates that repeating the same identifier will not help and proposes an alternative lookup method. ''Database timeout'' identifies a transient infrastructure condition for which a retry is reasonable. This eliminates blind repetition without removing Claude's ability to adapt.
Option A can be useful for tightly bounded low-level retries, but it does not solve permanent errors or tell the agent what happened after retries fail. Option C incorrectly disguises a failed operation as successful tool content. Option D moves semantic knowledge into hardcoded orchestration logic, making the system more rigid and duplicating information already known by the tool.
The most reliable tool interface combines the error flag, a stable error type, a retryability indicator, a concise causal explanation, and a recommended recovery action.
Official references/topics: is_error handling, instructive tool results, recovery guidance, resilient MCP tool design.
You are building developer productivity tools using the Claude Agent SDK. The agent helps engineers explore unfamiliar codebases, understand legacy systems, generate boilerplate code, and automate repetitive tasks. It uses the built-in tools (Read, Write, Bash, Grep, Glob) and integrates with Model Context Protocol (MCP) servers.
Your codebase exploration tool stores session IDs to allow engineers to continue investigations across work sessions. An engineer spent an hour yesterday analyzing a legacy authentication module, building context about its architecture and dependencies. They want to continue today. The session ID is valid, but version control shows 3 of the 12 files the agent previously read were modified overnight by a teammate's merge.
What approach best balances efficiency and accuracy?
Answer : B
Resuming preserves the prior architectural analysis, dependency mapping, and conversation history, avoiding the cost of repeating an hour of valid work. Anthropic states that resuming by session ID restores the agent's full prior context, including files read, analysis performed, and decisions made. (https://code.claude.com/docs/en/agent-sdk/sessions)
However, the session represents historical knowledge rather than a repository snapshot. Because three files changed externally, the agent must be told which files are affected and directed to re-read them before relying on earlier conclusions. Anthropic clarifies that sessions persist the conversation, not the filesystem. (https://code.claude.com/docs/en/agent-sdk/sessions) Targeted re-analysis updates the stale portion of the agent's model while retaining the nine unchanged files' established context.
Option A discards valuable work even though most of the analyzed code remains unchanged. Option C is accurate but inefficient because it reprocesses all twelve files regardless of whether they changed. Option D is unsafe: the agent may continue reasoning from obsolete function signatures, dependencies, or control flows.
The continuation prompt should identify the changed files, summarize the merge's purpose where known, and request a focused comparison against the earlier understanding. Any architectural conclusions affected by those changes should then be revised explicitly.
Official references/topics: Session Resume; Filesystem Versus Conversation State; Targeted Re-Analysis; Repository Change Awareness.
You are integrating Claude Code into your Continuous Integration/Continuous Deployment (CI/CD) pipeline. The system runs automated code reviews, generates test cases, and provides feedback on pull requests. You need to design prompts that provide actionable feedback and minimize false positives.
After deploying automated code review, developers report that approximately 35% of findings are false positives following consistent patterns: style suggestions that contradict team conventions, security warnings for patterns that are safe in the deployment environment, and performance suggestions that would degrade this particular use case.
You want to reduce false positives while enabling the model to generalize its judgment to novel code patterns it has not seen before.
Which approach is most effective?
Answer : B
Option B demonstrates the decision boundary Claude must learn. Carefully selected examples can show structurally similar code producing different outcomes based on project context---for example, an approved authentication wrapper versus an unsafe direct call, or a deliberate performance trade-off versus an accidental quadratic operation. These contrasts help Claude apply the underlying judgment to new code rather than merely memorizing prohibited phrases.
Anthropic identifies relevant, diverse, and clearly structured examples as one of the most reliable methods for improving output accuracy and consistency. It recommends several examples that mirror the real use case and cover important edge conditions. Option A risks creating an oversized negative catalogue that consumes context, becomes difficult to maintain, and cannot anticipate every future variation. Option C filters text after generation and may suppress genuine findings that happen to use the selected keywords. Option D is dangerously vague: telling a reviewer to be conservative can suppress real but uncertain defects and reduce recall. The prompt should provide paired acceptable/problematic examples, explain why each classification differs, and require concrete code evidence for every reported finding. Anthropic prompting best practices
================
You are building a multi-agent research system using the Claude Agent SDK. A coordinator agent delegates to specialized subagents: one searches the web, one analyzes documents, one synthesizes findings, and one generates reports. The system researches topics and produces comprehensive, cited reports.
Production reviews reveal inconsistent handling of uncertainty in final reports. Sometimes conflicting subagent findings are synthesized into a single confident statement, losing important nuance, while other reports use excessive qualifications and become unhelpful. The web-search agent returns, ''Industry analysts estimate a $50 billion market size, although methodologies vary.'' The document-analysis agent returns, ''A peer-reviewed study estimates $35 billion, with a $7 billion 95% confidence interval.'' The coordinator either selects one estimate arbitrarily or produces a vague $35--$50 billion range.
What systematic approach best addresses this?
Answer : D
Option D preserves the evidence instead of manufacturing certainty. The two estimates are not directly interchangeable: one is an industry estimate with unspecified methodology, while the other is a peer-reviewed estimate with an explicit confidence interval. Converting both into model-generated confidence scores and calculating a weighted average would create a new figure that neither source reported and that may have no statistical validity. Anthropic's hallucination-reduction guidance recommends making claims auditable through quotations, citations, and supporting evidence rather than presenting unsupported synthesis as fact. Its Citations documentation similarly emphasizes retaining the exact source passages supporting individual claims. Filtering uncertain findings, option B, would remove decision-relevant information. Requiring two-source corroboration, option C, could also discard credible evidence concerning emerging or specialized subjects. The synthesis agent should report the estimates separately, explain their methodological differences, identify which findings are strongly supported or disputed, and state what evidence would resolve the disagreement. This produces calibrated, useful reporting without arbitrary selection, excessive hedging, or false precision.
================
You are building a customer support resolution agent using the Claude Agent SDK. The agent handles high-ambiguity requests like returns, billing disputes, and account issues. It has access to your backend systems through custom Model Context Protocol (MCP) tools (get_customer, lookup_order, process_refund, escalate_to_human). Your target is 80%+ first-contact resolution while knowing when to escalate.
A customer returns 4 hours after their initial session about the same billing dispute. The previous 32-turn session contains lookup_order results showing ''Status: PENDING, Expected resolution: 24--48 hours.'' In testing, you observe that when resuming sessions with stale tool results, the agent often references the outdated data in responses (e.g., ''I see your refund is still being processed'') even after subsequent fresh tool calls return different information.
What approach most reliably handles returning customers?
Answer : D
Option D separates durable case history from volatile operational data. The new session receives a compact, structured summary describing the billing dispute, the customer's objective, actions previously taken, and the unresolved status. It does not inherit outdated backend observations as though they were still authoritative. Fresh tool calls then retrieve the current refund or order state before the agent responds.
Agent SDK sessions preserve conversation history, including earlier tool calls and tool results. Resuming the complete transcript therefore reintroduces stale system data into the active context, even though the external backend may have changed substantially during the four-hour gap. Conversation persistence must not be confused with persistence of external-system truth.
Option A performs unnecessary calls to every previously used tool, including tools unrelated to the returning customer's current question. Option B relies on prompt compliance while retaining contradictory historical evidence in context. Option C manually removes tool results from an existing transcript and may damage the logical relationship between prior tool_use and tool_result blocks while still retaining a long, unstructured conversation.
A structured summary should preserve stable identifiers, previous actions, customer commitments, and unresolved issues. Time-sensitive fields such as refund status, delivery state, account balance, or expected resolution should always be refreshed through authoritative tools.
Official references/topics: Session persistence, stale tool-result management, context compaction, fresh-data retrieval.