Documentation Index
Fetch the complete documentation index at: https://docs.claude-mem.ai/llms.txt
Use this file to discover all available pages before exploring further.
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)
Export Memories
# Export all Windows-related memories
npx tsx scripts/export-memories.ts "windows" windows-memories.json
# Export bug fixes
npx tsx scripts/export-memories.ts "bugfix" bugfixes.json
# Export specific feature work
npx tsx scripts/export-memories.ts "progressive disclosure" progressive-disclosure.json
Parameters:
<query> - Search query (uses hybrid semantic + full-text search)
<output-file> - Output JSON file path
--project=name - Optional: filter results 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
Import Memories
# Import from an export file
npx tsx scripts/import-memories.ts windows-memories.json
Parameters:
<input-file> - Input JSON file (from export script)
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!
π Summary:
Sessions: 12 imported, 0 skipped
Summaries: 12 imported, 0 skipped
Observations: 54 imported, 0 skipped
Prompts: 7 imported, 0 skipped
Re-importing (Duplicate Prevention)
If you run the import again on the same file, duplicates are automatically skipped:
π Importing sessions...
β
Imported: 0, Skipped: 12 β All skipped (already exist)
π Importing summaries...
β
Imported: 0, Skipped: 12
π Importing observations...
β
Imported: 0, Skipped: 54
π Importing prompts...
β
Imported: 0, Skipped: 7
Sharing Memories
For Export Authors
-
Export your memories:
npx tsx scripts/export-memories.ts "windows" windows-memories.json
-
Share the JSON file via:
- GitHub gist
- Project repository (
shared-memories/)
- Direct file transfer
- Package in releases
-
Document whatβs included:
- What query was used
- What knowledge is contained
- Who might benefit from it
For Import Users
-
Download the export file to your local machine
-
Review whatβs in it (optional):
cat windows-memories.json | jq '.totalObservations, .totalSessions'
-
Import into your database:
npx tsx scripts/import-memories.ts windows-memories.json
-
Verify import by searching:
curl "http://localhost:37777/api/search?query=windows&format=index&limit=10"
{
"exportedAt": "2025-12-10T23:45:00.000Z",
"exportedAtEpoch": 1733876700000,
"query": "windows",
"totalObservations": 54,
"totalSessions": 12,
"totalSummaries": 12,
"totalPrompts": 7,
"observations": [ /* array of observation objects */ ],
"sessions": [ /* array of session objects */ ],
"summaries": [ /* array of summary objects */ ],
"prompts": [ /* array of prompt objects */ ]
}
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 only claude-mem project memories
npx tsx scripts/export-memories.ts "bugfix" bugfixes.json --project=claude-mem
# Export all memories for a specific project
npx tsx scripts/export-memories.ts "" all-project.json --project=my-app
Export by 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" bugfixes.json
Export by Date Range
You can filter the export after exporting:
# Export all memories, then filter manually with jq
npx tsx scripts/export-memories.ts "" all-memories.json
cat all-memories.json | jq '.observations |= map(select(.created_at_epoch > 1700000000000))' > recent-memories.json
Combine Multiple Exports
# Export different topics
npx tsx scripts/export-memories.ts "windows" windows.json
npx tsx scripts/export-memories.ts "linux" linux.json
# Import both
npx tsx scripts/import-memories.ts windows.json
npx tsx scripts/import-memories.ts linux.json
Troubleshooting
Database Not Found
β Database not found at: /Users/you/.claude-mem/claude-mem.db
Solution: Make sure claude-mem is installed and has been run at least once.
Import File Not Found
β Input file not found: windows-memories.json
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:
- Create a PR to the
shared-memories/ directory
- Include a README describing whatβs in the export
- Tag with relevant keywords (windows, linux, bugfix, etc.)
- Community members can then import your knowledge!
Examples of Useful Exports
Windows Compatibility Knowledge:
npx tsx scripts/export-memories.ts "windows compatibility installation" windows-fixes.json
Progressive Disclosure Architecture:
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:
npx tsx scripts/export-memories.ts "performance optimization caching" perf-tips.json