DEV Community

kuroko
kuroko

Posted on

I Built a Tool to Stop Losing My 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.

I went to find the JSONL file. 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.

Wait, Claude Code Deletes My History?

Yeah. Claude Code stores conversations as JSONL files under ~/.claude/projects/, and old files are automatically deleted over time. You can change this in settings, but that only solves the auto-deletion problem. /compact still lossy-summarizes your context, and version updates can break session compatibility. Even with deletion disabled, JSONL files are scattered across directories with no way to search across sessions.

What I Tried (and Why It Wasn't Enough)

I tried claude-history (Rust TUI) and Claude Code History Viewer (desktop app). Both are great for browsing, but they read JSONL files directly — once those files get deleted, they can't show you anything either. claude-mem does persist data into its own database, but it's a full memory system with Node.js, MCP server, and semantic search — more than I needed. I just wanted to archive conversations before they disappear.

What I was missing: a simple, durable archive I could set up once and forget about.

So I Built One

claude-vault is a single Rust binary that imports your Claude Code conversations into SQLite with full-text search. No Node.js, no Python, no MCP server — just download and run.

claude-vault import
# Imported 94562 messages (0 skipped, 12847 filtered, 0 errors) from 203 files
Enter fullscreen mode Exit fullscreen mode

Once conversations are in SQLite, they survive file deletion, compaction, updates — whatever happens to the original JSONL files.

What About All the Noise?

If you've ever opened a Claude Code JSONL file, you know it's mostly noise — tool results, system tags, file read outputs, progress messages. claude-vault strips all of that during import, keeping only what matters: your questions, Claude's responses, and code-modifying actions.

Search That Actually Works

Search uses FTS5 with Porter stemming, so "running" matches "run" and "configurations" matches "configure":

claude-vault search "race condition fix"
claude-vault search "deploy" --project my-app --since 2025-01-01
Enter fullscreen mode Exit fullscreen mode

You can also pipe JSON output to Claude itself:

claude-vault search "previous auth implementation" --json
Enter fullscreen mode Exit fullscreen mode

The Part That Made It Actually Useful: Hooks

Manually running import is fine, but I kept forgetting. The real fix was hooking it into Claude Code's lifecycle. Add this 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 &"
          }
        ]
      }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

PreCompact captures the full conversation before /compact summarizes it. SessionEnd archives in the background when you exit. Once set up, I never think about it — every session is archived automatically.

What It Doesn't Do (Honest Assessment)

  • It's an archive, not a memory system. It won't inject past context into new sessions automatically.
  • It's CLI-only. If you want a TUI, claude-history is great.
  • No semantic search — it's keyword-based FTS5 with stemming.

It does one thing: makes sure your conversations don't disappear. That's it.

Try It

cargo install claude-vault
# or download a prebuilt binary from GitHub Releases
Enter fullscreen mode Exit fullscreen mode

Seriously, 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: kuroko1t/claude-vault


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.

Top comments (1)

Collapse
 
ptak_dev profile image
Patrick T

Nice write-up. Short and to the point.