Run all your AI coding agents (Claude Code, Codex, Cursor, ...) in tmux: jump to the one that needs you, spawn them into worktrees, and hand work between them
When running multiple AI coding agent sessions across tmux panes, it's hard to keep track of which session is idle, which is waiting for permission, and which pane to switch to. ccmux solves this with a background daemon that monitors session activity and an interactive TUI that shows live session states at a glance.
It works with your existing tmux workflow. You don't change how you launch or run your agents; ccmux discovers what's already running in your panes, so as long as you're in tmux with a supported agent, it just works.
Built-in support for: Claude Code, Codex, Cursor, OpenCode, Pi, Antigravity, Copilot, Gemini CLI, plus custom agent definitions via config.
✨ Features
🎯 Live Session States: Every agent tracked as idle, working, or waiting (permission / plan approval / question), flagged the moment one needs you
🧩 Multi-Agent: Claude Code, Codex, Cursor, OpenCode, Pi, Antigravity, Copilot, Gemini CLI, plus custom agents via config
🔄 Real-Time: Background daemon streams state changes instantly over SSE, no polling, no refresh
👁️ Live Preview: Split-pane view of the selected session's pane content
⚡ Act in Place: Tab into the preview to approve, answer, or type, keys go straight to that pane
🔔 Actionable Notifications: Approve, deny, or reply to a waiting agent straight from the desktop notification
🪟 Sidebar Mode: Compact always-visible session rail docked beside your working panes
🔍 Fuzzy Search: Fuzzy-match sessions by project, branch, or path; substring-match any recent prompt, captured pane content, and on-demand live transcripts
📂 Session Grouping: Collapsible project groups with reordering and pinning
🌿 Git & PR Aware: Branch and worktree detection, open PRs with live CI and review status
🌱 Worktree Workflow: Spawn or fork sessions into fresh git worktrees, move uncommitted changes out of a dirty checkout, and prune leftovers from the Worktrees panel
📝 Diff Review: Press d to review a session's working-tree diff with hunk, right in the pane, or D for everything the branch changed since it forked
🤖 Background Agents & Subagents: Claude Code background agents get rows too; running subagents show as agents with a live list in the preview
🎛️ Session Control: Spawn, fork, kill, and restart sessions from the TUI; ccmux invoke for scripted one-shot agent turns
🤝 Session Handoff: Send a session's last response to another agent, from the CLI, the row menu, or agent-to-agent via the bundled relay skill
⌨️ Keyboard-First, Mouse-Friendly: Vim keys and number jumps, plus click-to-switch and right-click context actions
📦 Installation
Prerequisites
tmux with active sessions running AI coding agents
git 2.31 or newer (for branch and worktree detection; ccmux still works without it, just without that info)
git clone https://github.com/epilande/ccmux.git
cd ccmux
bun install
bun link
ccmux setup
ccmux setup installs agent hooks for authoritative session matching. ccmux works without it, but it's recommended; see Session Matching with Hooks. Bare ccmux setup only configures agents whose executable is found on PATH; use ccmux setup --agent to install for a specific agent even if it isn't detected.
Shell Completions
ccmux completion prints a completion script for zsh, bash, or fish. It completes commands and flags, and asks the running daemon for live values: session ids and %pane ids wherever a command takes one, agent names, invocation ids, config keys and their values. Directory flags such as --cwd fall through to the shell's own path completion.
# zsh (~/.zshrc, after compinit)
eval "$(ccmux completion zsh)"
bash (~/.bashrc)
eval "$(ccmux completion bash)"
fish
ccmux completion fish > ~/.config/fish/completions/ccmux.fish
The zsh eval has to come after compinit, since the script registers itself with compdef. A file in fpath sidesteps that and avoids running ccmux at every shell start: ccmux completion zsh > ~/.zfunc/_ccmux with fpath=(~/.zfunc $fpath) before compinit. The Homebrew formula installs completions for all three shells.
🚀 Quick Start
Start your AI coding sessions in tmux panes as usual
Launch the picker:
ccmux
Navigate with j/k, press Enter to switch to a session
[!TIP]
Bind a tmux key so you can pop ccmux open from anywhere (add to ~/.tmux.conf):
>
> # Prefix + C-p: open ccmux in a centered popup
> bind-key C-p display-popup -E -w 80% -h 75% "ccmux"
>
> # Or skip the prefix entirely (Alt+p from any pane)
> bind-key -n M-p display-popup -E -w 80% -h 75% "ccmux"
>
> With the binding above, ccmux works out on its own which terminal opened the popup, so picking a session switches that terminal and leaves any other attached client where it was. The picker exits after selection, so the popup closes itself and drops you straight into that pane. (display-popup needs tmux 3.2+.)
> Hand ccmux the client explicitly if you attach two terminals to the SAME tmux session, since nothing inside the popup can tell them apart, or if your binding opens the popup on a session other than the one the pressing terminal is looking at:
> The run-shell -C wrapper is what makes #{client_tty} expand, since display-popup never expands its own command. The -e "CCMUX_CLIENT_TTY=#{client_tty}" form documented previously still works, on tmux 3.3+.
🎮 Usage
CLI Commands
| Command | Description |
| :------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------- |
| ccmux | Launch interactive TUI picker (default) |
| ccmux picker | Launch TUI with options (--preview, --icons ) |
| ccmux picker --persistent | Dashboard mode (stay open after switching sessions) |
| ccmux spawn [agent] | Spawn a new agent session in a tmux pane |
| ccmux invoke [agent] "prompt" | Run a single agent turn and write the response to stdout (docs) |
| ccmux invoke list | List active and recently-finished invocations (-j for JSON) |
| ccmux invoke cancel | Cancel a running invocation by id (idempotent) |
| ccmux invoke result | Print an invocation's full captured output (subprocess agents only) |
| ccmux show | List all active sessions |
| ccmux show --json | Output sessions as JSON |
| ccmux status | Show daemon and session overview |
| ccmux switch | Switch tmux client to a session's pane |
| ccmux review [id] | Review a session's diff with hunk (defaults to cwd) |
| ccmux kill | Kill a session's process |
| ccmux restart | Kill and resume a session |
| ccmux last | Print a session's last response (--turns , --json) (docs) |
| ccmux handoff [to] | Hand a session's last response to another session (--turns, --note, --spawn, --agent, --cwd) (docs) |
| ccmux send | Send text to a session's tmux pane (multiline pastes as one message; --no-enter skips submit) |
| ccmux send --stdin | Same, reading the text from stdin instead of argv |
| ccmux screen [id] | Capture pane content |
| ccmux screen --grep | Search across all session panes |
| ccmux dismiss | Remove a session from tracking |
| ccmux worktree list | List every worktree of the repos ccmux knows about, plus the one you are in (--repo ) |
| ccmux worktree prune | Remove worktrees whose work is finished (--dry-run, --state, --end-idle, --repo ) |
| ccmux daemon start\|stop\|restart\|status | Manage the background daemon |
| ccmux config set | Set a preference |
| ccmux config get | Get a single preference value |
| ccmux config list | List all preferences |
| ccmux config themes | List built-in themes (marks the active one) |
| ccmux setup | Install hooks for every supported agent found on PATH (Claude + Codex + Cursor + OpenCode + Pi + omp + Antigravity + Copilot) |
| ccmux setup --agent | Limit install/uninstall/status to specific agent(s); forces install even if not found on PATH |
| ccmux setup --status | Report install state without writing anything |
| ccmux setup --uninstall | Remove hooks (preserves user-owned hook entries) |
| ccmux debug | Diagnose session tracking discrepancies |
| ccmux completion | Print the completion script for zsh, bash, or fish (install) |
| ccmux notify [message] | Send a notification via the configured backend (bare: test message + diagnostics) |
| ccmux sidebar | Launch narrow sidebar TUI (no preview/footer) |
| ccmux sidebar --toggle | Smart toggle: spawn/kill sidebars in every window across all tmux sessions |
The daemon starts automatically the first time you run a ccmux command (picker, show, invoke, etc.). It runs on 127.0.0.1:2269 and provides both a REST API and SSE event stream.
Preview Pane
Press P to split the picker and preview the highlighted session's live pane content side by side. Press Tab to focus the preview and act in place: your keystrokes go straight to that agent's pane, so you can approve a permission, answer a question, or type a follow-up without ever leaving ccmux.
The preview header names the session: the project in bold, then the agent's own summary of the session on agents that publish one (Claude Code, Codex, OpenCode, Cursor, oh-my-pi, and Copilot do; on the rest the line is omitted), then the working directory and the branch/version/target metadata.
When the session has agents running, an Agents section lists each one with its runtime. Finished agents drop off the list.
hunk is a terminal diff reviewer. With hunk on your PATH, press d in the picker to review the selected session's working-tree diff without leaving ccmux: the picker suspends, hunk diff --watch takes over the pane in the session's repository root, and the picker resumes when hunk exits. The same action is available from the row menu (m, or right-click). If the working tree has no changes, ccmux reports that instead of opening an empty review.
Shift+D reviews the other diff: everything the checkout has changed since it forked, not just what is uncommitted. That is the question worth asking about an agent working in a worktree, which commits as it goes and often has an empty working tree while the branch is the whole point. The base it compares against is whatever ccmux spawn --worktree recorded when it cut the branch, falling back to the merge-base with the repo's default branch for checkouts ccmux did not create. A checkout carrying no commits of its own beyond that base has no fork point to compare against, so D there shows the working tree, the same as d; a main checkout with unpushed commits does have one, and D shows those too.
To send review feedback back to the agent:
Press c in hunk to annotate a line, then Ctrl+S to save the note.
Add any other review notes and quit hunk.
Confirm Send review comments when the picker resumes. ccmux sends all captured notes, including short source snippets, to the agent as one prompt and stays in the picker so you can watch its status.
The offer relies on hunk's session JSON commands (hunk session list / session comment list). With an older hunk the review itself still works; the offer just doesn't appear.
The reviewHandback preference controls what happens when hunk exits:
confirm (default) asks before sending the prompt.
auto sends and submits the prompt immediately without a dialog.
fill pastes the prompt into the agent's composer without submitting it. The text remains there until you jump to the session and submit or edit it; a later send or invoke may find it prepended.
The review also runs from the CLI:
ccmux review # Review the current directory's repository
ccmux review <id> # Review a session's repository by id
Install hunk with brew install hunk. The d footer hint and help entry appear only when hunk is detected on PATH at launch.
Sidebar Mode
A compact, always-visible session list that lives alongside your working panes. No preview panel, no footer, just status icons and project names.
ccmux sidebar --toggle # Toggle sidebars in all tmux windows
ccmux sidebar --toggle --width 40 # Custom width (default: 30)
ccmux sidebar --toggle --position right # Right side (default: left)
ccmux sidebar --resize --width 30 # Snap every existing sidebar pane to <width>
The smart toggle fills gaps when some windows are missing sidebars, and kills all sidebars when every window already has one. New windows automatically get a sidebar, and sidebars snap back to their configured width when a window is resized.
Configure defaults so --toggle uses your preferred layout:
ccmux config set sidebar.width 40
ccmux config set sidebar.position right
Suggested tmux keybinding (add to ~/.tmux.conf):
bind-key S run-shell "ccmux sidebar --toggle"
Notifications
Desktop notifications on waiting/finished transitions, disabled by default. When a session needs permission, or has a plan waiting for approval, the banner carries Approve / Deny buttons; permission, plan, question, and "finished" notifications also carry an inline Reply field, so you can answer, redirect, or send the next instruction without switching to its pane. Focusing a session's pane clears its notification.
ccmux config set notifications.enabled true
ccmux notify # sends a test notification and prints setup diagnostics
Actionable Approve/Deny buttons work for Claude Code, OpenCode (1.x only), Codex, Cursor, Gemini CLI, Antigravity, Copilot, and oh-my-pi; Pi has no tool-approval pause, so it never raises a waiting notification. OpenCode's buttons are withheld on OpenCode 2, whose permission row turns the 1.x Deny keys into an approval, and on any OpenCode session whose version ccmux could not read, including preview builds that report 0.0.0-*. Inline Reply on waiting-state notifications (permission, plan, question) is Claude Code only; Reply on finished notifications works for every built-in agent. A reply the agent's composer would misread as a command (e.g. leading ! or /) is refused instead of typed, and the text comes back in a follow-up notification so it isn't lost. Approve/Deny work on macOS and Linux; inline reply needs a notification server that advertises it (always on macOS, varies on Linux).
For OpenCode, one server can host several sessions folded into a single row, so when more than one is waiting at once the buttons are withheld (the keystroke could land on the wrong session's dialog) and the notification is delivered informational-only.
macOS: the buttons, ccmux's own name and icon, per-session grouping, and retraction come from a helper app Homebrew installs alongside ccmux, so brew install epilande/tap/ccmux for the full experience. Source installs fall back to osascript (posts as Script Editor, silenced by Focus / Do Not Disturb, no buttons or reply). macOS never shows a permission dialog for a CLI-launched app, so grant it once by hand: run ccmux notify and follow the printed steps (open the settings deep link, find ccmux, enable Allow notifications, set Alert Style to Persistent), then re-run ccmux notify to confirm.
Linux:dbus grouping, click-to-jump, and Approve/Deny are native (no extra binary); inline reply appears only when the server advertises it. A headless daemon (SSH, systemd) needs DBUS_SESSION_BUS_ADDRESS, plus DISPLAY for the notify-send fallback.
Configure further with ccmux config set notifications., or edit ~/.config/ccmux/ccmux.json directly:
backend: "auto" picks ccmux-notifier (else osascript) on macOS, and D-Bus (else notify-send) on Linux. command runs your own shell command with CCMUX_* env set (EVENT, SESSION_ID, AGENT, PROJECT, BRANCH, TITLE, SUBTITLE, BODY, PANE), for ntfy, Pushover, and the like. CCMUX_BODY is the complete text (the event line plus any context), so a script reading only it still gets something meaningful; CCMUX_SUBTITLE is the bare event line on its own for structured consumers.
The osc backend delivers notifications through the terminal stream instead of a desktop API, for daemons running on a remote box; see Remote / SSH.
[!NOTE]
Approve/Deny only send the mapped keystroke to that session's pane (for Claude, the same key you'd press yourself). Approve on a plan picks "manually approve edits" (edits stay gated), never Claude's auto-accept mode. Reply on a permission or plan notification denies the pending tool/plan and sends your text as the next message (it cancels the prompt first, then types). If the session moved on since the notification fired, the press sends nothing and you get a fresh "state changed" notification instead; dismissing a notification never approves anything.
The keystrokes behind the buttons come from a per-agent notificationActions map, overridable per Custom Agents.
Search Mode
Press / to filter the list as you type. ccmux searches several sources at once and highlights why each row matched:
Metadata (project, branch, path) matches fuzzily, so ccmx still finds ccmux.
Recent prompts, captured pane content, and live transcripts match by substring, so a content word matches only where it actually appears.
Prompts come from the daemon's in-memory index, which keeps the most recent prompts per session and is tail-bounded after a daemon restart (only recent prompts are re-read from disk). Transcript search closes that gap: it reads each session's transcript file on demand and covers the full session history, including assistant replies (Claude and Codex).
Three toggles control what gets scanned: searchPaneContent, searchPaneLines, and searchTranscript (see Configuration).
Spawning Sessions
Launch new agent sessions directly from the CLI:
ccmux spawn # Spawn claude (default) in a new tmux window
ccmux spawn codex # Spawn a specific agent
ccmux spawn --split # Split current pane instead of new window
ccmux spawn --split h # Split left/right ('v' is the stacked default)
ccmux spawn --target %12 # Split (or place the window next to) a specific pane
ccmux spawn --detach # Don't switch to the new pane
ccmux spawn --cwd ~/proj # Set working directory
ccmux spawn --resume <id> # Resume an existing session
ccmux spawn --fork <id> # Branch an existing session into a new one
ccmux spawn --prompt "fix the tests" # Send an initial prompt
ccmux spawn --model opus # Start the agent on a model (its own flag, e.g. claude --model)
ccmux spawn --worktree --prompt "fix flicker" # Spawn into a git worktree (name derived from the prompt)
ccmux spawn --worktree fix-flicker # Spawn into a named worktree, creating it if needed
ccmux spawn --worktree --base develop --prompt "fix flicker" # Branch the new worktree from develop
ccmux spawn --worktree fix-flicker --with-changes # Move this checkout's uncommitted work into it
ccmux spawn --worktree fix-flicker --with-changes --untracked copy # Untracked files land in both
ccmux spawn --fork <id> --worktree # Fork into a fresh worktree off the source's branch
ccmux spawn --pr 154 # Check that PR out in a worktree, on its own branch
ccmux spawn --issue 150 # New worktree named after the issue, prompt seeded
Split directions use tmux's own vocabulary: h puts the new pane beside the
old one, v stacks it below. Run inside tmux, ccmux spawn uses the pane you
ran it from, so the new pane or window lands in your session rather than
wherever the daemon happens to consider "current". A new window is appended at
the end of your session, which leaves every existing window index alone; pass
--target to insert one directly after that pane's window instead
(tmux renumbers the windows after it), or --target none to let tmux place it.
--target accepts any pane on the server, including one in a _different_ tmux
session: ccmux creates the pane there and moves your client over to it, the
same jump ccmux switch makes. Pass --detach to leave your view where it is.
That jump needs a client of its own to move, so it only happens when you run
ccmux spawn from inside the session you are attached to; run from outside
tmux, or from a detached session, it creates the pane without switching (use
ccmux switch afterwards).
--prompt starts the agent interactively with the prompt already submitted.
It is supported for the agents whose interactive-with-prompt invocation ccmux
has verified; for anything else (including custom agents) ccmux refuses the
spawn rather than guessing a flag, and you can teach it the right shape with
promptCommand in your agent config.
--model starts the agent on that model, passed through as the agent's
own flag (--model for every built-in, read from each CLI's --help). An
agent with no known flag, including a custom one, refuses the spawn; declare
modelFlag in its config to teach it. OpenCode 2's TUI has no model flag and
exits on --model, so pick its model with /models inside OpenCode. A new
window is named after the worktree when the spawn has one (fix-flicker,
issue-150-..., pr-154-...) and after the agent otherwise, so a batch of
spawns is tellable apart; the name pins tmux's automatic-rename off for that
window.
--worktree [name] spawns the agent into a git worktree at the configured
worktree.path (default: /.claude/worktrees/), creating it first
if it does not exist yet. Worktree paths and names
explains the path template, safety rules, and exclusion behavior.
An explicit name is create-or-open: spawning into the same branch again reuses
its registered worktree, including one created under an earlier path layout.
Without a name, ccmux derives one from --prompt's opening words; a derived
name that collides with an existing worktree gets a numeric suffix (-2,
-3, ...) instead of reusing it, since two different prompts landing in the
same worktree would silently merge unrelated work. --base sets what
the new branch is cut from, defaulting to the main checkout's current branch.
An explicit name whose branch is checked out in the main checkout is refused:
use --cwd to start an agent there, or switch the main checkout to another
branch first. PR and issue reuse may still open the main checkout when it
already holds that source.
When the resolved worktree parent is inside the main checkout, ccmux adds an
exclude for that parent to the hosting repo's .git/info/exclude (the same
file Claude Code writes, local to your clone, never .gitignore). The default
path keeps the exact **/.claude/worktrees/ pattern. Paths outside the main
checkout need no exclusion and leave the file untouched.
Spawning on a PR or an Issue
--pr resolves the pull request with gh, fetches pull//head, and
spawns the agent into a worktree checked out on the PR's own branch, set
up to track it the way gh pr checkout would, including a fork PR, whose
branch is pointed at the fork's clone URL so git push updates the PR instead
of failing. By default its logical name is pr--, which
deliberately never collides with the pr- directories Claude Code creates
for its own fetch-only PR checkouts. worktree.path controls only the
directory; it does not change the PR branch, and the tmux window uses the
logical worktree name rather than a path-derived basename. --base is
refused here: the PR's head is the start point. ccmux records origin/
as the branch's review base, so d in the picker shows the PR's
actual diff.
--issue is an ordinary spawn-from-base worktree whose default logical
name is issue--; --base works as usual. The configured path
affects only the directory. Issue discovery matches the issue- branch
family rather than relying on that configurable path.
Both seed the agent's opening prompt with the title and URL, and your own
--prompt is appended after it. A PR whose branch is already checked out is
opened rather than duplicated; a second --issue of the same number opens the
existing worktree for that issue branch. Both refuse rather than guess: a
PR that is not open, an issue that is closed, and a same-named local branch
that is not that PR (a branch counts as the PR's only when its merge _and_ remote config
both already point at it, so a fork PR cannot ride in on a name collision with
one of your origin-tracking branches). The remote is compared as a repository,
not as text, so a branch you set up yourself with git remote add fork
and git checkout -b fork/ is recognized as the PR's. A local
branch that _is_ the PR is fast-forwarded, never force-updated. If it has
diverged, ccmux leaves it alone and says so.
ccmux fetches the PR from origin, while gh resolves the number through its
own repo selection (gh repo set-default, GH_REPO, a fork clone's upstream).
If those name different repositories, ccmux refuses and names both rather than
checking out a same-numbered PR from the wrong repo.
Moving Uncommitted Changes
--with-changes relocates the checkout's uncommitted work into the worktree
it creates, so the new agent starts on top of it and the checkout you left is
clean:
ccmux spawn --worktree fix-flicker --with-changes
Move changes in a session's context menu does the same thing from the
picker. It only appears for a row whose checkout is actually dirty, and it
opens the new-session dialog already set to move: the destination is locked to
a new worktree, an Untracked row appears, and the name and prompt stay
editable.
The picker holds any outcome that needs your attention until a keypress: a
failure that parked your work in a stash (with the command to get it back), a
move that completed but could not drop its own backup entry, a staged/unstaged
split it could not preserve, or a spawn that failed after the changes had
already moved (naming the worktree they moved into). Only refusals that
changed nothing (a name already taken, nothing to move) are a passing toast,
since the fields to fix them are still in front of you. The sidebar toasts
what a clean move did; the picker jumps straight into the new pane, as it does
for every other spawn.
Untracked files move by default (leaving them behind would strand the work
you are relocating). --untracked copy puts them in both places,
--untracked leave keeps them where they are. Gitignored files are never
moved or copied in any mode; worktree.symlinkDirectories and
.worktreeinclude cover those.
The move is stash-first: your changes are stashed out of the checkout, the
worktree is created, the entry is applied into it, and only then is the entry
dropped. If anything fails before the entry is dropped, your checkout is put
back as it was, and the stash entry holding your work is reported by sha
whether or not the restore succeeded.
Staged and unstaged changes arrive as you left them where git allows it; if
the split cannot be preserved, everything still moves and you are told to
re-run git add.
ccmux refuses to run at all while a merge, rebase, cherry-pick, revert, or
bisect is in progress, and refuses a worktree name that already exists — a
move needs a fresh worktree, because rolling one back would take a checkout
it did not create.
Forking Sessions
Fork starts a second session that continues an existing conversation's
history, in a pane beside the original, and leaves the original running and
untouched. (A source with no pane of its own gets a new window instead.)
F in the picker, or Fork in a session's context menu, opens the
new-session dialog over the row; Enter on it forks straight away, into a pane
beside the source's own. ccmux spawn --fork forks the same way
but places the result like every other ccmux spawn, relative to the pane you
run it from. Either way the new pane is tracked like any other session, with
its own row, state and id.
The fork starts in the source's directory by default. --cwd elsewhere is
honored, since the fork resumes the source's transcript by path rather than by
looking a session id up under the current directory.
--worktree goes one further and creates the destination, so the two sessions
edit their own checkouts instead of one. The worktree is named after the branch
the source is on (-fork, numbered -2, -3 if that name is taken)
and cut from it, so the fork continues on the history its conversation was
written against. Name it yourself with --worktree or pick the ref with
--base. --with-changes is refused on a fork: the original session is still
running in the checkout those changes would be moved out of.
The picker's version of that is the Where row in the dialog F
opens. It starts on This checkout, so an untouched dialog is the plain fork
beside the original; move it to New worktree and a Name row appears,
previewing the -fork the daemon would derive and taking one of your
own instead. A Source row names the conversation being continued;
everything else comes off the row. Where the source is not in a git repository
the choice is locked to its own checkout, since there is nowhere for a linked
one to go.
Fork needs two things, and the picker hides the action when either is missing:
the agent has to declare how it forks (forkCommand), and ccmux has to know
which conversation the pane holds. For most agents that knowledge comes from
hooks, so run ccmux setup if the action isn't offered.
Today Claude Code is the only agent that ships a fork command, because it
is the only one whose behavior when resuming a still-running session has been
verified. Adding another is one config line once you have checked it yourself
(see docs/agent-adapters.md).
Worktrees Panel
After a branch is merged (and auto-deleted on GitHub), three leftovers stay on your machine: the worktree directory, the local branch, and often a tmux pane with a finished agent in it.
W in the picker (or Worktrees on a group header) opens the Worktrees panel: every worktree of every repo in scope, main checkout first, with its branch, ahead/behind, uncommitted counts, open PR, and the agent living in it. Enter jumps to that agent, or starts one in a worktree that has none. Tab widens from the selected row's repo to all of them, y copies a path, and d reviews what the branch changed since it left its base (not just what is uncommitted, which is what d on a session row shows).
The panel has a second view: l switches to Pull Requests, every open PR of the repos in scope, with its branch, author, review state and checks, and the worktree it is already checked out in where there is one. Enter there cuts a worktree from the PR (or jumps to the agent already in it), o opens it on GitHub, and h goes back to the worktrees. The two axes are independent: Tab still scopes either view to one repo or all of them, and the tab line under the title names both views with the live PR count.
N in the picker (or n inside the Worktrees panel) opens the source picker: every open pull request and every open issue of the repos in scope, in one list, with the worktree that already holds each one where there is one. / filters across both at once, so a word you remember finds it whether it was filed as a PR or as an issue, and the section counts follow what you type. Enter starts work on the row: it cuts a worktree from a PR's head, or one named after an issue and seeded with it, and where a checkout already exists it goes there instead of starting a second agent in the same tree.
The panel loads in two passes: the list paints immediately from local git state, then the prune classification (which fetches and asks GitHub) merges in and sinks the finished worktrees to the bottom of their group. Those, and only those, become selectable for removal, showing why each one is removable. Space selects a row, and x removes what you selected after a confirmation that spells out what goes with it; on a single clean removable row, x with nothing selected takes that row. ccmux worktree prune runs the same classification from the command line:
| Reason | Meaning |
| :--------------- | :--------------------------------------------------------------------- |
| PR merged | GitHub says the branch's PR was merged (survives squash/rebase merges) |
| merged locally | The branch tip is an ancestor of the default branch |
| upstream gone | The branch had an upstream and it's gone after a fetch --prune |
| PR closed | The PR was closed without merging; the branch is kept |
A worktree an agent is working or waiting in is never offered. One whose only occupant is an idle agent is offered when GitHub reports its branch's PR merged, as an explicit opt-in: the panel labels the row, and the CLI needs --end-idle. Removing a worktree stops its agent (SIGTERM, escalating to SIGKILL if it does not exit) and closes its pane before the directory goes; the agent's transcript is its own file and survives the removal, though agents that resume by directory rather than by session id (opencode --continue, pi -c, omp -c) lose the way back to it once the worktree is gone. Removal then deletes the directory, attempts to delete the local branch, prunes git's metadata, and drops the directory's entry from ~/.claude.json. A worktree whose agent still won't die even after SIGKILL is refused rather than deleted, so nothing is removed out from under a process that may still be writing to it. Branch deletion follows the evidence rather than the reason: a merged PR is force-deleted (git branch -D, since a squash merge leaves the tip unmerged by git's definition), merged locally and upstream gone use the safe git branch -d and report a refusal if git says the branch still holds unmerged work, and PR closed keeps the branch entirely.
Safety rules, in short: a worktree with a working or waiting agent is never offered and an idle one is offered only on a merged PR and only behind an explicit opt-in (--end-idle in the CLI, the labeled row in the panel), a branch still sitting on a base's tip is never classified as merged, a worktree whose PR state cannot be established (gh missing, logged out, offline, or pointed at a host it does not recognize) is skipped with the reason shown rather than treated as having no PR, nothing is pre-selected, dirty worktrees (uncommitted or untracked changes) need their own D opt-in on top of being selected and are re-checked immediately before deletion, a pane still working inside the worktree when the removal runs blocks that one removal (an editor counts as work; a bare shell left sitting there does not, and neither does a ccmux picker or sidebar), a worktree.symlinkDirectories symlink does not count as dirty (it is setup, not your work), gitignored files that would be deleted are surfaced before you confirm (the CLI lists them, the picker shows a count with up to two names on the row), and the main checkout is never a candidate.
Each directory is renamed to a .ccmux-trash-- sibling before being deleted, so the path frees immediately and the contents survive for the length of the run. If ccmux is interrupted mid-run, look for that directory next to where the worktree was: mv .ccmux-trash-- restores it, and git worktree repair re-links it to the repo.
ccmux worktree prune # Interactive confirm list
ccmux worktree prune --dry-run # Show what would go, change nothing
ccmux worktree prune --state # Also drop agent state entries (see below)
ccmux worktree prune --end-idle # Also offer worktrees whose only agent is idle
ccmux worktree prune --repo ~/p # Limit to one repository
--state removes ~/.claude.json entries for any recorded directory that does not exist right now, not only former worktrees, so an ordinary repo you have not checked out will be dropped too. Entries whose parent directory is also missing are skipped, which keeps an unmounted external drive or a disconnected network share from taking every project on it with them. The removed paths are printed, and the file is copied to ~/.claude.json.ccmux-backup-- first (the newest three are kept).
There is no --yes and no automatic mode; removals are always confirmed interactively. --dry-run changes nothing on disk, though it still runs git fetch --prune per repo, which is what makes the upstream gone signal visible and does update remote-tracking refs.
Programmatic Invocation
ccmux invoke runs a single agent turn and writes the response to stdout, so you can use real agents in shell pipelines and scripts. See docs/invoke.md for the full reference.
ccmux invoke claude "say hi in one word"
echo "what is 2 + 2" | ccmux invoke claude
git diff main | ccmux invoke claude "Review this diff"
Claude runs interactively in a dedicated tmux session and returns clean text parsed from the transcript JSONL. Codex, Cursor, OpenCode, Pi, oh-my-pi, Antigravity, Copilot, and Gemini run as non-interactive subprocesses (codex exec -o, cursor-agent --print, opencode run --format json, pi -p, omp -p, agy -p, copilot -p --allow-all-tools, gemini -p) and return the agent's clean response text.
For orchestration, name an invocation with --id , then use ccmux invoke list, ccmux invoke cancel , and ccmux invoke result to watch, cancel, or read its full captured output by that id. See docs/invoke.md for the fire-and-poll reference.
Reading and Handing Off Between Sessions
ccmux last prints a session's last response; ccmux handoff moves it into another session without the text passing through whoever ran the command. See docs/handoff.md for the full reference.
ccmux last codex # print the last response, pipeable
ccmux last codex --turns 3 # widen to the last three exchanges
ccmux last <id> | pbcopy
ccmux handoff codex claude --note "this is the failing test, take it from here"
ccmux handoff self codex # an agent handing off its own conclusion
ccmux handoff self --spawn # ...into a session that does not exist yet
Both take a session reference, not just an id: a session id, %pane, session:window.pane, self, an agent type, or a project name. Fuzzy references are scoped by where you are sitting (same window, then same tmux session, then everything), and an ambiguous one is refused with the candidate list rather than guessed at.
A handoff arrives with a provenance header naming the source session, agent, directory, branch, and time, and is only ever typed into an idle composer: a target that is mid-turn gets it queued and delivered when the turn ends, and a target with a pending prompt is refused.
In the picker, the row menu's Copy opens a small dialog asking how much to take: it starts on the last response, so Enter copies that straight to your clipboard, while j/k or a digit counts up to 20 turns (which brings your own prompts along, formatted exactly as ccmux last prints them). Hand off starts a pick-target mode: the session list itself becomes the target picker, j/k move, and Enter (or a click) opens a dialog asking how many turns to send and offering a one-line note for the receiving agent. Enter there sends and Esc cancels the whole handoff. A queued handoff shows a ⇄ badge on the target row until it lands.
Agent Skills
This repo ships two Agent Skills for your coding agent: dispatch teaches it to orchestrate other agents through ccmux invoke (firing, fan-out, joining, cancelling, and reading worker output), and relay teaches it to read a peer session's output with ccmux last and move it into another session with ccmux handoff. For Claude Code they install together as one plugin (this repo doubles as a plugin marketplace):
Other skills-capable agents (Codex, Cursor, OpenCode, and others) can use the same skills by copying them into their skills directory. Both are additive glue for the ccmux CLI, which must be installed and on your PATH. See plugins/ccmux/README.md for details.