respawn-sessions

Respawn long-running Claude Code sessions as detached tmux sessions with registry-driven modes.

Updated May 12, 2026
One-click install
npx skills add https://github.com/fryanpan/ai-team-lead --skill respawn-sessions-fryanpan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: respawn-sessions
Source: https://github.com/fryanpan/ai-team-lead/tree/main/.claude/skills/respawn-sessions
Command: npx skills add https://github.com/fryanpan/ai-team-lead --skill respawn-sessions-fryanpan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Restarting a fleet of long-running Claude Code agent sessions after a reboot, plugin update, or account switch is error-prone: hand-rolled tmux commands silently drop board identity variables, Discord state scoping, and startup dialog handling, leaving peers that look healthy but cannot write or connect. ## Core Features & Use Cases - Four respawn modes: missing fills gaps after a reboot, plugin cycles sessions lacking the fleet plugin, all resets the whole registry, and running cycles every live session at its own cwd after a /login account switch. - Identity and state preservation: passes CW_AGENT_NAME/FEEDBACK_AGENT_NAME and per-peer DISCORD_STATE_DIR via tmux -e flags, resumes transcripts with --continue, and auto-dismisses startup dialogs. - Team-lead self-respawn: self-respawn.sh cycles the team-lead's own session using a detached, sentinel-armed revival job that aborts safely if the respawn path fails to arm. - Use Case: After switching Claude accounts with /login, run python3 respawn.py --mode running --execute to cycle every live session onto the new account's MCP handshakes without losing worktree transcripts. ## Quick Start Ask the team lead to respawn your sessions, for example say "respawn all agents" or run a dry-run of respawn.py first and then rerun it with --execute for the mode you need.

Frequently Asked Questions about respawn-sessions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I restart Claude Code sessions after a Mac reboot?▼

Run respawn.py with the default missing mode and --execute. It spawns a detached tmux session only for registry projects with respawn: true that have no claude process running at their path, leaving everything already up untouched.

Which respawn mode should I use after a /login account switch?▼

Use --mode running, not --mode all. The running mode kills and respawns every session that is actually alive at its own cwd, including respawn: false and worktree sessions, so no peer keeps the old account's MCP handshakes.

Why does a respawned session read the board but never post?▼

The session is missing CW_AGENT_NAME, which is passed via tmux new-session -e at spawn time. Hand-rolled tmux commands drop it, making every write fail with author-required. Relaunch through respawn.py with --mode missing --only <name> --execute.

Is respawn.py safe to run by mistake?▼

Yes, it is dry-run by default and only prints what it would kill or spawn. Destructive actions require the explicit --execute flag, and the team-lead's own process is never killed in any mode.

How does the team-lead restart its own session?▼

Run self-respawn.sh with the team-lead's claude PID. It arms a detached revival job via python3 os.setsid(), verifies a sentinel file proving the job is live, and only then kills the old process, aborting safely if arming fails.

Does respawn.py require PyYAML or other Python packages?▼

No external packages are needed. It parses registry.yaml with a minimal regex-based parser using only the Python 3 standard library, plus system tools tmux, ps, and lsof.