I Built a Tool to Stop Losing My Claude Code Conversation History
Source: Dev.to
The Problem: Lost Claude Code Conversation History
A few weeks ago I needed to revisit a debugging session. Claude had walked me through a nasty race condition in my app—it took over an hour, and the fix was subtle. I knew exactly which session it was, but when I went to find the JSONL file it was gone. No warning, no “this file will be deleted in 3 days.” Just gone.
If you’ve been using Claude Code for more than a couple of months, this has probably happened to you too. Claude Code stores conversations as JSONL files under ~/.claude/projects/, and old files are automatically deleted over time. You can disable auto‑deletion in settings, but that only solves part of the problem:
/compactstill lossy‑summarizes your context.- Version updates can break session compatibility.
- Even with deletion disabled, JSONL files are scattered across directories with no way to search across sessions.
Existing Tools
- claude-history (Rust TUI) – great for browsing, but reads JSONL files directly, so deleted files are invisible.
- Claude Code History Viewer (desktop app) – same limitation.
- claude-mem – persists data into its own database and adds semantic search, but brings in a full Node.js/MCP server stack that’s overkill for simple archiving.
What I needed was a simple, durable archive I could set up once and forget about.
Introducing claude-vault
claude-vault is a single‑binary Rust tool that imports Claude Code conversations into an SQLite database with full‑text search. No Node.js, no Python, no MCP server—just download and run.
Importing Conversations
claude-vault import
# Imported 94562 messages (0 skipped, 12847 filtered, 0 errors) from 203 filesOnce the data is in SQLite, it survives file deletion, compaction, and updates.
What Gets Imported
Claude Code JSONL files contain a lot of noise (tool results, system tags, file‑read outputs, progress messages). claude-vault strips all of that, keeping only:
- Your questions
- Claude’s responses
- Code‑modifying actions
Searching the Archive
claude-vault uses SQLite’s FTS5 with Porter stemming, so searches are flexible:
claude-vault search "race condition fix"
claude-vault search "deploy" --project my-app --since 2025-01-01You can also get JSON output for piping back into Claude:
claude-vault search "previous auth implementation" --jsonAutomating the Import
Manually running import works, but I kept forgetting. The real fix is to hook the import into Claude Code’s lifecycle.
Add the following to ~/.claude/settings.json:
{
"hooks": {
"PreCompact": [
{
"hooks": [
{
"type": "command",
"command": "claude-vault import >/dev/null 2>&1"
}
]
}
],
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "claude-vault import >/dev/null 2>&1 &"
}
]
}
]
}
}- PreCompact – captures the full conversation before
/compactsummarizes it. - SessionEnd – archives the session in the background when you exit.
Once set up, every session is archived automatically without any further thought.
How It Differs from Other Solutions
| Feature | claude-vault | claude-history | claude-mem |
|---|---|---|---|
| Archive only (no memory injection) | ✅ | ✅ | ❌ (adds memory) |
| CLI‑only | ✅ | ✅ (TUI) | ✅ (requires server) |
| Full‑text search (FTS5) | ✅ | ✅ (basic) | ✅ (semantic) |
| No external runtime (Node, Python) | ✅ | ✅ | ❌ |
| Automatic hooking into Claude Code | ✅ | ❌ | ❌ |
It does one thing: make sure your conversations don’t disappear. Nothing more, nothing less.
Installation
cargo install claude-vault
# or download a prebuilt binary from GitHub ReleasesCall to Action
Run claude-vault import now. If you’ve been using Claude Code for a while, some of your old sessions might already be gone—archive what’s left before it’s too late.
GitHub:
Have you lost Claude Code sessions you wish you could get back? What’s your approach to preserving conversation history? I’d love to hear what others are doing.