kitty-session-persistence
БесплатноБез исполняемых скриптовНе проверенSnapshot and restore kitty terminal sessions on macOS. Use when surviving WindowServer hangs without losing tabs, configuring snapshots, or restoring after a…
от laurigates★ 61 звезда на GitHubОб этом скилле
Kitty Session Persistence (macOS)
When to Use This Skill
| Use this skill when... | Use something else when... |
|---|---|
| Terminal sessions need to survive WindowServer hangs and force-reboots | The user's terminal is iTerm2 / Terminal.app / Ghostty / Wezterm — kitty-specific |
Configuring kitty's listen_on socket and a snapshot LaunchAgent |
Cross-platform terminal config — this is macOS LaunchAgents |
| Restoring a previous session after a crash | One-off "open these tabs" — kitty @ launch directly is enough |
| Auditing whether snapshot capture is still running | General system diagnostics — see macos-plugin:macos-incident-postmortem |
| Snapshotting kitty's layout | Reading another pane's output, or deciding which kitty @ commands are safe to run — see kitty-remote-control |
Platform Guard
This skill is macOS-only. All commands assume Darwin and launchctl-managed LaunchAgents. Refuse to act if uname -s is not Darwin.
test "$(uname -s)" = "Darwin" || { echo "kitty-session-persistence: not Darwin, refusing"; exit 1; }
Core Expertise
Kitty exposes a remote control protocol via a Unix socket. With listen_on configured, kitten @ ls returns a JSON description of every OS window, tab, and window inside kitty — enough to reconstruct the layout from scratch.
The pattern this skill installs:
- Always-listen socket —
listen_on unix:/tmp/kitty-$USERinkitty.confso the snapshot script can always reach the running instance. - Snapshot script — captures
kitten @ lsoutput to a timestamped JSON file under~/.local/state/kitty-sessions/, with alatest.jsonsymlink. - LaunchAgent — runs the snapshot script every 5 minutes (default) so the worst-case loss is one window of work.
- Restore command — reads
latest.jsonand re-launches tabs with the recordedcwdand command.
Architectural notes
- Kitty's remote control requires
allow_remote_control yesinkitty.confor--allow-remote-control yesat launch. - The socket path must match between
listen_onand thekitten @ --toflag the snapshot script uses. - LaunchAgent
StandardOutPathandStandardErrorPathare essential — failing snapshots are otherwise silent. - Use
RunAtLoad: falseand rely onStartIntervalso a kitty restart doesn't spawn a backlog of immediate snapshots.
Setup
1. Configure kitty
Add to ~/.config/kitty/kitty.conf:
allow_remote_control yes
listen_on unix:/tmp/kitty-{kitty_pid}
Using {kitty_pid} makes each kitty instance addressable on its own socket. For the persistent-socket pattern this skill needs, use the user-stable form instead:
allow_remote_control yes
listen_on unix:/tmp/kitty-USER
Replace USER with the actual username. The snapshot LaunchAgent points at this exact path.
Reload kitty after editing:
kitty @ --to unix:/tmp/kitty-USER load-config
2. Install the snapshot script
Create ~/.local/bin/kitty-snapshot (mode 0755):
#!/usr/bin/env bash
set -uo pipefail
[ "$(uname -s)" = "Darwin" ] || exit 0
SOCKET="unix:/tmp/kitty-${USER}"
STATE_DIR="${HOME}/.local/state/kitty-sessions"
mkdir -p "$STATE_DIR"
ts="$(date -u +%Y%m%dT%H%M%SZ)"
out="${STATE_DIR}/${ts}.json"
if ! kitten @ --to "$SOCKET" ls >"$out" 2>>"${STATE_DIR}/snapshot.err"; then
rm -f "$out"
exit 0 # kitty not running — silent success
fi
ln -sfn "$out" "${STATE_DIR}/latest.json"
# Keep ~7 days of 5-min snapshots = 2016 files; cap at 4032 (14 days)
ls -1t "$STATE_DIR"/*.json 2>/dev/null | tail -n +4033 | xargs -r rm -f
The exit 0 on kitten @ ls failure is intentional — the LaunchAgent fires every 5 minutes regardless of whether kitty is running.
3. Install the LaunchAgent
Write ~/Library/LaunchAgents/com.<reverse-dns>.kitty-snapshot.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.kitty-snapshot</string>
<key>ProgramArguments</key>
<array>
<string>/Users/USER/.local/bin/kitty-snapshot</string>
</array>
<key>StartInterval</key>
<integer>300</integer>
<key>RunAtLoad</key>
<false/>
<key>StandardOutPath</key>
<string>/Users/USER/.local/state/kitty-sessions/launchd.out</string>
<key>StandardErrorPath</key>
<string>/Users/USER/.local/state/kitty-sessions/launchd.err</string>
</dict>
</plist>
Replace com.example with a stable reverse-DNS prefix and USER with the literal username (LaunchAgents do not expand $HOME).
Validate, load, and verify:
plutil -lint ~/Library/LaunchAgents/com.example.kitty-snapshot.plist
launchctl bootstrap "gui/$(id -u)" ~/Library/LaunchAgents/com.example.kitty-snapshot.plist
launchctl print "gui/$(id -u)/com.example.kitty-snapshot" | grep -E 'state|last exit'
bootstrap replaces the
Установить kitty-session-persistence в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Bash(kitty *)Bash(kitten *)Bash(launchctl *)Bash(uname *)Bash(plutil *)Bash(test *)ReadWriteEditGrepGlobFAQ
Что делает скилл kitty-session-persistence?
Snapshot and restore kitty terminal sessions on macOS. Use when surviving WindowServer hangs without losing tabs, configuring snapshots, or restoring after a force-reboot.
Как установить скилл kitty-session-persistence?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл kitty-session-persistence запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic