Courseiva
Claude Code →hardMultiple Select

CCDV-F Claude Code Practice Question

A developer wants Claude Code to run a series of shell commands as part of a build task but is concerned about the assistant executing arbitrary or destructive commands. Which TWO practices reduce this risk while still allowing the needed commands to run? (Choose two.)

⚠ Common exam trap

The trap here is treating a written instruction in CLAUDE.md as a security control, when only enforced mechanisms like allow lists and hooks actually restrict which commands can execute.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Add a PreToolUse hook on the Bash tool that inspects the command and blocks anything outside the approved set.

Least-privilege controls are the right answer. An allow list in settings.json restricts execution to the specific build commands, and a PreToolUse hook on the Bash tool can inspect and block disallowed commands before they run. Together they permit the intended build while constraining arbitrary or destructive execution. Skipping permissions removes safeguards, memory-file advice is not enforced, and container hardening changes the environment rather than governing command selection.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    Add a PreToolUse hook on the Bash tool that inspects the command and blocks anything outside the approved set.

    Why this is correct

    A PreToolUse hook can examine the proposed Bash command and reject it before execution, providing a programmatic guardrail beyond static allow lists. This lets the developer enforce custom rules, such as rejecting commands containing destructive flags, while still permitting the build commands. It is a flexible way to reduce risk during shell execution without removing the ability to run what is needed.

  • ✗

    Instruct Claude Code in CLAUDE.md to never run dangerous commands.

    Why it's wrong here

    Guidance in CLAUDE.md is contextual advice, not an enforced control. The model may still propose a dangerous command, especially under ambiguous instructions, and there is no hard block. While documenting intent is good practice, it does not by itself reduce the risk of arbitrary execution in a reliable, verifiable way, so it is not one of the two practices that actually constrain behavior.

  • ✗

    Run the build inside a container with no network access and a read-only filesystem.

    Why it's wrong here

    Container isolation is a valid defense-in-depth measure, but the scenario asks for practices that reduce risk while still allowing the needed commands to run as part of the build task. A read-only filesystem would often prevent the build from writing artifacts, breaking the task. Isolation changes the environment rather than governing which commands Claude Code may execute, so it does not directly address the stated concern within the workflow.

  • ✗

    Enable `--dangerously-skip-permissions` to avoid prompts during the build.

    Why it's wrong here

    Skipping permissions removes the confirmation step and allows Claude Code to run commands without review, which increases rather than reduces risk. The scenario is specifically about reducing the chance of arbitrary or destructive commands, so disabling safeguards is counterproductive. This flag is intended for isolated environments where risk is acceptable, not for a cautious build workflow.

  • ✓

    Define an allow list in `.claude/settings.json` that permits only the specific build commands the task requires.

    Why this is correct

    An allow list restricts Claude Code to a known set of commands, so the build task can run while unrelated or destructive commands are blocked or require approval. This directly limits the blast radius without preventing the intended workflow. Scoping permissions to exactly what the task needs is the recommended least-privilege approach for shell execution in Claude Code.

About these practice questions

One of 257 original CCDV-F practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Anthropic exam blueprint

This CCDV-F practice question is part of Courseiva's free Anthropic certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CCDV-F exam.