A rule must hold no matter what Claude decides in Claude Code. Where does it belong?
Why C is the answer
In a PreToolUse hook
CLAUDE.md is context that guides Claude, not enforcement. The Claude Code docs say to use a PreToolUse hook to block an action regardless of what Claude decides.
In detail
- CLAUDE.md is context that guides Claude, not enforcement.
- The docs say to use a PreToolUse hook to block an action regardless of what Claude decides.
- Use CLAUDE.md for guidance, and hooks for rules.
Use case
An illustrative scenario, not a real incident.
A team must never touch production files from Claude Code. CLAUDE.md asks for that, but a PreToolUse hook enforces it, whatever Claude decides.
See it in different ways
flowchart LR
A["Untrusted web page"] --> B["Model"]
B --> C["Tool call request"]
C --> D{"PreToolUse hook"}
D -->|"Allowed"| E["Tool runs"]
D -->|"Denied"| F["Blocked in code"]sequenceDiagram participant P as Untrusted content participant C as Claude participant H as Hook in code participant T as Risky tool P->>C: Hidden instruction C->>H: Requests a risky action H--xT: Blocked by policy H-->>C: Denied, with a reason
flowchart TD
Q{"What happens if it is broken?"}
Q -->|"Minor"| A0["Guidance in CLAUDE.md"]
Q -->|"Must never happen"| A1["PreToolUse hook"]Key point: Hooks enforce, and CLAUDE.md guides.
Why the other options are wrong
- A. In a code comment
- A code comment is only text, and nothing runs it.
- B. In the chat history
- Chat history is context, and it is lost between sessions.
- D. In CLAUDE.md
- CLAUDE.md guides Claude, but it cannot enforce a rule.

