[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)
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
- 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/. - Have Claude update that memory file (
Edit, or overwriteWrite). - 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-scopedEdit(**/.claude/projects/**)/Write(...)permissions.additionalDirectories(including the memory dir itself)- the
--allowedToolsCLI 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.
3 Comments
Confirmed — reproduced on 2.1.237 (Linux, headless), and this matches your diagnosis:
~/.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.permissions.allowrules (e.g.Edit(**/.claude/projects/**)) andadditionalDirectoriesdo 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.additionalDirectoriesbut 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
For your information: the label
reproducedon 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.Opposite symptom on 2.1.284 (Linux,
defaultpermission mode):WriteandEditon~/.claude/projects/<project>/memory/were applied without any prompt, even though bareEditandWriteare inpermissions.askin the user settings. So the memory directory now appears exempt from permission checks, and the exemption overrides explicitaskrules. Details in #96078.