The problem: a Claude Code session that opens another session in a new terminal tab usually grabs the keyboard, so whatever you were typing lands in the new session.

The code

One bash script and a Claude Code skill. To start a session in a repo with its first task:

~/.claude/scripts/launch-session.sh ~/GitHub/api "Read AI.md, then fix issue 42 and run the tests"

With --agent, each session gets its own name, which an optional hook maps onto an agent bridge identity:

~/.claude/scripts/launch-session.sh --agent api-lane-a ~/GitHub/api "Pick up ISSUE-42"

How it works

  • A new tab, focus kept. It opens a tab in the terminal you are already in and hands focus back: on macOS it re-selects your iTerm2 tab, on Linux tmux and kitty open in the background, and on Windows Terminal the previous window is restored (not yet tested on real hardware).
  • Detached when it must be. If the screen is locked or there is no desktop, it starts the session in GNU screen or tmux instead, and logs it so you can attach later.
  • Headless on request. --background runs claude -p with the prompt.
  • Safe prompts. The first prompt travels in a generated runner file, never on the terminal’s command line, so quotes and newlines survive on every platform.

ClaudeDeck’s spawn command uses it. Install steps are in the gist.

View the source

⌃