[BUG] Auto-memory Edit/Write to ~/.claude/projects/*/memory is gated as a sensitive file in project-cwd sessions; "always allow" doesn't persist (2.1.215)

Status Open
Reported on v2.1.201
Maintainer reply ✓ Yes — bcherny
Activity 3 comments · opened Jul 19, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Environment

  • Claude Code v2.1.215 (also reproduced on 2.1.201), VS Code extension, Windows 11
  • Auto-memory enabled (default)

Summary

When Claude updates one of its own auto-memory files under ~/.claude/projects/<slug>/memory/ from a session whose working directory is a project (i.e. not $HOME), the Edit/Write is blocked by the "sensitive file" gate and prompts for approval every time. Choosing "always allow" does not persist across sessions. (This is the behavior behind the now-closed-and-locked #16762 / #43001.)

Why it matters

Auto-memory instructs the model to update an existing memory file rather than duplicate it. That update is an Edit (or overwrite Write) on a path under .claude/, which the harness classifies as sensitive. So routine, first-party memory maintenance raises a permission prompt on essentially every project-directory session, and the prompt cannot be silenced by configuration.

Reproduction

  1. Work in a session whose cwd is a project outside $HOME (e.g. C:\code-one\myrepo); let auto-memory accumulate a file under ~/.claude/projects/<sanitized-cwd>/memory/.
  2. Have Claude update that memory file (Edit, or overwrite Write).
  3. A prompt appears: "…is a sensitive file". "Always allow" does not persist — it re-prompts next session.

Diagnosis (headless probes on 2.1.201 and 2.1.215 + classifier inspection)

The sensitive-file classifier flags any path containing a .claude segment (only .claude/worktrees is exempt). The check sits above permission-rule resolution, so none of these clear it:

  • permissions.allow — bare "Edit"/"Write" or path-scoped Edit(**/.claude/projects/**) / Write(...)
  • permissions.additionalDirectories (including the memory dir itself)
  • the --allowedTools CLI flag (scoped or bare)
  • --permission-mode dontAsk (which auto-denies, so the write silently fails)

Control: editing a file that is out-of-workspace but not under .claude and is listed in additionalDirectories (e.g. under %TEMP%) succeeds. So the block is specifically the .claude location applied to Claude's own memory store — not a general out-of-workspace restriction.

Current workaround

Set autoMemoryDirectory to a path outside .claude. Note it must be per-project via .claude/settings.local.json, because a single user-level value is used literally (no per-cwd subdir), which would merge every project's memories into one directory.

Suggested fix

Treat the resolved auto-memory directory as non-sensitive for the memory subsystem's own Edit/Write (analogous to the existing .claude/worktrees exemption), or persist "always allow" for these paths so approval is a one-time cost.

View original on GitHub ↗

3 Comments

bcherny collaborator · 1 month ago

Confirmed — reproduced on 2.1.237 (Linux, headless), and this matches your diagnosis:

  • Editing a file under ~/.claude/projects/<slug>/memory/ from a project-cwd session is blocked with the "is a sensitive file" prompt — including the session's own auto-memory directory.
  • Path-scoped permissions.allow rules (e.g. Edit(**/.claude/projects/**)) and additionalDirectories do not clear it; the sensitive-file check intentionally runs before permission-rule resolution, and persisted "always allow" grants for .claude/ paths are deliberately not honored across sessions (only session-scoped grants are) — which is why the prompt comes back every session.
  • Control confirmed: an out-of-workspace edit under additionalDirectories but outside .claude/ succeeds.

We agree Claude's own auto-memory maintenance shouldn't trip this gate. A change is in the works to let auto-memory's own markdown files be updated without a prompt (analogous to the existing worktrees exemption) while keeping the rest of .claude/ protected; as of 2.1.237 it hasn't shipped yet. I'll leave this open until it lands in a release.

🤖 Generated with Claude Code

marcindulak · 26 days ago

For your information: the label reproduced on this issue does not prevent it from becoming stale and eventually auto-closed. See https://github.com/anthropics/claude-code/issues/87647 for details, and consider upvoting that for visibility.

gmantova · 11 days ago

Opposite symptom on 2.1.284 (Linux, default permission mode): Write and Edit on ~/.claude/projects/<project>/memory/ were applied without any prompt, even though bare Edit and Write are in permissions.ask in the user settings. So the memory directory now appears exempt from permission checks, and the exemption overrides explicit ask rules. Details in #96078.