Have you ever experienced a situation with Claude Code where the rules you defined in CLAUDE.md are followed initially, but start to be ignored toward the end of a long session?
I was particularly struggling with projects that had many strict rules in CLAUDE.md. With 10 to 20 clauses like "do not touch this directory" or "use only these specific APIs," having to roll back and review every time Claude violated a rule was truly exhausting.
The cause is context compression. As the conversation grows longer, CLAUDE.md gets pushed out of the context window, leaving the rules simply invisible to the model. I wanted to stop Claude the moment it attempts a violation, rather than noticing it later and rolling back. For my use case, it is better to have enforcement, even if it is a bit strict. With that in mind, I created claudemd-guard and published it to npm.
How it works
It operates as a PreToolUse hook for Claude Code and performs the following before executing tools like Edit, Write, or Bash:
- Collects CLAUDE.md from the project tree.
- Sends the collected rules and the intended operation to an AI validator.
- Blocks the operation if there is a clear violation, and lets it pass if not.
It runs via your local Claude CLI by default, so no additional API keys are required. It follows a fail-open design, meaning that if an error occurs during validation, the operation is allowed to proceed. I determined that having work stopped because the guard itself broke is a poor failure mode for a convenience tool.
Installation
npm install -g claudemd-guard
claudemd-guard install
Restart Claude Code to enable it. You can uninstall it with a single command: claudemd-guard uninstall.
I hope this reaches those who want to ensure CLAUDE.md is followed and are tired of rolling back violations.
United States
NORTH AMERICA
Related News
How Braze’s CTO is rethinking engineering for the agentic area
11h ago
Amazon Employees Are 'Tokenmaxxing' Due To Pressure To Use AI Tools
22h ago
KDE Receives $1.4 Million Investment From Sovereign Tech Fund
2h ago
Instagram’s new ‘Instants’ feature combines elements from Snapchat and BeReal
2h ago
Six Claude Code Skills That Close the AI Agent Feedback Loop
2h ago