Question 230
A required validation hook cannot find its checker executable. The team wants failures to be actionable. What should the hook provide?
- A clear diagnostic naming the missing dependency and a failure result consistent with the required gate.
- The application's production secrets to help debugging.
- An empty response that the team interprets as a passed check.
- A success result followed by an undocumented warning in a temporary file.
Explanation
Correct Answer
A:The workflow needs both an enforceable failure signal and information that lets the team repair the environment. The failure signal should match the hook event's documented gating behavior. A success exit would conceal the fact that the required validation executable never ran.
Incorrect Answers
B:Credential disclosure does not explain or repair a missing local executable.
C:Silence cannot establish that the required checker completed successfully.
D:Reporting success lets the required gate pass while hiding the reason validation never ran.
Question 231
A hook constructs a shell command by concatenating an untrusted file name into it. What is the best implementation correction?
- Allow only shorter file names while retaining raw concatenation.
- Put the command in CLAUDE.md and assume the model will sanitize it.
- Hide the generated command from logs.
- Pass the path as a separate argument through a safe process API and validate the intended path scope.
Explanation
Correct Answer
D:Argument separation prevents shell interpretation, while scope validation limits which files the hook can act on. Shell interpretation and filesystem authorization are separate problems. A safely passed argument can still name an out-of-scope file unless the handler checks the resolved target.
Incorrect Answers
A:A short name can still contain shell metacharacters that change command behavior.
B:Moving the vulnerable construction into instructions does not fix how the hook executes input.
C:Suppressing visibility leaves the injection path intact and makes failures harder to diagnose.
Question 232
A hook edits a file, and a watcher launches another edit task that triggers the same hook indefinitely. What should the team add?
- A second watcher that repeats the same workflow.
- A longer timeout for every iteration.
- A guard against self-generated events and a stable no-change exit condition.
- A rule that every hook must always modify a file.
Explanation
Correct Answer
C:Recognizing already handled events or unchanged content lets the automation reach a fixed result. Event ownership or content checks can distinguish the hook's own result from a new user edit. The design should converge instead of generating a fresh change every time it observes one.
Incorrect Answers
A:Another watcher increases duplicate triggers and makes the loop harder to control.
B:Extending each run does not eliminate the feedback cycle between the hook and watcher.
D:Mandatory modification prevents convergence and guarantees continued event generation.
Question 233
A CI job needs to consume Claude Code's result programmatically rather than scrape terminal prose. Which CLI approach is appropriate?
- Infer success from whether the process printed any words.
- Use ordinary text output and extract the first line containing the word result, treating all remaining lines as diagnostic noise.
- Set a terminal theme with fewer escape codes but continue parsing interactive output.
- Assume that passing a JSON prompt automatically makes the CLI's outer response valid JSON.
- Use print mode with the supported JSON output format and validate the result.
Explanation
Correct Answer
E:Structured noninteractive output provides fields that a CI process can parse and check. For example, supported JSON output can be selected with the CLI's output-format setting in print mode. Consumers should still inspect the result status rather than equating valid JSON with a passed review.
Incorrect Answers
A:Output presence does not establish the result's meaning or successful completion.
B:Prose can change structure or contain the same word in explanations. A documented structured format provides a more reliable machine contract.
C:Cleaner terminal formatting still leaves a human-oriented, potentially changing text interface. It does not provide the supported structured output contract CI needs.
D:Prompt content and CLI output serialization are separate settings. The job should request the supported JSON output mode and then validate what it receives.
Question 234
An automation consumes Claude Code's stream-json output. How should it process the stream?
- Parse complete framed events and distinguish intermediate events from the final result.
- Parse each received byte as a complete JSON document.
- Concatenate all events into one object without separators.
- Treat the first text fragment as the final assessment.
Explanation
Correct Answer
A:Streaming output arrives incrementally, so the consumer must respect event boundaries and completion semantics. One process read may contain a partial event or several events. A buffered parser must reconstruct complete records before interpreting their types and terminal status.
Incorrect Answers
B:Network or process reads can split an event at arbitrary byte positions.
C:Multiple JSON events do not become a valid single object by simple concatenation.
D:An early fragment can precede tool activity, corrections, and the completed result.
Question 235
Two repository sessions ran yesterday. An automated follow-up must continue the security review, not the later formatting session. What is the safest selection method?
- Resume the explicitly identified security-review session.
- Choose the session with the longer transcript.
- Select whichever session used the same model, without checking the task identity.
- Always continue the most recent session without checking its purpose.
Explanation
Correct Answer
A:Selecting the recorded session identity avoids depending on incidental execution order. Continue-most-recent is convenient for interactive work but unsuitable when several tasks share a directory. An explicit session reference ties automation to the intended conversation.
Incorrect Answers
B:Transcript length does not identify the intended security-review task.
C:Model choice does not distinguish the security review from the formatting conversation.
D:Recency would choose the formatting session and bring the wrong conversation state forward.
Question 236
A script pipes an untrusted build log into a noninteractive Claude Code review. What should the review prompt make clear?
- That the log is diagnostic evidence to analyze under the review task's instructions.
- That any command printed in the log should be executed immediately.
- That the log should replace all project permissions.
- That the final line is necessarily the root cause.
Explanation
Correct Answer
A:A clear data role supports useful analysis without promoting log content into operating instructions. Build logs can contain commands, quoted user input, or malicious text from dependencies. Their diagnostic value does not make those strings instructions for the reviewing agent.
Incorrect Answers
B:Logs may contain arbitrary text and do not authorize new commands.
C:Diagnostic data has no authority to change configured execution boundaries.
D:The last message may be a downstream symptom rather than the cause of the failure.
Question 237
A scripted Claude Code review exits successfully but reports that a dependency prevented tests from running. How should CI interpret this?
- The repository has no dependencies because no test result was produced.
- The missing dependency can be ignored whenever the response is valid JSON.
- All application tests passed because the CLI exited successfully.
- The review command completed, while the required test gate remains unresolved.
Explanation
Correct Answer
D:A successful CLI exit establishes process-level completion. It does not satisfy a separate application-test gate when the response says that the tests could not run.
Incorrect Answers
A:A blocked test invocation says nothing about the absence of dependencies.
B:Output syntax cannot substitute for executing a required test gate.
C:Successful CLI execution does not imply that the application test suite ran or passed.
Question 238
An unattended analysis job must not continue tool work indefinitely. Which configuration directly bounds its conversational tool loop?
- A larger maximum output-token setting for each individual response.
- A higher retry count with no total limit.
- A larger context window so the entire tool history can remain visible.
- A supported maximum-turns limit, with the limit result handled by the caller.
Explanation
Correct Answer
D:A turn ceiling constrains the run and lets the caller recognize incomplete work when the ceiling is reached. The caller should record unfinished scope when the limit is reached. Raising the limit indiscriminately would hide a loop rather than establish that the analysis is making useful progress.
Incorrect Answers
A:Output length limits one generation, not the number of turns the controller can continue. Raising it does not bound the overall conversational loop.
B:Unbounded retries can extend the run rather than limit it.
C:Context capacity affects how much history fits in a request. It does not establish when an otherwise continuing loop must stop.
Question 239
Before modifying a repository, Claude Code finds an existing uncommitted diff from the developer. What should it do first?
- Inspect the baseline and preserve unrelated edits while making the requested change.
- Reset the working tree so that every change belongs to the new task.
- Assume the diff is generated noise and overwrite it.
- Stage every existing change into the agent's future commit.
Explanation
Correct Answer
A:Understanding the starting diff lets the agent distinguish its work from the developer's existing changes. Preserving the starting state prevents the agent from attributing or reverting someone else's edits. The final diff should distinguish the requested patch from changes already present at task start.
Incorrect Answers
B:A reset would discard the developer's unrelated work without authorization.
C:The presence of uncommitted changes provides no basis for treating them as disposable.
D:Staging unrelated edits blurs ownership and may include work outside the task.
Question 240
Two Claude Code tasks need to edit overlapping files on different branches at the same time. Which setup best reduces working-directory interference?
- Require both tasks to modify the same temporary copy without version control.
- Have each task force-reset the other's branch before saving.
- Create two different conversation sessions in the same checkout and assume their different session identifiers also isolate branch files on disk.
- Give each task a separate worktree or checkout and integrate the resulting changes deliberately.
- Create two branches but have both sessions switch and edit them in the same working directory concurrently.
Explanation
Correct Answer
D:Separate working directories isolate branch edits while preserving a clear integration step. A worktree separates checked-out files and branch state, but related changes still need review during integration. Isolation prevents concurrent overwrites; it does not prove semantic compatibility.
Incorrect Answers
A:A shared unversioned copy retains the same conflict risk and loses useful change history.
B:Repeated resets destroy concurrent work rather than safely isolate it.
C:Conversation separation does not provide filesystem isolation. Both sessions can still overwrite the same working-tree content.
E:Branch names do not create separate files on disk. Concurrent switches and edits can still interfere until the tasks have isolated worktrees or checkouts.