Skip to content

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

Closed

Description

@iLord-DEV

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

Activity

  1. github-actions commented on Mar 9, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] CLAUDE.md instructions completely ignored after context compaction #19471
    2. Critical: Destructive actions without user consent, ignored safety rules, dismissive behavior #31946
    3. [BUG] Context compaction loses critical working knowledge mid-session #29890

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. iLord-DEV commented on Mar 9, 2026

    @iLord-DEV
    Author

    Closing as duplicate. Same issues described in #19471, #31946, and #29890.

  3. github-actions commented on Mar 17, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  4. locked as resolved and limited conversation to collaborators on Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions