Most CLAUDE.md Security Rules Have No Control Enforcing Them
A study of 481 public CLAUDE.md files finds that only about 4 to 16 percent of the security rules developers write there match a control Claude Code enforces. The rest are left to the model.
TL;DR
- In 481 public CLAUDE.md files, only about 4 to 16 percent of security rules a study extracted have a matching built-in control in Claude Code [^1].
- The other rules, such as "never put customer secrets in logs", depend on the model interpreting them, and nothing tells developers which kind they wrote [^1].
Background
CLAUDE.md is a plain-text instruction file that Claude Code loads into its context. Developers use it to describe how the agent should work, including security rules. Claude Code also enforces controls itself, such as permission rules that deny a command or ask before it runs. Its documentation draws the line: permission rules "are enforced by Claude Code, not by the model", while instructions in CLAUDE.md "shape what Claude tries to do, but they don't change what Claude Code allows" [^2].
What happened
Ting Yan's paper "When 'Do Not' Is Not Deny" measures how often the two line up [^1]. The study collected 481 public GitHub repositories with a CLAUDE.md file, split the files into lines or sentences and kept 4,661 segments with rule words such as "must", "never" or "do not" [^1]. An LLM classifier marked 870 of them as security-related and checked each against Claude Code's documented controls. Two security practitioners independently labeled a sample of 180 segments without seeing the model's answers [^1].
The classifier found a matching control for 16.6 percent of the security rules. Under the strict, adjudicated human standard that the paper treats as its main result, the figure was 4.4 percent, leaving 95.6 percent without one [^1]. The classifier's typical mistake was to count a match whenever a rule named a command, path or domain that a permission rule could target, even if the rule had a condition the pattern can't express, such as "run npm publish only when cutting a release" [^1]. In the classifier's breakdown, which the paper calls exploratory, rules about destructive commands matched a control most often, at 31.5 percent, and rules about authorization or personal data least often, at under 7 percent [^1].
Why it matters
A rule like "never run npm publish" can be backed by a deny rule that Claude Code checks before the command runs, while "never put customer secrets in logs" needs the model to decide what counts as a secret and what counts as a log [^1]. Both look the same in the file. The paper calls CLAUDE.md a "write-only" channel: a developer writes a security rule and gets no feedback on whether anything will enforce it [^1]. Because more and more of the people writing these files have little security background, the paper argues the gap hurts most those least likely to notice it [^1].
The study has limits. It only looks at what is written in CLAUDE.md, and teams may enforce rules through CI, hooks or other tooling, so a rule without a matching control is not necessarily unprotected [^1]. Its extraction method caught about two-thirds of the security rules in a file, and the corpus leans toward new, little-known projects: 58 percent of the repositories have no stars [^1]. As a fix, the paper suggests that agent platforms show beside each rule whether a control backs it, mark rules they can't enforce as advisory and log when a rule would have applied [^1].
Practical example
Say your CLAUDE.md says "never run npm publish" and "never commit secrets". Claude Code's documentation says instructions like these only shape what Claude tries to do; to block an action, you need a permission rule, a permission mode or a PreToolUse hook [^2]. The first rule maps onto a deny permission rule for the command [^1]. The second is about what a commit contains, which no permission pattern inspects, so it stays text for the model to interpret unless you add a hook, script or other check [^1].
Related gear
We recommend this book because it details the core security engineering principles required to establish resilient system boundaries rather than relying on soft runtime assumptions.