claude-code - 💡(How to fix) Fix Memory rules saved but never applied — Claude Code operates in wrong environment across sessions

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Root Cause

Root cause (as I understand it)

RAW_BUFFERClick to expand / collapse

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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING