Open the Claude Code session you are in a second time, in another terminal. The new session starts with a copy of the conversation so far, then goes its own way: neither side sees what the other does next.
Useful when a session is about to take a turn you are not sure about. Spawn it, try the risky path in the new window, keep the original intact.
Claude Code already knows how to split a conversation: /branch moves you into the copy,
/fork runs the copy as a background session in its own git worktree. Both leave you
with one terminal in front of you. /spawn makes the same split, but the copy opens in a
terminal of its own and you can type in either.
| Where the copy runs | Where you are left | |
|---|---|---|
/branch |
in place of the original | in the copy |
/fork |
background session, own worktree | in the original |
/spawn |
a second terminal window | in the original, copy beside |
One consequence to keep in mind: /spawn sets up no worktree. Both sessions work in the
same directory, so keeping two Claude Codes off the same files is up to you.
- Linux, with a terminal emulator or tmux
- Claude Code
python3, for/spawnsonly
/plugin marketplace add https://github.com/nd-/claude-spawn.git
/plugin install claude-spawn@claude-spawn
From a local clone, with an absolute path or one starting with ./:
/plugin marketplace add ~/code/claude-spawn
/plugin install claude-spawn@claude-spawn
Opens the second session. Where it lands depends on the machine, checked in this order:
$CLAUDE_SPAWN_TERMINAL, when you have set it- a tmux window, when the session runs under tmux, which is also what makes this work over SSH
$TERMINAL, then the first terminal emulator found inPATH
The window opens in the current working directory, detached, and with this session's
CLAUDE_* variables cleared so the new Claude Code does not mistake itself for a child
process. It prints one line naming the terminal it used and the session the copy was
forked from, so a window that never came is not mistaken for a quiet success.
The copy replays the conversation up to and including the /spawn that opened it, which
puts a fresh-looking invitation to run it again in front of you. Doing so forks the fork,
and a handful of windows later nothing tells them apart. /spawns prints the tree if you
need to untangle one after the fact.
Terminals it knows how to drive: ptyxis, gnome-terminal, kgx, konsole, kitty, ghostty,
alacritty, wezterm, foot, xfce4-terminal, tilix, terminator, blackbox-terminal,
x-terminal-emulator, xterm. Anything else is tried with the usual -e convention, so
naming an unlisted one usually works:
export CLAUDE_SPAWN_TERMINAL=stSet it to tmux to always open a tmux window instead of a new one.
Lists what came out of what:
/home/you/code/project
8f3c1a2b refactor-payment-flow
142 msg, last active 03 Mar 18:04, on main
└─ b91d77e0 try-stripe-webhooks
58 msg, last active 03 Mar 21:37, on webhooks
--all covers every project instead of the current one, --json prints the same data
for a script to read.
Claude Code records no link between a session and the one it came from, so /spawns
rebuilds it from the transcripts in ~/.claude/projects: messages copied into the new
session keep the id of the session they were originally written in. Transcripts older
than that field are matched on their shared opening messages instead, which shows that
two sessions are related without saying which came first. Those appear as
origin inferred.
A session shows up only once it has received a first message. A window you opened and never typed into was never recorded.
Print the command instead of running it:
CLAUDE_SPAWN_DRY_RUN=1 ./scripts/spawn.shNo display and no tmux means nowhere to open a window: start Claude Code under tmux and
/spawn will use a tmux window.
Two windows instead of one, on Ptyxis. Not the spawn: Ptyxis restores the windows of
its previous session when it starts from cold, and /spawn is what wakes it up. The extra
window holds a plain login shell, in whatever directory that earlier session was in. It
never happens while a Ptyxis window is already open, which is what makes it look random.
gsettings get org.gnome.Ptyxis restore-session # true means it will
gsettings set org.gnome.Ptyxis restore-session falseOther terminals with a session-restore setting behave the same way.
Inspired by claude-branch, which does the macOS side of the same idea.
MIT