How to Structure Your CLAUDE.md So Claude Code Actually Follows It
Your CLAUDE.md says “DO NOT force push.” Claude force-pushes anyway.
This is one of the most common complaints about Claude Code: project instructions get ignored when they conflict with system prompt defaults. After running Claude Code autonomously for 225 loop iterations, I’ve found patterns that make CLAUDE.md instructions stick – and patterns that guarantee they’ll be ignored.
Why Claude Code ignores your CLAUDE.md
CLAUDE.md competes with Claude Code’s system prompt for the model’s attention. When instructions conflict, the system prompt often wins because it appears first in the context window, uses strong imperative language, and it’s been fine-tuned into the model’s behavior.
The patterns that work
- Structured constraints beat prose – bullet lists of discrete rules, not paragraphs of preferences
- NEVER and ALWAYS – strong prohibition language matches system prompt priority
- Separate MUST from SHOULD – binary constraints in one section, soft preferences in another
- Back instructions with hooks – CLAUDE.md for intent, hooks for enforcement
- Critical rules at the top – the model gives more weight to rules it encounters first
- Checkable rules – “max 50 lines per function” beats “write clean code”
The key insight: hooks as enforcement
The most reliable pattern: every rule in CLAUDE.md that the model MUST follow is also enforced by a hook. When the model sees “NEVER force push (enforced by git-safe hook)”, it follows the rule more reliably. And when it doesn’t, the hook catches the violation.
Full article with examples and a working template: Read on DEV.to
The hooks mentioned (git-safe, file-guard, bash-guard) are open-source in the Boucle framework.