Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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:

  1. Always-listen socket — listen_on unix:/tmp/kitty-$USER in kitty.conf so the snapshot script can always reach the running instance.
  2. Snapshot script — captures kitten @ ls output to a timestamped JSON file under ~/.local/state/kitty-sessions/, with a latest.json symlink.
  3. LaunchAgent — runs the snapshot script every 5 minutes (default) so the worst-case loss is one window of work.
  4. Restore command — reads latest.json and re-launches tabs with the recorded cwd and command.

Architectural notes

  • Kitty's remote control requires allow_remote_control yes in kitty.conf or --allow-remote-control yes at launch.
  • The socket path must match between listen_on and the kitten @ --to flag the snapshot script uses.
  • LaunchAgent StandardOutPath and StandardErrorPath are essential — failing snapshots are otherwise silent.
  • Use RunAtLoad: false and rely on StartInterval so 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

Полный SKILL.md на GitHub

Установить kitty-session-persistence в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash(kitty *)
Bash(kitten *)
Bash(launchctl *)
Bash(uname *)
Bash(plutil *)
Bash(test *)
Read
Write
Edit
Grep
Glob

FAQ

Что делает скилл 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), без исполняемых скриптов.

Похожие скиллы

Сравнить kitty-session-persistence с