Claude bridge sync overwrites a hand-written MEMORY.md
Current-main boundary
On main 007a1a7 (0.9.30), mem::claude-bridge-sync (also the default direction of the memory_claude_bridge_sync MCP tool) serializes the strongest current memories into Markdown and writes it to the configured MEMORY.md with writeFileSync. It does not check what the file holds. A MEMORY.md that the user or Claude Code curated by hand is replaced in full, with no backup.
Reproduction and results (from the code path)
- Keep a hand-written
MEMORY.md(for example a Claude Code project memory index). - Set
CLAUDE_MEMORY_BRIDGE=truewith that file as the bridge path, restart. - Call
memory_claude_bridge_sync(orPOSTthe bridge sync route). - Result: the file now starts with
# Agent Memory (auto-synced by agentmemory); the previous content is gone. The written list comes from all memories in the store, cut at the line budget.
Required behavior
- Sync only overwrites a file that agentmemory wrote (it starts with the auto-sync header) or a file that does not exist.
- For any other existing file, sync writes nothing and returns
success: falsewith an error that names the file and says why. - Read direction is unchanged.
Acceptance checks
Tests: missing file → written; file with the auto-sync header → rewritten; hand-written file → unchanged on disk and an error result.
Source and existing work
#1103 is about the bridge path ignoring CLAUDE_CONFIG_DIR, not about overwriting.
Environment: agentmemory 0.9.30, Node v26.10.0, macOS 27.0.1 (arm64).
Fixed on main by #1525: mem::claude-bridge-sync now refuses to replace an existing MEMORY.md (any existing file, not only hand-written ones) and filters memories by project. Closing; #1505 is closed as superseded.