Skip to main content
The export and import scripts let you move memory data between Claude Mem installations with automatic duplicate prevention. Use them to share knowledge with teammates, back up specific memory sets, or import community-contributed observations.

Use cases

Share knowledge with teammates

Export bug fix patterns, architectural decisions, or platform-specific learnings and share the JSON file with your team.

Back up memory sets

Export observations about a specific project or topic before migrating machines or resetting your database.

Import community exports

Import observations contributed by others — Windows compatibility fixes, deployment patterns, and more.

Cross-machine sync

Export observations from one machine and import them on another to continue where you left off.

Data directory

All Claude Mem data lives in ~/.claude-mem/:
~/.claude-mem/
├── claude-mem.db           # SQLite database (observations, sessions, prompts)
├── chroma/                 # Vector embeddings for semantic search
├── .install-version        # Cached version for smart installer
├── worker.port             # Current worker port file
└── logs/
    ├── worker-out.log
    └── worker-error.log
The export scripts read from this database directly.
Export files contain memory data in plain text. Review exports before sharing to ensure no sensitive information — API keys, passwords, internal hostnames — is included.

Exporting memories

The export script searches the database using hybrid search (ChromaDB vector embeddings combined with SQLite FTS5 full-text search) and exports all matching observations, sessions, summaries, and prompts to a portable JSON file.
# Export all Windows-related memories
npx tsx scripts/export-memories.ts "windows" windows-memories.json

# Export bug fix patterns
npx tsx scripts/export-memories.ts "bugfix" bugfixes.json

# Export work on a specific feature
npx tsx scripts/export-memories.ts "progressive disclosure" pd-patterns.json
Parameters:
  1. <query> — search query (uses hybrid semantic + full-text search)
  2. <output-file> — output JSON file path
  3. --project=name — optional: filter to a specific project
Example output:
🔍 Searching for: "windows"
✅ Found 54 observations
✅ Found 12 sessions
✅ Found 12 summaries
✅ Found 7 prompts

📦 Export complete!
📄 Output: windows-memories.json
📊 Stats:
   • 54 observations
   • 12 sessions
   • 12 summaries
   • 7 prompts

Importing memories

The import script reads an export file and inserts records with automatic duplicate prevention. It checks whether each record already exists before inserting, skips duplicates silently, and imports everything inside a single transaction.
npx tsx scripts/import-memories.ts windows-memories.json
Parameters:
  1. <input-file> — path to an export JSON file
Example output:
📦 Import file: windows-memories.json
📅 Exported: 2025-12-10T23:45:00.000Z
🔍 Query: "windows"
📊 Contains:
   • 54 observations
   • 12 sessions
   • 12 summaries
   • 7 prompts

🔄 Importing sessions...
   ✅ Imported: 12, Skipped: 0
🔄 Importing summaries...
   ✅ Imported: 12, Skipped: 0
🔄 Importing observations...
   ✅ Imported: 54, Skipped: 0
🔄 Importing prompts...
   ✅ Imported: 7, Skipped: 0

✅ Import complete!

Re-importing the same file

Running the import script twice on the same file is safe — duplicates are skipped automatically:
🔄 Importing sessions...
   ✅ Imported: 0, Skipped: 12  ← all already exist
🔄 Importing summaries...
   ✅ Imported: 0, Skipped: 12
🔄 Importing observations...
   ✅ Imported: 0, Skipped: 54
🔄 Importing prompts...
   ✅ Imported: 0, Skipped: 7

Duplicate detection strategy

Record typeUniqueness key
Sessionsclaude_session_id
Summariessdk_session_id
Observationssdk_session_id + title + created_at_epoch
Promptsclaude_session_id + prompt_number

Export file format

{
  "exportedAt": "2025-12-10T23:45:00.000Z",
  "exportedAtEpoch": 1733876700000,
  "query": "windows",
  "totalObservations": 54,
  "totalSessions": 12,
  "totalSummaries": 12,
  "totalPrompts": 7,
  "observations": [],
  "sessions": [],
  "summaries": [],
  "prompts": []
}

Safety features

Duplicate prevention

Won’t re-import records that already exist in the database.

Transactional imports

All-or-nothing: if the import fails mid-way, the database is rolled back to its previous state.

Read-only export

The export script opens the database in read-only mode and never modifies data.

Dependency ordering

Sessions are imported before observations and summaries to maintain referential integrity.

Advanced usage

Export by project

# Export only memories from a specific project
npx tsx scripts/export-memories.ts "bugfix" bugfixes.json --project=claude-mem

# Export all memories for a project (empty query)
npx tsx scripts/export-memories.ts "" all-project.json --project=my-app

Export by observation type

# Export only discoveries
npx tsx scripts/export-memories.ts "type:discovery" discoveries.json

# Export only bug fixes
npx tsx scripts/export-memories.ts "type:bugfix" bugfix-patterns.json

Filter by date after export

Use jq to filter an export file by date before importing:
npx tsx scripts/export-memories.ts "" all-memories.json
cat all-memories.json | jq '.observations |= map(select(.created_at_epoch > 1700000000000))' > recent.json
npx tsx scripts/import-memories.ts recent.json

Combine multiple exports

npx tsx scripts/export-memories.ts "windows" windows.json
npx tsx scripts/export-memories.ts "linux" linux.json

npx tsx scripts/import-memories.ts windows.json
npx tsx scripts/import-memories.ts linux.json

Sharing with others

As an export author:
  1. Export your memories:
    npx tsx scripts/export-memories.ts "windows compatibility" windows-fixes.json
    
  2. Share the JSON file via GitHub Gist, your project repository, or direct transfer.
  3. Document what the export contains — what query was used and who might benefit.
As an import user:
  1. Download the export file.
  2. Optionally inspect it:
    cat windows-memories.json | jq '.totalObservations, .totalSessions'
    
  3. Import into your database:
    npx tsx scripts/import-memories.ts windows-memories.json
    
  4. Verify with a search:
    curl "http://localhost:37777/api/search?query=windows&format=index&limit=10"
    

Example exports

These commands export useful memory sets that can be shared with others:
# Windows compatibility knowledge
npx tsx scripts/export-memories.ts "windows compatibility installation" windows-fixes.json

# Progressive disclosure architecture patterns
npx tsx scripts/export-memories.ts "progressive disclosure architecture token" pd-patterns.json

# Bug fix patterns
npx tsx scripts/export-memories.ts "bugfix error handling" bugfix-patterns.json

# Performance optimization notes
npx tsx scripts/export-memories.ts "performance optimization caching" perf-tips.json

Troubleshooting

❌ Database not found at: /Users/you/.claude-mem/claude-mem.db
Make sure Claude Mem is installed and has recorded at least one session. The database is created on first use.
❌ Input file not found: windows-memories.json
Check the file path. Use an absolute path if the file is not in the current directory.
If the import fails part-way through, the transaction is rolled back and your database remains unchanged. Fix the issue (disk space, file corruption, etc.) and run the import again.

Folder context files

Auto-generated CLAUDE.md files for directory-level context

Search tools

Query your memory database with MCP tools

Build docs developers (and LLMs) love