How to make a Claude Code rule enforced instead of just requested

Reddit r/AI_Agents News

Summary

Explains the difference between merely requesting rules via CLAUDE.md and actually enforcing them in Claude Code, recommending permissions.deny rules and PreToolUse hooks for boundaries that must hold even when the model makes a bad choice.

If a rule is "never do X", putting it in CLAUDE.md isn't the same as enforcing it. Anthropic's Claude Code docs explicitly describe CLAUDE.md as context, not enforced configuration. That's an important distinction when the rule protects something you can't afford to change. Three different jobs: Guidance: CLAUDE.md Naming conventions, project structure, test commands. Instructions that help Claude choose what to do. Restrictions: permission rules The docs' managed-settings table puts blocking specific tools, commands or file paths under permissions.deny. It says settings rules are enforced by the client, rather than depending on Claude choosing to follow them. Checks before execution: PreToolUse hooks These run before a tool call and can block it. The docs include a protected-file example where a script exits with code 2 to block an edit and tells Claude why. A small test I'd add: in a disposable repo with no credentials or real data, protect a dummy file and ask Claude to edit it. Check whether execution is actually blocked, rather than whether Claude merely says it won't edit it. Passing that one test isn't proof that every route is covered. A check on an editing tool shouldn't be assumed to block changes through other tools too. Match the restriction to the paths you need to prevent. The takeaway: use prompt files to describe the workflow, and enforcement controls for boundaries that must hold even when the model makes a bad choice.
Original Article

Similar Articles

Claude Code auto mode: a safer way to skip permissions

Anthropic Engineering

Anthropic introduces 'auto mode' for Claude Code, a feature that uses model-based classifiers to automate permission approvals, aiming to reduce user fatigue while maintaining security against unsafe actions.