Skip to main content

Memory Export/Import Scripts

Share your claude-mem knowledge with other users! These scripts allow you to export specific memories (observations, sessions, summaries, and prompts) and import them into another claude-mem installation.

Use Cases

  • Share Windows compatibility knowledge with Windows users
  • Share bug fix patterns with contributors
  • Share project-specific learnings across teams
  • Backup specific memory sets for safekeeping

How It Works

Export Script

Searches the database using hybrid search (combines ChromaDB vector embeddings with FTS5 full-text search) and exports all matching:
  • Observations - Individual learnings and discoveries
  • Sessions - Session metadata
  • Summaries - Session summaries
  • Prompts - User prompts that led to the work
Output is a portable JSON file that can be shared.
Privacy Note: Export files contain all matching memory data in plain text. Review exports before sharing to ensure no sensitive information (API keys, passwords, private paths) is included.

Import Script

Imports memories with duplicate prevention:
  • Checks if each record already exists before inserting
  • Skips duplicates automatically
  • Maintains data integrity with transactional imports
  • Reports what was imported vs. skipped
Duplicate Detection Strategy:
  • Sessions: By claude_session_id (unique)
  • Summaries: By sdk_session_id (unique)
  • Observations: By sdk_session_id + title + created_at_epoch (composite)
  • Prompts: By claude_session_id + prompt_number (composite)

Usage

Export Memories

Parameters:
  1. <query> - Search query (uses hybrid semantic + full-text search)
  2. <output-file> - Output JSON file path
  3. --project=name - Optional: filter results to a specific project
Example Output:

Import Memories

Parameters:
  1. <input-file> - Input JSON file (from export script)
Example Output:

Re-importing (Duplicate Prevention)

If you run the import again on the same file, duplicates are automatically skipped:

Sharing Memories

For Export Authors

  1. Export your memories:
  2. Share the JSON file via:
    • GitHub gist
    • Project repository (shared-memories/)
    • Direct file transfer
    • Package in releases
  3. Document what’s included:
    • What query was used
    • What knowledge is contained
    • Who might benefit from it

For Import Users

  1. Download the export file to your local machine
  2. Review what’s in it (optional):
  3. Import into your database:
  4. Verify import by searching:

JSON Export Format

Safety Features

Duplicate Prevention - Won’t re-import existing records ✅ Transactional - All-or-nothing imports (database stays consistent) ✅ Read-only Export - Export script opens database in read-only mode ✅ Dependency Ordering - Sessions imported before observations/summaries ✅ Validation - Checks database exists before starting

Advanced Usage

Export by Project

Export by Type

Export by Date Range

You can filter the export after exporting:

Combine Multiple Exports

Troubleshooting

Database Not Found

Solution: Make sure claude-mem is installed and has been run at least once.

Import File Not Found

Solution: Check the file path. Use absolute paths if needed.

Partial Import

If import fails mid-way, the transaction is rolled back - your database remains unchanged. Fix the issue and try again.

Contributing Memory Sets

If you’ve exported valuable knowledge that others might benefit from:
  1. Create a PR to the shared-memories/ directory
  2. Include a README describing what’s in the export
  3. Tag with relevant keywords (windows, linux, bugfix, etc.)
  4. Community members can then import your knowledge!

Examples of Useful Exports

Windows Compatibility Knowledge:
Progressive Disclosure Architecture:
Bug Fix Patterns:
Performance Optimization: