← Catalog

pi-branch-out

Fork the current Pi session into a split terminal pane or new tab with rotating layout policies, and with optional model and message queuing, and support for cmux, tmux, iTerm2, Terminal.app, Ghostty, Warp, and Orca.

Package

Install

Install with PiG

pig install npm:pi-branch-out

Install with Pi

pi install npm:pi-branch-out
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "extensions/branch-out/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.10 (README.md). PiG does not review it.

branch-out for Pi (pi-branch-out)

Fork the current Pi session into a split terminal pane or new tab with rotating layout policies, and with optional model and message queuing. Routing, split geometry, and focus behavior are config-driven. Inside Orca, the fork opens as a new pane in the current terminal tab and worktree.

Install

pi install npm:pi-branch-out

From the dot314 git bundle (filtered install):

{
  "packages": [
    {
      "source": "git:github.com/w-winter/dot314",
      "extensions": ["extensions/branch-out/index.ts"],
      "skills": [],
      "themes": [],
      "prompts": []
    }
  ]
}

After installing, copy extensions/branch-out/config.json.example to extensions/branch-out/config.json and adjust to taste.

Command

/branch [--model <query>] [message]

Both arguments are optional and independent.

/branch works while the parent is responding or running tools. The child starts with the entries on the parent's active path when you run the command, even if the session file is behind. An unfinished streamed response and later tool results are not included. The parent continues its turn.

  • --model <query> — target model for the child session. Accepts a fully qualified provider/model-id or a fuzzy query scoped to the current provider. If the query does not resolve safely the child keeps the parent's model.
  • message — prefilled text in the child session's editor with a 10-second auto-submit countdown. Typing anything or pressing Esc cancels the countdown; Enter sends immediately.

Config

Config lives in extensions/branch-out/config.json next to the extension.

{
  "launchMode": "split",
  "splitDirection": "right",
  "preserveFocus": true
}

launchMode

ValueBehavior
"split"Open in a new split pane inside the current window (default)
"tab"Open in a new tab / surface

splitDirection

Accepts a single value or a comma-separated fallback list. The first entry supported by the active backend is used; if none match, right is the final default.

"splitDirection": "counterclockwise,right"

This is useful when splitDirection is a rotating policy (unsupported by iTerm2). The fallback right kicks in automatically on that backend.

Static directions
ValueEffect
"right"Split to the right of the current pane
"down"Split below the current pane
"left"Split to the left of the current pane
"up"Split above the current pane
Rotating layout policies (cmux and tmux only)

clockwise and counterclockwise are stateful layout policies. On the first /branch call the current pane is split in the policy's initial direction. On each subsequent call the policy picks the next queued managed leaf and splits it in that leaf's assigned direction, building a balanced recursive tree rather than a linear stack.

ValuePattern
"clockwise"First split right → children split up/down → grandchildren split right/left → …
"counterclockwise"First split right → children split down/up → grandchildren split left/right → …

State is persisted per backend and workspace key in /tmp/pi-branch-out-layout-state.json. Stale entries are pruned against live pane/surface lists on each call. To reset the policy entirely:

rm /tmp/pi-branch-out-layout-state.json

preserveFocus

ValueBehavior
trueFocus stays in the pane that ran /branch (default)
falseFocus moves to the newly created pane

Terminal backend routing

Routing is automatic and tried in this order:

  1. --branch-out-terminal flag override (always wins)
  2. Orca — detected via ORCA_WORKTREE_ID and either ORCA_TERMINAL_HANDLE or ORCA_PANE_KEY
  3. cmux — detected via CMUX_SOCKET_PATH
  4. tmux — detected via TMUX
  5. iTerm2 — detected via TERM_PROGRAM=iTerm.app
  6. Terminal.app — detected via TERM_PROGRAM=Apple_Terminal
  7. Ghostty — detected via GHOSTTY_RESOURCES_DIR or TERM_PROGRAM containing ghostty
  8. Warp — detected via TERM_PROGRAM=WarpTerminal

If no backend is detected, macOS tries iTerm2 and Terminal.app before falling back to an Alacritty window; other platforms fall back to Alacritty. These fallbacks require launchMode: "tab".

The Orca backend opens the fork beside the terminal that ran /branch and uses Pi's current working directory. Direction values describe the desired placement: right creates a left/right split (Orca vertical), while down creates a top/bottom split (Orca horizontal). Orca requires launchMode: "split".

The Warp backend opens the fork in a new tab in Warp's active window and uses Pi's current working directory. It works with Warp Stable on macOS and Linux when Pi runs on the same machine as Warp, not in an SSH session. It requires launchMode: "tab"; for splits inside Warp, run Pi in tmux with launchMode: "split". Each launch writes a temporary Tab Config named tmp_pi_branch_*.toml, which the new tab deletes as it starts. If a launch never opens a tab, delete the leftover file from ~/.warp/tab_configs/ on macOS or ${XDG_DATA_HOME:-$HOME/.local/share}/warp-terminal/tab_configs/ on Linux.

Backend capability matrix

Backendtabsplit — static directionssplit — rotating policies
Orca—right downDefaults to right
cmux✓left right up downclockwise counterclockwise
tmux✓left right up downclockwise counterclockwise
iTerm2✓right down— (use fallback list)
Terminal.app✓— (error)— (error)
Ghostty— (new window)— (error)— (error)
Warp✓— (error)— (error)

Backends without a default for the requested splitDirection fail fast with an explicit error. Use a comma-separated preference list to select a supported direction across backends (e.g. "counterclockwise,right").

Examples

/branch

Fork current session and open in a new pane/tab using config defaults.

/branch explore the auth edge cases

Fork with a queued message. The child session opens with "explore the auth edge cases" prefilled in the editor and a 10-second auto-submit countdown.

/branch --model flash

Fork using a fuzzy model query. If the current provider is Anthropic, flash would resolve to the closest Gemini Flash match available; if unresolvable the child keeps the parent's model.

/branch --model gemini/flash-2.5 try rewriting the parser without recursion

Fork with both a target model and a queued message.

Upstream credit

An earlier version of this extension began as an iteration on davidgasquez's branch-term.ts, MIT license.