Claude Certified Architect – Foundations Practice Question 3: PreToolUse Hook Guardrail
Claude Certified Architect, Foundations · Test 1 · question 3 of 10
A company runs an agent built with the Claude Agent SDK that has shell access to a staging host. Policy says the agent must never run a command containing "rm -rf", and auditors need that guarantee to hold regardless of what users or retrieved documents say to the agent. The current control is a sentence in the system prompt, and a red team has bypassed it with a crafted document. What is the best fix?
Show answer and explanation
Answer:
A is correct. A PreToolUse hook runs in your application code before the tool executes and can return a permission decision of "deny" (with a reason that is fed back to Claude). Because it is deterministic code outside the model, it holds regardless of prompt injection or model behavior, which is what an audit-grade guarantee needs.
B is wrong because system-prompt instructions are probabilistic guidance; stronger wording and examples reduce but never eliminate bypasses. C is wrong because a PostToolUse hook fires after the tool has already run, so the destructive command would have executed. D is wrong because temperature does not make a model reliably ignore injected instructions, and it gives no guarantee at all.
Reference: Intercept and control agent behavior with hooks - Agent SDK