Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

memory-sync

The missing feedback loop between claude-memory-extractor and Claude Code's built-in MEMORY.md.

~/.claude/memories/extracted/*.md  -->  memory-sync  -->  MEMORY.md
     (obra's output)                                  (Claude Code's input)

The Problem

Claude Code writes MEMORY.md during sessions — what it notices is important. But it has blind spots. You can have a session where it carefully notes one bug fix but completely misses a bigger mistake in the same conversation.

obra's memory extractor runs post-session over transcripts and catches what the agent missed: recurring patterns, implicit preferences, debugging strategies that worked. It scores each insight by confidence.

But these systems are disconnected. Extracted insights sit in ~/.claude/memories/extracted/ and never feed back into MEMORY.md for the next session.

memory-sync closes that loop.

Install

# No dependencies. Just Python 3.12+.
git clone https://github.com/anupamchugh/memory-sync.git
cd memory-sync

Usage

# See what you've got
python memory_sync.py --stats

# Preview what would sync (dry run)
python memory_sync.py --dry-run

# Sync high-confidence memories to all project MEMORY.md files
python memory_sync.py

# Sync to a specific project
python memory_sync.py --memory-md ~/.claude/projects/-Users-me-myproject/memory/MEMORY.md

# Only recent memories, higher threshold
python memory_sync.py --since 2026-02-01 --min-confidence 4.0

# List all your project memory locations
python memory_sync.py --list-projects

How It Works

  1. Reads all extracted memories from ~/.claude/memories/extracted/
  2. Filters by confidence score (default: >= 3.5)
  3. Deduplicates against existing MEMORY.md content
  4. Appends high-quality insights, respecting the 200-line limit
  5. Sorts by confidence (best insights first)

The confidence threshold is the curation layer. Not "remember everything" or "remember nothing" — remember what a second pass confirmed was worth remembering.

Options

Flag Default Description
--min-confidence 3.5 Minimum confidence to sync (0-5)
--since None Only sync after this date
--max-lines 190 MEMORY.md line limit (200 truncates)
--dry-run false Preview without writing
--stats false Show memory statistics
--list-projects false List all MEMORY.md locations

As a Claude Code Hook

Add to .claude/hooks/post_session.sh:

#!/bin/bash
python ~/Desktop/workspace/memory-sync/memory_sync.py --min-confidence 4.0

Or as a cron job:

# Sync daily at midnight
0 0 * * * python ~/Desktop/workspace/memory-sync/memory_sync.py --min-confidence 3.5

Why This Exists

In-session memory and post-session extraction have orthogonal failure modes:

System Writes When Blind Spot
MEMORY.md Agent notices something Agent's own mistakes
Extractor Transcript review Nothing — reads everything

The gap was: extraction results never became next-session memory. This tool is the bridge.

Credits

About

Close the loop between obra's claude-memory-extractor and Claude Code's MEMORY.md

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages