Skip to main content
Glama

claude-memory-bridge

Share the exact same live Claude Code memory files (~/.claude/projects/<slug>/memory/) with Antigravity CLI (agy) and Factory Droid (droid) — plus local nightly Auto-Dream consolidation.

No database, no embeddings, no copying, no sync drift. Claude Code stays untouched.

~/.claude/projects/<slug>/memory/
├── MEMORY.md            # Live index shared across harnesses (200 lines / 25 KB cap)
└── *.md                 # Native Claude Code YAML frontmatter (user / feedback / project / reference)
        ▲
        ├── Claude Code          (native Auto Memory)
        ├── claude-memory-mcp    (stdio MCP server: 6 tools, atomic writes + file lock)
        ├── claude-memory-hook   (SessionStart index + proactive memory discipline)
        └── claude-memory dream  (local Auto-Dream via `agy -p`, backups & restore)

What You Get

  • 100% live Claude Code format: identical slug encoding, git repo & linked worktree resolution (--git-common-dir), metadata.type frontmatter preservation (including originSessionId), and surgical MEMORY.md updates that keep your custom sections intact.

  • 6 dedicated MCP tools: memory_list, memory_read, memory_write, memory_search, memory_delete, and read-only memory_list_projects — with cross-process locking, atomic writes, secret redaction, and [[wikilink]] resolution.

  • Opt-in cross-project search: stays strictly inside the current project by default (scope: "current"). Only searches sibling/parent projects (scope: "nearby") or all projects (scope: "all") when asked, while skipping /tmp, scratch workspaces, and excluded paths.

  • Local Auto-Dream consolidation: brings Claude Code's 4-phase background memory cleanup to any setup (including third-party gateways without Anthropic OAuth) using headless agy -p, deterministic pre-scan, automatic pre-run backups, one-command restore, and strict single-project + read-only-repo isolation.


Related MCP server: memory-mcp

Install

Requires Node.js >= 20.

git clone https://github.com/alesha-pro/claude-memory-bridge.git
cd claude-memory-bridge
npm install
npm run build
npm test

Optional global CLI link (claude-memory, claude-memory-mcp, claude-memory-hook):

npm link

Connect Your Harnesses

Replace /ABS/PATH/TO/claude-memory-bridge with your clone path.

Antigravity CLI (agy)

  1. MCP server — ~/.gemini/config/mcp_config.json:

    {
      "mcpServers": {
        "claude-memory": {
          "command": "node",
          "args": ["/ABS/PATH/TO/claude-memory-bridge/dist/mcp.js"]
        }
      }
    }
  2. SessionStart hook — ~/.gemini/config/hooks.json (merge with any existing hook entries):

    {
      "claude-memory": {
        "SessionStart": [
          {
            "type": "command",
            "command": "node /ABS/PATH/TO/claude-memory-bridge/dist/hook.js --harness antigravity",
            "timeout": 10
          }
        ]
      }
    }
  3. Auto-allow memory tools — ~/.gemini/antigravity-cli/settings.json:

    {
      "permissions": {
        "allow": ["mcp(claude-memory/*)"]
      }
    }
  4. Verify: agy mcp list should show claude-memory enabled.

Factory Droid (droid)

  1. MCP server — ~/.factory/mcp.json:

    {
      "mcpServers": {
        "claude-memory": {
          "command": "node",
          "args": ["/ABS/PATH/TO/claude-memory-bridge/dist/mcp.js"]
        }
      }
    }
  2. SessionStart hook — ~/.factory/settings.json (add inside "hooks"."SessionStart"):

    {
      "hooks": [
        {
          "type": "command",
          "command": "node /ABS/PATH/TO/claude-memory-bridge/dist/hook.js --harness droid",
          "timeout": 10
        }
      ]
    }
  3. Verify: droid mcp list should show claude-memory connected with 6 tools.


MCP Tools

Tool

Scope

Purpose

memory_list

Current (or project_slug read-only)

List project memories and MEMORY.md size stats

memory_read

Current (or project_slug read-only)

Read full markdown body, metadata, and resolved [[wikilinks]]

memory_write

Current project only

Create/update .md atomically, redact secrets, update MEMORY.md

memory_delete

Current project only

Delete .md and remove its MEMORY.md entry

memory_search

current (default), nearby, all, or project_slug

Local Unicode-aware (EN/RU) ranked search with snippets

memory_list_projects

Read-only

List projects with non-empty memory (filters temp/excluded)


Auto-Dream (Nightly Consolidation)

Over dozens of sessions, MEMORY.md accumulates duplicates, expired notes, short dates (07.11), and broken [[wikilinks]]. claude-memory dream runs a conservative 4-phase consolidation cycle via headless agy -p (default model: gemini-4-hydrogen-high).

# Preview only (default — strictly read-only, zero file edits)
node dist/cli.js dream /path/to/project --dry-run --with-sessions

# Apply changes (creates an automatic backup first)
node dist/cli.js dream /path/to/project --apply --with-sessions

# Check or roll back backups at any time
node dist/cli.js backups /path/to/project
node dist/cli.js restore latest /path/to/project

How It Stays Safe

  • Pre-run backup: snapshots all .md files to ~/.local/state/claude-memory-bridge/backups/<slug>/<timestamp>/ before every --apply (keeps last 10 per project; restore also takes a pre-restore snapshot).

  • Read-only codebase: passes per-session --settings to agy denying write_file(*) and command(*). In --dry-run, memory_write and memory_delete are also denied.

  • Hard single-project lock: sets CLAUDE_MEMORY_LOCK_PROJECT_SLUG so the MCP server physically blocks cross-project reads/writes during a dream cycle.

  • Fast on 100+ file banks: runs a ~10 ms deterministic pre-scan (broken [[wikilinks]], unindexed/dangling entries, overlap clusters, short/relative dates) before invoking the model.

  • Smart scheduling gates (for --all):

    • --min-hours 24 — skips projects dreamed within the last 24h;

    • --min-sessions 3 — requires ≥ 3 new .jsonl sessions or at least 1 modified .md memory file since the last dream;

    • --active-within-days 14 — ignores dormant/archived projects;

    • --max-projects 3 — caps runs per night (most recently active first);

    • --with-sessions — optionally extracts a compact (≤16 KB) digest of recent user messages from .jsonl logs to catch missed corrections/decisions.

Schedule Nightly Runs

macOS (launchd) — copy and edit examples/launchd-nightly-dream.plist:

mkdir -p ~/.local/state/claude-memory-bridge
cp examples/launchd-nightly-dream.plist ~/Library/LaunchAgents/com.local.claude-memory-dream.plist
# Edit YOUR_USER and /ABSOLUTE/PATH/TO/claude-memory-bridge, then load:
plutil -lint ~/Library/LaunchAgents/com.local.claude-memory-dream.plist
launchctl bootstrap "gui/$(id -u)" ~/Library/LaunchAgents/com.local.claude-memory-dream.plist

Logs live in ~/.local/state/claude-memory-bridge/ (dream.log, dream-state.json, launchd.out.log, launchd.err.log).

Linux (cron) — daily at 04:00:

0 4 * * * /usr/bin/node /ABS/PATH/TO/claude-memory-bridge/dist/cli.js dream --all --apply --with-sessions --min-hours 24 --min-sessions 3 --active-within-days 14 --max-projects 3 --model gemini-4-hydrogen-high >> ~/.local/state/claude-memory-bridge/cron.log 2>&1

Optional /memory-dream Skill

Copy examples/memory-dream/SKILL.md to trigger consolidation on demand from Claude Code, Factory Droid, or Antigravity CLI:

mkdir -p ~/.agents/skills/memory-dream
cp examples/memory-dream/SKILL.md ~/.agents/skills/memory-dream/SKILL.md
# For Antigravity CLI global skills:
mkdir -p ~/.gemini/config/skills
ln -sfn ~/.agents/skills/memory-dream ~/.gemini/config/skills/memory-dream

Optional Config & CLI Reference

Create ~/.config/claude-memory-bridge/config.json to isolate benchmark/private directories or link related projects for scope: "nearby":

{
  "exclude": ["models-benchmarks"],
  "groups": [
    ["~/dev/backend", "~/dev/frontend"]
  ]
}
  • exclude: projects matching these patterns are hidden from memory_list_projects, skipped by Auto-Dream, and isolated from cross-project search when running inside them.

  • groups: paths or slugs treated as nearby siblings across directory trees.

CLI commands:

node dist/cli.js status [path]
node dist/cli.js projects [--filter <text>] [--include-temp]
node dist/cli.js list [path] [--project-slug <slug>]
node dist/cli.js search "<query>" [path] [--scope current|nearby|all] [--project-slug <slug>]
node dist/cli.js dream [path] [--dry-run|--apply] [--with-sessions] [--model <id>] [--force] [--all]
node dist/cli.js backups [path]
node dist/cli.js restore <backup-id|latest> [path]
node dist/cli.js test-hook --harness <antigravity|droid> [path]

Environment variables: CLAUDE_PROJECTS_DIR, CLAUDE_MEMORY_DEFAULT_CWD, CLAUDE_MEMORY_CONFIG, CLAUDE_MEMORY_STATE_DIR, CLAUDE_MEMORY_EXCLUDE, CLAUDE_MEMORY_LOCK_PROJECT_SLUG.

License

MIT — see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that reads all your Claude Code project memory files and exposes them as tools. Lets any Claude instance — in any project, or via Claude.ai — query your full project history and preferences.
      5
      50 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      F
      maintenance
      A local stdio MCP server that exposes a shared brain (read/search/write) over ~/.claude/memory, allowing memories written in any agent to be readable and searchable across all three (Claude Code, Cursor, Codex). It provides tools like memory_search, memory_read, memory_write, etc., with no external services.
      14 npm
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      A local shared-memory MCP server for Claude, Codex, Hermes, and other MCP-aware agents, providing a durable memory layer with Markdown files and SQLite fact store.
      6
      MIT