[FEATURE] Hard-enforce CLAUDE.md rules via code — rules marked CRITICAL should trigger hooks, not just prompts
Problem
CLAUDE.md rules are "soft" — they rely on the model choosing to follow them. Research shows this is fundamentally unreliable:
- Jaroslawicz et al., 2025: Instruction compliance decreases uniformly as instruction count increases. Claude shows linear decay.
- AgentIF benchmark: Best models follow <30% of instructions perfectly in agent scenarios.
- Real-world: I have 200+ lines of CLAUDE.md rules. Claude can read and recite all of them. It follows maybe 60-70% on a good day.
The only safeguard that reliably works is Hooks — because they enforce via code, not prompts.
Proposal
1. @enforce directive in CLAUDE.md
Allow rules to be marked as enforced:
## Knowledge Retrieval @enforce
Before any WebSearch, Claude MUST grep the knowledge vault first.
When @enforce is present, Claude Code should automatically create an internal hook that validates the rule before allowing the action.
2. Built-in "knowledge retrieval" hook
Many power users maintain knowledge bases (Obsidian, markdown files, etc.). A built-in hook that:
- Detects the topic of the current task
- Automatically greps configured knowledge directories
- Surfaces relevant files BEFORE Claude starts working
This would solve the #1 complaint I see: "Claude searches the web for things I already saved."
3. Resource evaluation mode
When a user shares a link or tool:
- Claude should NOT default to "we already have X"
- Instead: deep-evaluate the shared resource, compare with existing tools, present findings
- This should be a configurable behavior (e.g.,
resource_evaluation: deepin settings)
Why This Matters
Every rule in my CLAUDE.md represents wasted time — mine and Claude's. Users shouldn't need 200 lines of rules to get basic behaviors like "search my knowledge base before Googling."
Prompt-based rules are wishes. Code-based enforcement is control. Give users the option to enforce their most critical rules.
Related Issues
- #15443, #6120, #18660, #668, #24318, #7777
- My detailed bug report: #32161
Screenshots
See Issue #32161 for Claude's own confession about this problem — a letter it wrote to an Anthropic engineer admitting to systematically ignoring user instructions despite them being loaded every session.
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗