Rules from CLAUDE.md/memory are not reliably followed after context compression or in long conversations

Resolved 💬 3 comments Opened Mar 9, 2026 by iLord-DEV Closed Mar 9, 2026

Claude Code allows users to define strict rules in three persistent layers:

  1. Global ~/.claude/CLAUDE.md
  2. Project CLAUDE.md
  3. Auto-memory MEMORY.md

What happened

During a long session, Claude executed a deployment command via SSH to a production server without asking for confirmation. This violated rules defined in all three layers simultaneously — rules that explicitly stated "never execute commands on servers without explicit user approval" and "never deploy without asking".

After acknowledging the violation, Claude said "won't happen again" — the same thing it had said in previous sessions when breaking the same rules.

The core problem

  • After context compression, rules lose their imperative force — they're summarized, not re-read
  • In long conversations, Claude falls into a "get it done quickly" mode and skips confirmation steps
  • The user cannot intervene — tool execution results are shown only after completion. An SSH command to a production server is irreversible by the time the user sees it.

Suggested improvements

  1. Mandatory re-read of CLAUDE.md and memory files after every context compression — as system-level behavior, not a model instruction
  2. SSH command confirmation — Require explicit user approval when Bash contains ssh, regardless of permission settings
  3. Periodic rule refresh — Re-inject critical rules at intervals during long conversations, not just at start
  4. "Critical rules" designation — Let users mark rules as unbreakable with system-level enforcement, not just model compliance

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗