CCDV-F Claude Code MEDIUM
PRODUCTION SCENARIO
A team's CLAUDE.md says never to edit files under infra/prod/, yet Claude Code still occasionally modifies them. The team wants a guarantee that holds regardless of what the model decides.

Which mechanism provides that guarantee?

Answering here is anonymous. Nothing is saved unless you sign in.

Show answer and explanation

Answer: A PreToolUse hook on Edit and Write that exits with code 2 for those paths

PreToolUse is the only one of these events that fires before the tool runs, and exit code 2 there blocks the call whatever JSON the hook prints, feeding the stderr reason back to Claude. PostToolUse fires after the tool has already run, so exit 2 cannot block it; the stderr reaches Claude only as a warning about a change already made. PermissionRequest does not honour exit 2 at all and expects a deny through its decision object. Exit 2 on Stop prevents Claude from stopping, which leaves the edit in place.
Free

Keep practicing CCDV-F

105 original CCDV-F practice questions, each with an explanation and a source link. No account needed.

Start free practice set → Timed, explained, free