DEV Community

Cover image for Claude Resurrect — a tool to resume all Claude sessions after a reboot
Dennis
Dennis

Posted on Edited on Originally published at Medium AI-assisted

Claude Resurrect — a tool to resume all Claude sessions after a reboot

I keep a bunch of Claude Code sessions open in iTerm2. One per tab, each in its own project, some of them running for days. They know the code, they remember what we tried yesterday and why it didn't work. Basically it's my whole working context.

Auto updates on my Mac are off, of course. But sometimes you just have to reboot: an update you actually need, something hangs, whatever. iTerm2 brings the tabs back after the reboot, but every tab is just an empty shell. So you go tab by tab: cd into the project, claude --resume, find the right session in the list, and again, and again. I hated that part.

tmux has had tmux-resurrect for years. For iTerm2 I didn't find anything that works properly. There are a few tools with "claude-resurrect" in the name, but they do other things: restart one session, or work with tmux or Ghostty. None of them puts every session back into its own iTerm2 tab after a reboot.

So I made my own. I called it 2.0, because there were already a few before it.

What it does

Install once:

curl -fsSL https://raw.githubusercontent.com/User0856/claude-resurrect-2.0/main/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

A small background agent writes down which tab runs which Claude session, every 30 seconds. You don't need to do anything before a reboot.

After the reboot open iTerm2 and run:

claude-resurrect
Enter fullscreen mode Exit fullscreen mode

claude-resurrect output after a reboot: four sessions resumed in their tabs, one already running and skipped

Every session comes back into its tab, in its folder, with the whole conversation. It just runs the same claude --resume <session-id> you would type yourself. Session names stay. Sessions that are already running get skipped, so running it twice is safe.

It's one JavaScript for Automation script. That ships with macOS, so there's nothing else to install.

How it works

Claude Code keeps a small file for every running session in ~/.claude/sessions/<pid>.json with the session ID, the folder and the start time. iTerm2 can tell which terminal device each tab uses, and ps tells which device each Claude process sits on. Put these together and you know which session lives in which tab.

A few things I had to get right:

Shutdown is messy. During a reboot processes die one by one, and a save in the middle would catch a half-empty layout. So a new layout is saved only after it's seen twice in a row, and an empty one is never saved.

The newest snapshot is the wrong one. If you start one fresh session before restoring, the newest snapshot has just that one session. So by default it takes the last snapshot from before the boot. All snapshots are kept, and claude-resurrect list shows them.

PIDs get reused. After a reboot an old session file can point to a PID that now belongs to some other process. The tool checks the process start time and the boot time, so it doesn't get fooled.

It never types into a busy tab. Only into a tab sitting at a clean shell prompt. Otherwise it opens a new tab.

What doesn't come back

You get what claude --resume gives you, the whole conversation. Whatever was running at the moment of the reboot is gone, like a half-written answer, background shells, subagents or /loop tasks. Usually I just say "continue where we stopped" and it does.

It also keeps a few launch flags like --model, --permission-mode and --add-dir.

What's next

For now it's macOS and iTerm2 only, because that's what I use. The name is generic on purpose. Terminal.app and tmux are next, then WezTerm and kitty. If you use one of those and want to help, issues are open.

Free, MIT. If a reboot ever ate your Claude sessions, give it a try:

GitHub logo User0856 / claude-resurrect-2.0

Restore all your Claude Code sessions after a macOS reboot with one command. Every session back in its own iTerm2 tab, with its full context. Like tmux-resurrect, for Claude Code. Zero dependencies.

Claude Resurrect 2.0: a pixel-art necromancer raising a terminal window from its grave

Claude Resurrect 2.0

Reboot your Mac without losing a single Claude Code session.
One command brings every session back to its iTerm2 tab, in the right folder, with its whole conversation

macOS iTerm2 Claude Code

Tests Version 2.0.0 Zero dependencies MIT License

Install · Use · Terminals · How it works · FAQ


Why this exists

iTerm2 is my favorite terminal. I keep a lot of Claude Code sessions open in it, one per tab, each in its own project, some running for days with a mountain of context behind them. Then macOS wants to restart, and every one of them is gone. Reopening them by hand means finding each folder and each session ID, tab after tab.

tmux users have had tmux-resurrect for years. iTerm2 had nothing. There are already a few tools called claude-resurrect, but none of them did what I needed with iTerm2: after a full reboot, put every session back into its own tab and resume it…




And if it saves you some time, a star would make my day.

Top comments (0)