ai-tabs
ai-tabs saves your iTerm2 tabs, and the omp, Claude Code, opencode and hermes sessions in them. After a reboot or a crash, it opens the tabs again and resumes each agent session.
- It takes a snapshot every 5 minutes through the iTerm2 Python API. A snapshot holds the windows, the tab order, titles and colors, the split layout, the iTerm2 profile of each pane, and the agent session in each pane.
- It keeps the snapshots in a SQLite database for 30 days. It pins the last snapshot before a reboot, or before many tabs close at once. The history never deletes pinned snapshots.
- A terminal screen lets you pick a snapshot and the tabs to open again.
- It can also export the snapshots as Markdown files, for example into an Obsidian vault.
Requirements
- macOS with iTerm2 3.5 or later.
- The iTerm2 Python API: open iTerm2 › Settings › General › Magic and select Enable Python API.
- uv. uv installs Python 3.15 for
ai-tabswhen it is necessary. - Optional: iTerm2 shell integration. With it,
ai-tabswaits for the shell prompt before it types the resume command.
Install
To run the tool without an install:
uvx ai-tabs
To install it, so that the launchd agent has a stable path:
uv tool install ai-tabs
To install the latest main branch from GitHub:
uv tool install git+https://github.com/WaYdotNET/ai-tabs
Then start the snapshots. This command loads two launchd agents. The first runs ai-tabs snapshot at login and every snapshot_interval seconds (default 300). The second runs ai-tabs watch, which takes a snapshot about 2 seconds after a tab, a window or a pane opens or closes (setting watch):
ai-tabs install
ai-tabs doctor
ai-tabs doctor checks iTerm2, its Python API, the shell integration, both agents, the age of the last snapshot, the database, the backups and the agent detection. It exits with code 1 when a check fails.
To stop the snapshots, run ai-tabs uninstall. The database, the backups and the configuration stay.
Use
Run ai-tabs without a command to open the restore screen. In iTerm2, the logo shows for a moment first (setting splash):
- The screen uses the colors of the logo, in a dark and a light theme. The
themesetting chooses one, andauto(the default) follows the macOS appearance. Presstto switch: it saves the choice astheme = "dark"ortheme = "light"in the configuration file. The top bar shows the small logo. Press?for the list of all the keys. - The left panel shows the snapshots, newest first. 📌 marks a pinned snapshot. A gold line shows how many panes opened and closed.
- The right panel shows the tabs of the selected snapshot. A bar in the tab color comes first, then the tab title, the session title and the folder. A green
●marks an agent session that still runs. - After a reboot or a crash, the screen starts on the last snapshot from before it, until you restore it.
| Key | Action |
|---|---|
↑ ↓ |
Move in the list |
tab |
Switch between the snapshots and the tabs |
space |
Select or clear a tab |
a |
Select all the visible tabs, or none |
/ |
Search tabs, sessions and folders. esc leaves the search |
enter |
Restore the selected tabs. In iTerm2, it asks first: new windows, or new tabs in this window |
c |
Show the ai-tabs commands, as ai-tabs --help |
d |
Dry run: show the commands that restore runs for the selected tabs |
r |
Resume recent sessions that do not run: space selects, enter resumes |
l |
Open a saved layout |
h |
Show the changes that the snapshot records |
p |
Pin the snapshot, or remove its pin |
e |
Export the snapshot as Markdown to export_dir |
o |
Change the settings |
s |
Take a snapshot now |
t |
Switch between the dark and the light theme, and save it in the settings |
v |
Show the releases and their changes, one line per change |
? |
Show all the keys |
q, esc |
Quit |
The restore opens new windows with the saved order, frame, titles, colors, splits and profiles. Each pane runs omp --resume or claude --resume in the agent folder, with the launch flags of the original session. A shell pane goes to its folder.
ai-tabs does not resume a session that still runs: two processes on the same session file corrupt it. For the same reason, when a snapshot holds one session in two panes, only the first pane resumes it.
Commands
| Command | What it does |
|---|---|
ai-tabs |
Open the restore screen |
ai-tabs snapshot |
Take a snapshot now |
ai-tabs restore [--from ID] [--tab 1.3 …] [--all] [--here] [--dry-run] |
Restore tabs. Without --tab or --all, it opens the restore screen. --here opens the tabs in this window |
ai-tabs show [ID] |
Show the tabs and sessions of a snapshot |
ai-tabs history [--limit N] |
List the snapshots, newest first |
ai-tabs pin ID, ai-tabs unpin ID |
Pin a snapshot, or remove its pin |
ai-tabs export [ID …] [--to DIR] |
Write snapshots as Markdown files |
ai-tabs sessions [--days N] [--open ID …] [--here] |
List the recent agent sessions that do not run now, or resume them by ID prefix |
ai-tabs layout save NAME [--from ID] [--tab 1.3 …] |
Save the current tabs, or tabs of a snapshot, under a name. Layouts never expire |
ai-tabs layout list, layout show NAME, layout open NAME [--here] [--dry-run], layout delete NAME |
List, show, open or delete the named layouts |
ai-tabs backup [--list] [--restore DATE|latest] [--yes] |
Write today's backup, list the backups, or restore one |
ai-tabs config, config set KEY VALUE, config unset KEY |
Show or change the settings |
ai-tabs changelog, ai-tabs --version |
Show the changes of each release, or the version |
ai-tabs install, ai-tabs uninstall |
Load or remove the launchd agents |
ai-tabs watch |
Take a snapshot after each tab, window or pane change. The watcher agent runs it |
ai-tabs doctor |
Check the setup |
A snapshot ID is YYYY-MM-DD/HH-MM-SS. latest is the newest snapshot. See docs/cli.md for all the options.
Settings
A setting takes its value from, in order of priority:
- the command option, for example
export --to; - the environment variable
AI_TABS_DIR, fordata_dironly; - the configuration file
$XDG_CONFIG_HOME/ai-tabs/config.toml, or~/.config/ai-tabs/config.toml; - the default.
| Setting | Default | Meaning |
|---|---|---|
data_dir |
$XDG_DATA_HOME/ai-tabs, or ~/.local/share/ai-tabs |
Folder of the database ai-tabs.sqlite. If ~/Library/Application Support/ai-tabs exists, ai-tabs moves it to this folder at the first start |
export_dir |
data_dir/export |
Folder of the Markdown exports |
export_latest |
false |
Rewrite export_dir/latest.md after every new snapshot |
backup_dir |
data_dir/backups |
Folder of the daily backups |
backup_keep |
7 |
How many daily backups stay |
history_days |
30 |
How many days the unpinned snapshots stay |
snapshot_interval |
300 |
Seconds between two snapshots. Run ai-tabs install after a change |
splash |
true |
Show the logo for a moment when the restore screen opens, in iTerm2 |
theme |
auto |
auto, dark or light. auto follows the macOS appearance |
watch |
true |
Take a snapshot when a tab, a window or a pane opens or closes. Run ai-tabs install after a change |
The configuration file holds only the settings that you changed, with config set, the settings window (o) or the t key. The other settings take their defaults. ai-tabs config shows each value and where it comes from: file, environment or default. ai-tabs config unset KEY gives a setting its default again. A new data_dir takes effect at the next start.
For an Obsidian vault, put the Markdown exports in the vault and keep the database out of it. A sync tool or git can copy the database while it is open and corrupt the copy. The exports are text files:
ai-tabs config set export_dir ~/Notes/ai-tabs
ai-tabs config set export_latest true
Data
ai-tabs snapshotwrites one backup a day with SQLiteVACUUM INTO, which makes a consistent copy.ai-tabs backup --restore DATEchecks the backup, writes a safety copy of the current database (backups/ai-tabs-before-restore-*.sqlite, never deleted by the daily prune), then copies the backup into the database with the SQLite online backup API.ai-tabs exportwrites one file per snapshot:export_dir/YYYY-MM-DD/HH-MM-SS.md. Each file has a front matter for Obsidian properties and Dataview, the changes, a table of the panes and the resume commands. Nothing reads the exports back: the database stays the only source.- Both launchd agents log to
~/Library/Logs/ai-tabs.log. The lines of the watcher start withwatch:.
How it finds the agent sessions
- Claude Code:
~/.claude/sessions/<pid>.jsongives the session ID and folder of eachclaudeprocess. - omp:
lsofgives the session file that eachompprocess holds open. omp holds the file open only while it writes to it, so for an idle resumed session the file comes fromomp --resume <file>. The first lines of the file give the session ID, folder and title. - opencode: the session comes from
--session <id>. Without the flag, it is the newest session of the process folder in~/.local/share/opencode/opencode.dbthat started after the process. Resume:opencode --session <id>. - hermes: the session comes from
--resume <id>. Without the flag, it is the newest open chat session of the process folder in~/.hermes/state.db. Resume:hermes chat --resume <id>. psgives the terminal of each process, and its command line for the launch flags.psdrops the original quotes, so a flag value with spaces can split into more words.- A pane without an agent takes the folder of the program that runs in it (
lsof -d cwd), or the iTerm2 folder when the shell shows its prompt.
Limits
- Only iTerm2 on macOS.
- A reboot stops every process.
ai-tabsopens the tabs again and resumes the sessions, but it does not bring back running processes. - It resumes omp, Claude Code, opencode and hermes sessions. Other panes go back to their folder.
- The opencode and hermes databases are opened read only. When the command line does not name the session, ai-tabs takes it from the folder and the start time of the process. It finds nothing after
--continue, after a session picked inside the agent, or before the first message.
Development
uv sync
uv run pytest
uv run ruff check src tests
uv run typer ai_tabs.cli utils docs --name ai-tabs --title ai-tabs --output docs/cli.md
Release
The Release workflow publishes to PyPI when a tag vX.Y.Z arrives on GitHub. It runs the tests, checks that the tag is the version in pyproject.toml, builds the wheel and the sdist, then uploads them with PyPI Trusted Publishing. No token is stored in GitHub.
Put the changes under ## [Unreleased] in CHANGELOG.md, commit them, then run the release script. It checks that main is clean and up to date, moves the Unreleased items to the new version, bumps the version, regenerates docs/cli.md, runs ruff and pytest, commits, tags and pushes. Then it waits for the workflow and for PyPI, installs the new version, restarts the watcher and runs ai-tabs doctor:
uv run scripts/release.py minor --dry-run # or patch, major
uv run scripts/release.py minor
License
MIT. See LICENSE.
Metadata
Release files for ai-tabs 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ai_tabs-0.4.0.tar.gz | 80.5 kB | With provenance | Details for ai_tabs-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ai_tabs-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for ai_tabs-0.4.0-py3-none-any.whl |
Total release size: 168.7 kB
Release files / ai_tabs-0.4.0.tar.gz
| Download URL | ai_tabs-0.4.0.tar.gz |
|---|---|
| Size | 80.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1fd14ec78eb80efba01a84a15a33835ad4999fd0c0b94ccee4003cdeaad4315
|
|
BLAKE2b-256 checksum How to use checksums |
88a7d8455dd200415fb326be13fd196ef0a33dce16838b48e132ef1b599653de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / ai_tabs-0.4.0-py3-none-any.whl
| Download URL | ai_tabs-0.4.0-py3-none-any.whl |
|---|---|
| Size | 88.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46a2b63981ecf9dc21cf04578e5ac30b6a2c7c967bd9fa653943aab6feef9470
|
|
BLAKE2b-256 checksum How to use checksums |
7b010c16c1fbde7cd444492fb1310e2ca0afadb2fe05938934f940d52a848fd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for ai-tabs 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ai_tabs-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.