recover-chats
If you run many parallel Claude Code sessions — possibly across multiple config dirs (~/.claude
plus any additional ~/.claude-* dirs) — a crash loses track of them all. When VS Code or the terminal
crashes, the session IDs are gone from the tab strip but the transcripts survive on disk. This skill
finds the real chats and hands back ready-to-run resume commands, each labeled with its opening
prompt so they're recognizable.
Run it
python3 ~/.claude/skills/recover-chats/recover.py
Defaults: last 2 days (today + yesterday), chats with >=2 human-typed turns, all config dirs.
Prints a sorted table and writes labeled resume commands to ~/resume-lost-chats.sh.
Flags:
--days N— look-back window (default 2).--min-turns N— lower to1to include chats typed in only once (a tab opened right before the crash with a single message); raises noise. Raise to cut to only substantial chats.--project <substr>— only sessions whose cwd/project matches (e.g.--project acme-app).--out <path>/--no-file— change or skip the output file.
Then tell the user: open ~/resume-lost-chats.sh, skim the # label comments, paste the ones they
want into separate terminal tabs. Don't run the file as a script — the lines are interactive
claude launches, one per tab. Each line is cd <real cwd> && CLAUDE_CONFIG_DIR=<dir> claude --resume <id> --dangerously-skip-permissions.
Why it works this way (the two traps)
- File mtime is a lie here. Config-dir files get bulk-touched to the same second (iCloud / Time
Machine / git checkout), so
find -mtimereports thousands of "recently modified" files that weren't touched by any session. The script uses thetimestampfield recorded inside each.jsonl, which only advances on real activity. - Most session files aren't chats. Factories, workflows, and subagents spawn hundreds of
sessions that live in
projects/alongside real ones. The script drops them by: skippingwf_*/subagentsdirs andagent-*/journalfiles, excluding machine-path buckets (private-tmp,claude-mem-observer,usage-watch, scratchpad exports), and requiring>=min-turnsgenuinely human-typed messages (not tool results, banners, or command wrappers).
Notes
- Config dirs are auto-discovered: every
~/.claudeand~/.claude-*that has aprojects/dir. A new account added later is picked up automatically — no edits needed. cwdfor each command comes from inside the session file, so worktree / non-repo paths are exact.- Completeness caveat to pass on: a chat with fewer than
--min-turnshuman messages is filtered out. If a recovered list looks short, rerun with--min-turns 1.