Claude Certified Architect – Foundations Practice Question 3: PreToolUse Hook Guardrail

Claude Certified Architect, Foundations · Test 1 · question 3 of 10

Agent Architecture & Orchestrationhard

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?

Select one answer
Show answer and explanation

Answer:

  • A. Register a PreToolUse hook on the Bash tool that returns a deny decision for matching commands

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

Practice Test 1 ›

Study guides for Claude Certified Architect, Foundations