Saves the user's iTerm2 windows, tabs and panes with the Claude Code session running in each one, and reopens them later with every session resumed in its own pane; after iTerm2 crashes or the Mac restarts, reopens the Claude sessions whose pane is gone. macOS and iTerm2 only. Use when the user asks to save, snapshot, restore or recover their terminal tabs, panes or Claude sessions, for example "salva minhas abas", "salva o estado das abas do iTerm", "restaura as abas", "o iTerm fechou, reabr...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Tab Keeper?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/dvwinck-tab-keeper)
---
name: tab-keeper
description: Saves the user's iTerm2 windows, tabs and panes with the Claude Code session running in each one, and reopens them later with every session resumed in its own pane; after iTerm2 crashes or the Mac restarts, reopens the Claude sessions whose pane is gone. macOS and iTerm2 only. Use when the user asks to save, snapshot, restore or recover their terminal tabs, panes or Claude sessions, for example "salva minhas abas", "salva o estado das abas do iTerm", "restaura as abas", "o iTerm fechou, reabre minhas sessões", "quais sessões do Claude eu tinha abertas", "save my iTerm tabs", "restore my tabs", "reopen my Claude sessions after the crash". Triggers - /tab-keeper or /tab-keeper:tab-keeper.
---
# tab-keeper (iTerm2 tabs and the Claude session in each)
Two sources of what to reopen:
- **The registry.** The plugin's `SessionStart` hook writes one small file per iTerm2 pane that runs Claude Code (the Claude session id and its directory), keyed by the pane's `ITERM_SESSION_ID`; the `SessionEnd` hook removes it when the session ends on purpose (`/exit`, `/clear`, logout). After a crash or a restart, the entries whose pane is gone are what `recover` reopens. The hooks never print and never talk to iTerm2.
- **Snapshots.** `snapshot` asks iTerm2 for every window, tab and pane (directory, profile, size, what is running), joins each pane with the registry, and saves it under `<claude config dir>/tab-keeper/snapshots/`. Claude sessions started before the hook was active are found by the tab title when one transcript of the pane's project has that title; the plan marks them so the user can check.
Reply to the user in the user's language. The script's messages are English by default; when the user writes in Portuguese, run every command with `--lang pt-BR`.
## Flow
### 0. Locate the script
```bash
test -f "${CLAUDE_SKILL_DIR}/scripts/tab_keeper.py" && echo OK || echo FALTA
```
`FALTA` means "missing". If `${CLAUDE_SKILL_DIR}` appears unexpanded, use the path shown as "Base directory for this skill" when the skill was loaded, written out in full in every command. Always run the script with `python3 -I`.
### 1. Start with status when anything is unclear
```bash
python3 -I "${CLAUDE_SKILL_DIR}/scripts/tab_keeper.py" status
```
It shows whether iTerm2 is running, how many Claude sessions are registered and how many can be recovered, the snapshots, and whether this very session is registered. Exit code `1` means it found problems; read them to the user in plain words.
### 2. Translate the request into one command
| The user wants | Command |
| --- | --- |
| save the tabs now | `snapshot` (add `--name <word>` when the user names it, letters, digits and dashes) |
| see what was saved | `list` |
| reopen a saved layout | `restore [NAME]` (the latest when no name), then `restore [NAME] --yes` after the user agrees |
| reopen after a crash or restart | `recover`, then `recover --yes` after the user agrees |
| only some windows or tabs | add `--only 1,2.3` (window `1`, tab `2.3`, numbers from the plan) |
| stop offering a session | `forget <session id>` or `forget --orphans` |
### 3. Restoring always takes two steps
`restore` and `recover` without `--yes` only print the plan: one line per pane with its directory and the `claude --resume <id>` it will type. **Show the plan to the user and run again with `--yes` only after the user agrees.** With `--yes` the script opens new iTerm2 windows and types the commands into each pane. Point out:
- panes marked "found by the tab title": the session id came from the title, not from the hook;
- panes whose Claude session is still open in iTerm2: they only get the `cd`;
- programs that were running in other panes (a server, a `tail -f`): they are listed and never restarted, so tell the user which ones to start by hand;
- the split layout is approximate, while the panes, their order and their directories are exact.
## Rules
- Never run `restore --yes` or `recover --yes` without the user's approval of the plan just shown.
- Never edit the registry or the snapshots by hand; use `forget` to drop entries.
- When `status` says this session has no registry entry, the hook is not active: the plugin is disabled, was installed after the session started (restart Claude Code), or the skill was copied without the plugin (see the README for the hook entries to add to `settings.json`).
- Outside macOS, or without iTerm2, only the hooks run and they do nothing; say so instead of retrying.