A parks-and-recreation department wants every JSON program schedule that Claude Code writes to disk to be automatically checked for valid syntax immediately after the write completes, with the agent blocked from moving on if the file fails to parse. Which mechanism should enforce this?
Select an answer to reveal the explanation.
Short Explanation
A note in CLAUDE.md is a sticky note on the printer; a PostToolUse hook is a printer that refuses the jammed page. It runs after Write and blocks on unparseable JSON.
Full Explanation
The requirement here is enforcement, and enforcement means something outside the model's discretion runs on a defined event. Claude Code hooks attach deterministic shell commands to points in the tool-calling lifecycle, which is what separates a control that always fires from an instruction the agent may or may not honor under context pressure.
A PostToolUse hook fires immediately after the Write tool completes, so it can inspect the exact schedule file just produced, run a JSON parser against it, and return a blocking error when parsing fails. The failure is surfaced back to the agent as something it must address before continuing, closing the loop automatically at the moment the file reaches disk.
A CLAUDE.md request is context the model weighs alongside everything else, so it degrades exactly when the session is busiest; a weekly manual audit detects a broken schedule days after downstream systems consumed it and depends entirely on human follow-through; and a comment inside the file has no executable effect at all, speaking only to future human readers.
Exam caveat: hooks run with the user's own shell privileges and their failures block real work, so a slow, flaky, or over-broad hook becomes its own outage; scope the matcher to the schedule paths it is meant to guard. Operational check: have the agent write a deliberately malformed program schedule and confirm the hook returns a non-zero blocking error that the agent then acts on.