Skip to content

fix(claude-bridge): never overwrite a MEMORY.md the bridge did not write - #1505

Open
Rex57 wants to merge 1 commit into
rohitg00:mainfrom
Rex57:fix/1490-bridge-keep-handwritten-memory-md
Open

Rex57 wants to merge 1 commit into
rohitg00:mainfrom
Rex57:fix/1490-bridge-keep-handwritten-memory-md

Conversation

@Rex57

@Rex57 Rex57 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1490.

With CLAUDE_MEMORY_BRIDGE=true, mem::claude-bridge-sync (also the default direction of the memory_claude_bridge_sync MCP tool) writes ~/.claude/projects/<slug>/memory/MEMORY.md, which is Claude Code's own project memory index, often curated by hand. It replaced that file in full with writeFileSync, with no check and no backup.

Sync now writes only when the file:

  • does not exist,
  • is empty or whitespace, or
  • starts with the bridge's own header, # Agent Memory (auto-synced by agentmemory).

For any other file it writes nothing, logs a warning, and returns:

{ "success": false, "error": "<path> holds content agentmemory did not write, so the bridge will not overwrite it. Move that content elsewhere first if agentmemory should own this file." }

The read direction is unchanged. The header is now one constant shared by the serializer and the check.

Checks

  • test/claude-bridge.test.ts: rewrites its own file; creates a missing file; leaves a hand-written file untouched with the error; replaces an empty file. The existing sync test now states that the old file came from the bridge.
  • npm run build, npm run skills:gen, npm run docs:sync (no changes), npm run skills:check
  • npm test: 2597 passed, 4 skipped

mem::claude-bridge-sync writes Claude Code's project MEMORY.md, the index a
user or Claude Code curates by hand, and replaced it in full with no check
and no backup. Sync now writes only when the file is missing, empty, or
starts with the bridge's own auto-sync header; otherwise it leaves the file
untouched, logs a warning and returns success: false with the reason.

Signed-off-by: Rex57 <203883624+Rex57@users.noreply.github.com>
@vercel

vercel Bot commented Oct 8, 2026

Copy link
Copy Markdown

@Rex57 is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3d06246d-3ba5-4cd9-a298-2cbb1f60e5ba
📥 Commits

Reviewing files that changed from the base of the PR and between 007a1a7 and 3c05aa2.

📒 Files selected for processing (2)
  • src/functions/claude-bridge.ts
  • test/claude-bridge.test.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude bridge sync overwrites a hand-written MEMORY.md

1 participant