How It Works
Claude Code stores every session as a JSONL file in~/.claude/projects/. Each file is a newline-delimited transcript of the session: tool calls, file reads and writes, bash commands, user prompts, assistant responses, and task completions.
Agent Memory’s import command reads these transcripts, parses each event, and processes them through the same pipeline as live sessions: deduplication, privacy filtering, synthetic compression, vector embedding, and BM25 indexing. After import, you can search this history with memory_smart_search exactly as you would search memories from current sessions.
Import via CLI
Run the import from any terminal whereagentmemory is installed:
~/.claude/projects/ and imports them. For large histories, use these options to control scope:
Import via API
You can also trigger an import over the REST API, which is useful for scripting or automation:AGENTMEMORY_SECRET set, include the Authorization header:
What Gets Imported
Agent Memory applies the same privacy filter used for live sessions: API keys, secrets, tokens, and content tagged
<private> are stripped before any data is stored or indexed.
After Import
Once the import finishes, verify the results:memory_smart_search MCP tool from inside your agent — search for a technology, file, or decision you know appeared in a previous session and confirm the agent can find it.
You can also browse imported sessions in the real-time viewer at http://localhost:3113. Imported sessions appear in the Replay tab alongside live sessions, with full timeline scrubbing and event playback.
Large import sets may take several minutes to process, especially if
CONSOLIDATION_ENABLED=true is set. Consolidation runs at the end of each imported session and involves LLM calls for summarization and graph extraction. For a faster initial import, you can temporarily set CONSOLIDATION_ENABLED=false, then run agentmemory consolidate manually after the import completes.Keeping History Fresh
Claude Code’scleanupPeriodDays setting (in ~/.claude/settings.json, default 30 days) automatically deletes JSONL transcripts older than that window. If you install Agent Memory on a months-old Claude Code setup, transcripts from before the cleanup window are already gone.
To prevent future data loss:
- Raise the cleanup window in
~/.claude/settings.json:"cleanupPeriodDays": 90 - Or use live capture (recommended): once the Agent Memory hooks are wired via
agentmemory connect claude-code, every session turn lands in Agent Memory in real time — Claude Code’s JSONL cleanup becomes irrelevant.