respawn
БесплатноЗапускает вложенные скриптыНе проверенRestart the current Claude Code or Codex CLI in its own terminal (iTerm2 window or tmux pane), or the current Claude Code background session (claude --bg / ←…
от vicnaum★ 53 звезды на GitHubОб этом скилле
Respawn
Restarts the calling Claude Code or Codex CLI in its verified iTerm2 session or tmux pane, or the calling Claude Code background session through its daemon, and resumes a session. Requires the companion agent-chat skill/CLI, which provides the shared identity and terminal ownership checks. Companion to session-stripper: a CLI restart loads the stripped transcript as smaller context.
Workflow (context nearly full)
Run inside the session that needs restarting:
- Strip first — use the
session-stripperskill. Its mutating commands write a fork by default: a NEW session id, printed asResume it: claude -r <new-session-id>. The live file is never touched, so stripping your own running session is safe. Note the new id for step 2. (With--in-placethe stripper instead writes<session>.jsonl.pendingand keeps the id; that copy needs--swap.) - Schedule the respawn — this must be the LAST tool call of the turn:
<skill-dir>/scripts/respawn.sh <new-session-id> # forked strip (the default): resume the fork
<skill-dir>/scripts/respawn.sh --swap <session.jsonl>.pending # --in-place strip: swap + resume this session's id
<skill-dir>/scripts/respawn.sh # plain restart, nothing to swap
- End the turn immediately — reply with one short line (e.g. "Respawning now, back shortly") and stop. Do not keep working after scheduling a real respawn. The watcher will recheck ownership, then stop the captured CLI. A dry run does not schedule anything and need not be the last tool call.
--swap applies the session surgery at the only race-free moment: after the watcher has confirmed the CLI process is dead, before relaunch. It runs session-stripper's apply (atomic rename; refuses on lineage/liveness/verify failures). If apply refuses, the watcher relaunches the UNSTRIPPED session and rewrites the kickoff prompt to say so — fail-open, nothing is lost. Whatever the CLI appended after the snapshot (the stripping turn itself) is discarded by design.
How it works
respawn.sh asks agent-chat whereami for the calling CLI, session and pane. It uses the sibling checkout's CLI when available, so an older PATH install cannot bypass the guard. Conflicting inherited session variables are resolved through the nearest CLI ancestor; ambiguous identity refuses. The scheduler verifies the foreground session and captures its pid/birth time, tty, and parent shell pid/birth time before detaching the watcher. The resume id may differ after a fork; the identity stopped is always the original calling session.
For Claude Code, the launch command is rebuilt from its exact argv (sysctl on macOS, /proc on Linux; ps joins arguments and loses quoting). Flags are preserved except session/worktree selectors: -c/--continue, -r/--resume [id], --from-pr [ref], --session-id <id>, --fork-session, -w/--worktree [name]/--tmux, --bg. Any prompt the CLI was launched with is dropped too; agents started by agent-chat carry their kickoff there. Then --resume <sid> is appended. --cmd "claude ..." overrides reconstruction.
The detached watcher then:
- Waits
--grace Nseconds (default 15), then verifies the original foreground session and process identity again. A changed thread, replaced process or pane causes refusal before input/signals. A CLI that already exited is accepted only in its verified original shell. - Stops the captured CLI: Codex receives SIGTERM by verified pid, with no terminal quit keys. Claude receives
/exitplus a separately guarded Enter; it can queue until turn end. When background shells or agents are running, Claude Code then asks "Background work is running": 1. Exit and stop tasks / 2. Move to background and exit / 3. Stay. The watcher confirms the default with Enter, and only while the selection is on "Exit and stop tasks". Those shells die with the CLI, and the default kickoff tells the agent to re-arm the ones it needs, such as anagent-chat watch. The watcher waits up to 15 minutes, or 20s with--force, and rechecks ownership before signal escalation. It never retargets a different pid that appeared on the tty. - With
--swap, applies the pending Claude transcript only after the original CLI is gone. On apply refusal it retains the original and rewrites the kickoff to explain that the session is unstripped. - Verifies the original foreground shell before typing the launch line and again before Enter. The kickoff is a quoted command-line argument, including after a failed swap; nothing is typed into a booting TUI.
- Waits up to 60s for the resumed session to be proved in the same pane under the original shell. Startup failure or a dialog produces a logged failure and no additional input.
Log: ~/.claude/respawn/respawn.log.
Claude Code background sessions
A session started with claude --bg, or moved there with ← or /background, has no pane: its worker runs on a pty the daemon owns.
Установить respawn в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл respawn?
Restart the current Claude Code or Codex CLI in its own terminal (iTerm2 window or tmux pane), or the current Claude Code background session (claude --bg / ←, no terminal), and resume a session — the external relaunch step an agent cannot perform on itself. Use when: (1) the session's context is nearly full and was just stripped with session-stripper, so the stripped pending copy must be swapped in (--swap) and the CLI restarted to load the smaller transcript, (2) resuming a forked stripped session under a new session id, (3) the user or the agent says respawn, restart yourself, restart the CLI, reload the session, or resume after strip. Backends: iTerm2 (macOS), tmux (works headless, e.g. Linux servers) and Claude Code background sessions.
Как установить скилл respawn?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл respawn запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic