A Bun/TypeScript CLI that launches multiple AI CLIs in a tmux window with per-pane or global prompts. Works both inside and outside tmux and keeps panes open on exit.
- tmux 3.x+
- Bun 1.3+ (or Node if you swap the shebang)
bun install # for type hints only
chmod +x tmux-ai.ts # make the script directly runnable./tmux-ai.ts [options] # run directly with Bun shebang
bun run tmux-ai.ts -- [options] # or via Bun
bun run tmux-ai -- [options] # package script helperKey flags:
-t, --tool <spec>repeatable tool command (cmdorcmd=prompt)-p, --prompt <text>global prompt applied to panes without their own-s, --session <name>tmux session (defaultai)-w, --window <name>tmux window (defaultbots)-l, --layout <layout>tmux layout (defaulttiled)--no-attachor--attachcontrol attaching when outside tmux--debugecho tmux commands
Initial prompts are passed in the tool invocations (not after launch): ca/claude/codex/droid use a positional prompt, copilot uses -p <prompt>, and gemini uses --prompt-interactive <prompt> so it continues interactively after the first turn.
Behavior:
- Inside tmux: creates a new window in the current session and never attaches.
- Outside tmux: reuses/creates the session, makes the window, and attaches unless
--no-attach. - Default tools if none are provided:
claude,gemini,ca,copilot,codex,droid.
Default toolset in session ai, window bots:
./tmux-ai.tsCustom tools plus a global prompt:
./tmux-ai.ts -t claude -t "copilot --model gpt-5" -p "You are my coding assistant."Per-pane prompts:
./tmux-ai.ts \
-t "claude=You are a strict code reviewer." \
-t "gemini=Research assistant; prioritize citations." \
-t "copilot --model gpt-5=Help me write and refactor code."Different layout:
./tmux-ai.ts -l main-vertical -t claude -t gemini -t copilotYou can give each AI CLI its own git worktree of the current project and seed them with the same task to compare outputs side by side:
./tmux-ai.ts --worktrees \
-t claude \
-t gemini \
-t "copilot --model gpt-5" \
-p "Add a /users REST API with basic CRUD and tests"When --worktrees (or -T) is set:
tmux-aimust be run inside a git repository.- It finds the repo root with
git rev-parse --show-toplevel. - It creates
<repo>/.worktrees/(if missing) and ensures.worktrees/is in.gitignore. - For each tool, it runs
git worktree add --detach .worktrees/<tool>-Nto create a detached worktree at the current commit. - Each tmux pane runs its tool from its own worktree directory:
cd <repo>/.worktrees/claude-1 && claude "<prompt>".
Tips:
- Use
-p/--promptto give the same task to every CLI. - If you like one agent's changes, you can
git diffin that worktree and copy patches back, or branch there and merge. - Clean up with
git worktree listandgit worktree remove <path>when you’re done.
Suggested alias to mirror your original muxai function:
alias muxai="$HOME/bin/tmux-ai.ts" # adjust path as needed