Question 20
An MCP server must expose a policy document as URI-addressable context and provide an explicit operation that submits a support ticket. Which pair of server primitives directly matches those requirements?
- Expose the policy as a resource and ticket submission as a tool.
- Expose both capabilities as resources whose reads encode the requested actions.
- Expose the policy as a prompt template and ticket creation as a resource read.
- Expose both capabilities as prompt templates and have the client infer which backend action to execute.
Explanation
Correct Answer
A:A resource represents retrievable context, while a tool exposes an operation the application may invoke. This separation makes reading policy and changing ticket state distinct capabilities.
Incorrect Answers
B:The document fits a resource, but ticket creation is an explicit state-changing invocation. Hiding it behind a read makes the action boundary unclear and does not match the specified primitive roles.
C:Prompt templates describe reusable interactions rather than a URI-addressable document. A resource read also does not express the requested explicit ticket-submission operation.
D:Prompts may guide a workflow, but a template is not itself the backend operation. This design lacks the direct context and action contracts requested in the stem.
Question 21
A document-search tool returns full text for 500 documents even when only two short passages match the question. What response design better supports an evidence-based answer within a limited context budget?
- Return ranked document titles and relevance scores, with no excerpts or follow-up retrieval.
- Return the matching passages, stable source references, and a path to retrieve more if needed.
- Return one generated conclusion and suppress the passages from which it was inferred.
- Return the first fixed number of characters from each of the 500 documents.
Explanation
Correct Answer
B:A focused result preserves evidence while avoiding bulk unrelated text. References and follow-up retrieval retain access to surrounding context when a passage needs qualification.
Incorrect Answers
A:Ranking helps select sources, but titles and scores do not contain the evidence for the answer. Without a way to fetch content, the assistant cannot check the underlying claims.
C:An opaque synthesis is compact but prevents the assistant from checking support or resolving conflicting evidence. The interface should retain a traceable route to the relevant source content.
D:Uniform truncation can discard the matching passage when it appears later in a document. It spends context on many irrelevant prefixes while failing to preserve the evidence actually requested.
Question 22
Customer authorization is already enforced by a CRM backend. The assistant needs only recent orders, but its unrestricted run_sql tool can also access unrelated tables and change records. Which interface change most directly narrows the operations it can request?
- Keep a generic SQL interface but reject statements containing the word DELETE.
- Expose a recent-orders endpoint with validated customer and date-range inputs.
- Keep unrestricted SQL and add an instruction to avoid unwanted tables.
- Retain unrestricted SQL but include a recent-orders query as the only prompt example.
Explanation
Correct Answer
B:A purpose-built endpoint limits the requested operation and returned data to the assigned read. Existing customer authorization remains necessary, while the interface no longer exposes general database execution.
Incorrect Answers
A:Blocking one command leaves other mutations and unrelated reads available. A keyword check also does not define the narrow recent-orders capability the assistant needs.
C:The instruction describes preferred behavior but leaves the broad database capability intact. A mistaken or injected query can still reach operations outside the task.
D:An example demonstrates preferred use without removing other executable operations. It cannot enforce a capability boundary on malformed or adversarially influenced requests.
Question 23
A Claude Messages response contains two client tool_use blocks. Both tools have finished. The next user message places a text introduction before the two tool_result blocks and is rejected. What correction addresses this formatting error?
- Keep the message order and replace tool_use_id with the corresponding tool name.
- Keep the introduction first and reverse the order of the two result blocks.
- Move the two results into a new assistant message and keep the text introduction in the user message.
- Put both correlated tool_result blocks first in the next user message, followed by any ordinary text.
Explanation
Correct Answer
D:The client-tool protocol requires results before text in the user content array. Retaining both results also answers every invocation from the preceding assistant message.
Incorrect Answers
A:The correlation field must refer to the original invocation ID. Replacing it with a name adds another error while leaving the text-before-results problem unchanged.
B:Swapping results does not fix the actual violation: ordinary text still precedes them. Invocation IDs handle correlation; the content-block placement rule is separate.
C:Client observations are returned as tool_result blocks in a user message. Changing the role does not satisfy the expected tool-result exchange.
Question 24
A team wants Claude Code to learn its repository's build command and coding conventions whenever a teammate starts work. Which placement best supports shared project guidance?
- Store the guidance only in one developer's personal home-directory instructions.
- Store the conventions solely in an individual session's conversation history.
- Commit concise project guidance in the repository's CLAUDE.md.
- Place the conventions only in a skill that is invoked manually for release tasks.
Explanation
Correct Answer
C:A project instruction file can travel with the source and provide recurring repository context. Version control lets the team review and update build commands as the project changes.
Incorrect Answers
A:Personal instructions are scoped to that developer's environment. Other teammates do not automatically receive them when cloning the repository.
B:Session history can help that conversation, but it is not a versioned instruction source shared by everyone who clones the repository. New teammates need the same baseline guidance.
D:A release-only procedure is not reliably loaded for ordinary coding work. The build command and coding conventions are baseline project guidance rather than occasional release instructions.
Question 25
Deployment authorization is already enforced by the backend. A Claude Code team also wants a local check to inspect proposed deployment-tool arguments and reject disallowed ones before invocation. Which lifecycle mechanism is appropriate?
- Use a PostToolUse hook to reject the deployment after reading its result.
- Use a SessionStart hook to approve any deployment arguments that might appear later.
- Use a Stop hook to inspect the final response and decide whether earlier deployment calls were allowed.
- Use a PreToolUse hook that inspects the proposed arguments and returns a deny decision when required.
Explanation
Correct Answer
D:This event occurs before tool execution and exposes the proposed call. It is the appropriate point for rejecting a covered operation based on its actual arguments.
Incorrect Answers
A:The result becomes available after the operation has run. Post-execution review can detect a problem but cannot serve as the requested prevention point.
B:Session initialization occurs before the specific tool request exists. It cannot inspect arguments that the model has not yet generated.
C:Turn-completion checks occur after earlier tool activity. They can govern continuation or reporting, but they do not prevent the preceding invocation.
Question 26
A repository has an occasional release-check procedure with several steps and supporting scripts. It is too long to include in always-needed project guidance. Which organization best fits this material?
- Package the procedure as a skill and keep a concise reference in the project's general guidance.
- Define the procedure only as a formatting rule for the final answer.
- Run the entire release procedure automatically from a hook on every source-file edit.
- Place the full release procedure and every script explanation in the always-loaded project instructions.
Explanation
Correct Answer
A:A skill can hold a reusable workflow and associated assets without expanding every task's baseline instructions. The short project reference helps Claude discover when that specialized procedure applies.
Incorrect Answers
B:An output-format rule controls presentation, not the operational steps and scripts that must run. It cannot replace the reusable workflow.
C:A deterministic hook can suit a small repeatable check. An occasional multistep release workflow should not run after unrelated edits without the release context.
D:This makes the workflow discoverable but imposes its full context cost on unrelated tasks. The scenario specifically seeks a home for occasional, extensive procedure content.
Question 27
Two repositories need the same specialized reviewer. Each developer should be able to use it locally across projects without committing its definition to either repository. Which Claude Code configuration scope fits?
- Place the definition in a temporary directory that neither project nor user configuration references.
- Commit the reviewer only under the first repository's project-level agents directory.
- Install the reviewer definition in the developer's user-level agents directory.
- Put the reviewer instructions only in the first project's CLAUDE.md.
Explanation
Correct Answer
C:A user-scoped subagent definition is available across that user's projects. It avoids adding the same agent file to each repository, while each developer still needs the local installation.
Incorrect Answers
A:An arbitrary file location does not make the definition discoverable as a configured agent. The file must live in a supported scope or be supplied through an explicit configuration mechanism.
B:A project-scoped definition belongs to that repository. It neither provides the intended cross-project local scope nor satisfies the requirement to avoid committing the definition.
D:Project guidance can recommend a workflow but is not a user-scoped subagent definition. It also ties the material to one project rather than installing the requested reusable reviewer.
Question 28
A CI job must invoke Claude Code once, capture its response, and terminate without an interactive conversation. Which documented invocation pattern is designed for this use?
- Use claude --continue as the job's only execution mode.
- Use claude --version and parse its output as the review result.
- Use claude -p with an explicit task and appropriate output handling.
- Run claude with an initial prompt in a terminal and keep the interactive session open.
Explanation
Correct Answer
C:Print mode supports a noninteractive request that returns output for the calling process. The CI job must still handle permissions, errors, exit status, and its own success criteria.
Incorrect Answers
A:Continuing a session controls which conversation is resumed. It does not by itself select the noninteractive print behavior the unattended job requires.
B:The version command reports the installed CLI version. It does not submit the repository review task or produce its requested analysis.
D:An initial prompt can start work, but an interactive session remains designed for subsequent interaction. Print mode supplies the single-request process behavior needed by the job.
Question 29
An automated code reviewer flags speculative problems in unchanged files. The team wants actionable findings tied to a pull request. Which change most directly improves the review contract?
- Suppress every finding that mentions code outside the changed lines.
- Classify every linter warning anywhere in the repository as a defect introduced by the pull request.
- Require the reviewer to report every hypothetical failure path without checking whether the diff makes it reachable.
- Limit findings to evidenced issues introduced by the diff and require file locations plus concrete impact.
Explanation
Correct Answer
D:The contract connects each finding to a changed behavior and verifiable evidence. Location and impact help maintainers distinguish a real regression from general style preferences or speculation.
Incorrect Answers
A:A diff can break callers or invariants in unchanged code. Reviewing surrounding context is necessary; the relevant boundary is whether the change introduces the issue, not where all its effects appear.
B:Existing warnings may be legitimate cleanup work without being introduced by the diff. This policy confuses repository debt with the specific change under review.
C:Listing possibilities can help brainstorming, but it does not establish a regression. Findings should explain an actual impact supported by the changed behavior.
Question 30
A monorepo has Python backend rules and TypeScript frontend rules. Putting both complete rule sets into every task causes confusion. Which organization is most appropriate?
- Use path-scoped rules for the relevant directories and retain only shared guidance globally.
- Put backend rules in each developer's global user instructions and frontend rules in shared project instructions.
- Keep both complete rule sets global and add a sentence telling Claude to choose whichever seems relevant.
- Choose one language's complete rules as the global standard for both directories.
Explanation
Correct Answer
A:Scope-specific instructions associate conventions with the files they govern. This reduces irrelevant context while preserving a consistent baseline for cross-cutting work.
Incorrect Answers
B:User scope applies across unrelated projects and varies between developers. Language-specific repository rules should be selected by project paths, not by who owns the local configuration.
C:This retains the irrelevant context that caused the problem. Explicit path scoping gives a more reliable association between each convention and the files it governs.
D:Some conventions are language-specific and cannot govern the other component correctly. A single global language policy loses the distinction that the monorepo needs.