Developer builds bash script to restore multiple Claude Code CLI sessions after Mac crash

A developer lost seven active Claude Code CLI sessions across five repositories when their Mac hard-crashed, as the CLI's built-in recovery tool only restores sessions one directory at a time. Investigating the issue, they discovered that Claude Code stores all session data in plain JSONL files under a local directory, containing session IDs, working directories, git branches, and conversation content. Using this, they wrote a roughly 150-line bash script called claude-sessions that aggregates all sessions across every project, displays them in a searchable list with conversation previews, and reopens each one in a new terminal tab or tmux window on selection. The script also filters out sub-agent sessions spawned by multi-agent workflows, which can account for a large share of session files. What previously took around 15 minutes of manual recovery was reduced to seconds using the tool, which depends only on fzf and Python 3.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in