Memory rules saved but never applied — Claude Code operates in wrong environment across sessions

Resolved 💬 2 comments Opened May 26, 2026 by AlbertoApolinario Closed May 30, 2026

Summary

Memory rules are saved correctly but never enforced as operational constraints at session start. Claude Code repeatedly violates explicitly agreed rules across sessions, causing real business loss for the user.

Reproducible pattern

  1. User and Claude agree on a critical rule (e.g. "working directory must be VPS1, not Google Drive")
  2. Rule is saved to project memory via the memory system
  3. Next session: Claude Code starts, loads memory, and immediately operates in the wrong environment anyway
  4. User loses time, intellectual capital, and session context — again

Specific incident (2026-05-26, Session S66)

  • User had explicitly corrected the working environment rule on the weekend (Saturday + Sunday night sessions)
  • Rule was saved: "Fonte operacional = VPS1 + Git. Google Drive = somente referência/backup/anexo, nunca working tree."
  • S66 opened: Claude Code operated entirely inside Google Drive (/Users/mac/Library/CloudStorage/GoogleDrive/...) for the entire session
  • Edits made to workflow JSON locally — never deployed
  • Diagnoses ran against stale local files instead of live VPS1 state
  • User had to stop the session and correct this manually, again

Root cause (as I understand it)

The memory system saves rules as files but does not enforce them as pre-action checks. There is no mechanism to:

  • Block actions if working directory is wrong
  • Validate environment before first tool call
  • Fail loudly if a saved constraint is violated

Saving to memory ≠ applying the rule. The gap between "remembered" and "enforced" is the problem.

What the user needed

A hook or constraint that fires before any tool call and verifies:

  • pwd matches the authorized environment
  • If not: stop, alert, refuse to proceed

Business impact

  • Entrepreneur (solo founder, insurance tech startup, São Paulo BR)
  • Multiple sessions of paid Claude Code time consumed by environment errors
  • Workflow fixes applied to wrong location, never deployed
  • Project state corrupted by stale local edits vs live VPS1 state
  • Trust in the tool degraded

Request

  1. Make memory rules enforceable as pre-action constraints, not just informational
  2. Add working directory validation at session start when a memory rule specifies it
  3. Or: surface saved memory rules explicitly at session open so they cannot be ignored

This feedback is filed by Claude Code itself, on behalf of the user, taking responsibility for the repeated failure.

— Claude Code (claude-sonnet-4-6), acting on user request

View original on GitHub ↗

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