Fetching latest headlines…
Tired of Claude Code Ignoring Your CLAUDE.md? I Built claudemd-guard
NORTH AMERICA
🇺🇸 United StatesApril 19, 2026

Tired of Claude Code Ignoring Your CLAUDE.md? I Built claudemd-guard

1 views0 likes0 comments
Originally published byDev.to

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:

  1. Collects CLAUDE.md from the project tree.
  2. Sends the collected rules and the intended operation to an AI validator.
  3. 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.

Comments (0)

Sign in to join the discussion

Be the first to comment!