Problem
~/.claude/projects/<project>/memory/ should hold only MEMORY.md per CLAUDE.md. Everything else belongs in brain/ topic notes.
Agents drift here — the vocabulary ("this is a memory, goes in the memory dir") fights the convention. Misplaced files aren't versioned, fork the source of truth, and silently desync from the brain/ index.
Fix
PostToolUse hook on Write|Edit. Detects writes to ~/.claude/projects/<x>/memory/<file>.md where basename != MEMORY.md. Emits a warning at write time with migration pointer to the right brain/ note.
PostToolUse can't block; visibility is the lever.
Shape
.claude/scripts/validate-memory-location.ts, ~70 lines, matches the existing validate-write.ts pattern.
- Reads stdin JSON, checks
tool_input.file_path
- POSIX + Windows path separators
- Allows
MEMORY.md
hookSpecificOutput.additionalContext lists target brain/ notes (Patterns / Gotchas / Key Decisions / Memories / new topic)
- Silent on:
- Vault paths
- Paths with 'memory' substring elsewhere (e.g.
brain/Memories.md)
- Other
.claude/projects/<x>/ subdirs (transcripts, hook-output)
- Bad input (null stdin, missing tool_input, non-string file_path)
- Subprocess integration tests in
tests/validate-memory-location.test.ts
Wires into existing PostToolUse Write|Edit block alongside validate-write and qmd-refresh.
Problem
~/.claude/projects/<project>/memory/should hold onlyMEMORY.mdper CLAUDE.md. Everything else belongs inbrain/topic notes.Agents drift here — the vocabulary ("this is a memory, goes in the memory dir") fights the convention. Misplaced files aren't versioned, fork the source of truth, and silently desync from the brain/ index.
Fix
PostToolUse hook on
Write|Edit. Detects writes to~/.claude/projects/<x>/memory/<file>.mdwherebasename != MEMORY.md. Emits a warning at write time with migration pointer to the right brain/ note.PostToolUse can't block; visibility is the lever.
Shape
.claude/scripts/validate-memory-location.ts, ~70 lines, matches the existingvalidate-write.tspattern.tool_input.file_pathMEMORY.mdhookSpecificOutput.additionalContextlists target brain/ notes (Patterns / Gotchas / Key Decisions / Memories / new topic)brain/Memories.md).claude/projects/<x>/subdirs (transcripts, hook-output)tests/validate-memory-location.test.tsWires into existing PostToolUse
Write|Editblock alongsidevalidate-writeandqmd-refresh.