name: snapshot-sessions
description: Danger-first snapshot of all live Claude Code sessions before a restart or shutdown. Scans running claude processes (NOT transcript timestamps, which miss idle/week-old tabs), resolves each to its folder + branch + uncommitted/unpushed/open-PR state, and writes a danger-first list to ~/.claude/session-snapshot.md so you know what unsaved work you are walking away from and exactly which cd <folder> && claude --resume <id> to run after reboot. Also lists orphaned worktrees with no attached session as a reap signal. Use when the user says "save my open sessions", "save the open claude tabs", "snapshot my sessions", "save my session statuses before I restart", "what should I reopen after I restart", "before I restart my computer", "capture my open tabs", or "snapshot-show" (just reads the saved file back).
/ro:snapshot-sessions
A pre-restart / pre-shutdown safety sweep across every live Claude Code session on the machine. It is a fire-alarm, not a dashboard and not a resume system: its one irreducible value is the cross-session view that no single session can produce (each session only sees its own cwd, and /ro:close-session only sweeps the repo it runs in).
Why this exists
You have N Claude sessions open across repos and worktrees in iTerm tabs. You need to restart the machine. Three things are true:
- Transcripts and working trees survive a restart. Conversations are journalled to
~/.claude/projects/<slug>/<session-id>.jsonl;claude --resume <id>replays one verbatim. Uncommitted files are on disk and survive reboot. So you lose almost nothing on a clean restart. - What you DO lose is the cross-session map (which tab was in which folder/worktree, doing what) and any background work (workflows, ScheduleWakeup chains, dev servers).
- Tab names lie. A tab labelled "NUTMEG" might be a shell, and a week-idle tab is invisible to any timestamp-based scan.
This skill solves #2 by keying off live processes, so it catches every open session regardless of how long it has been idle.
What it does
Run the bundled script:
python3 "$(dirname "$0")/scripts/snapshot.py" # or: python3 ~/Dev/ronan-skills/skills/snapshot-sessions/scripts/snapshot.py
It:
pgrep -fl 'claude --dangerously-skip-permissions'for live session pids.- Per pid,
lsof -p <pid> -a -d cwd -Fnfor the working directory (Claude does NOT hold the transcript open continuously, so key off cwd, then map to the newest transcript in~/.claude/projects/<slug>/; slug = every non-alphanumeric char replaced with-). - Per session, gather: branch, meaningful uncommitted count (ignores agent/tooling state:
.claude/RESUME.md,.swarm/,.nightshift/,.ralph/,.claude/worktrees/, the snapshot file itself), unpushed commits (@{u}..HEAD), open PR for the branch (gh pr list --head), and a one-line "what" (prefers a.claude/RESUME.md/.swarm/run-state.mdsummary line, falls back to the last real user instruction). - List orphaned worktrees: worktrees of any live repo with no session attached. Clean + merged ones are reap candidates.
- Write
~/.claude/session-snapshot.mddanger-first: rows with uncommitted/unpushed/open-PR work at the top, clean rows next, orphaned worktrees, then a paste-ready resume block.
After writing, open it so the user sees it:
open ~/.claude/session-snapshot.md
snapshot-show
"snapshot-show" / "show my saved sessions" is the read-back half. After a restart the live processes are gone, but the file persists, so just:
cat ~/.claude/session-snapshot.md # or: open ~/.claude/session-snapshot.md
No re-scan needed (and impossible anyway, the sessions are closed). Capture needs live processes; show just reads the saved file.
The restart flow
- Run
/ro:snapshot-sessionswhile the sessions are still alive (it needs the processes). - Deal with the ⚠️ danger rows first: anything uncommitted/unpushed/open-PR is work you are about to walk away from. For a session with real WIP, run
/ro:close-sessionin that tab rather than just relying on--resume. - Restart.
- Read
~/.claude/session-snapshot.md, recreate tabs, run the resume command per row.
Scope discipline (do not grow this)
- It is a fire-alarm, not a daily dashboard. Its value is inversely proportional to your session discipline: if you close sessions promptly (
/ro:close-session), you rarely need it. It earns its keep digging out of session sprawl and as a crash safety net. - Resume is the safety net, not the goal. The disciplined path is
/ro:close-sessionper tab (durable capture: issues, ADRs, wiki, memory), then start fresh and light (Pocock's <100k-token sessions). This skill does not replace that. - Do not auto-resume or auto-recreate tabs. It hands the user the commands; the human runs them.
Related
/ro:close-session— the per-session durability sweep; the disciplined front door this skill is the fallback for./ro:handoff— compacts one session into a rich handoff doc; its summary line is what this skill's "what" column reads when present./ro:worktree—reapmode audits the orphaned worktrees this skill surfaces before removing them.
Provenance
Created 2026-06-14 after a multi-repo night-shift run left 10 sessions open across repos and worktrees with a forced restart pending. Built from a proven script written live that session. Named "snapshot" deliberately: the file is read AFTER the sessions close (so "open-sessions" would be wrong), and "checkpoint" collides with /ro:way-of-working's commit-cadence vocabulary. See ronan-skills#77.