cmux
CLAUDE.md604 starsChanged 8 months agoMITView on GitHub
cmux is a pure Bash shell tool that manages git worktree lifecycles for running parallel Claude Code sessions. Each worktree gets its own isolated working directory so multiple Claude agents can work on the same repo simultaneously. Single-file shell tool — all logic lives in cmux.sh (~560 lines), which is sourced into the user's shell (bash/zsh). There is no build step, no dependencies, and no test suite. Function structure: - cmux() — public dispatcher, routes subcommands to _cmux_<cmd> functions -…
The file
We split this CLAUDE.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 43
Always self-test changes to cmux.sh before finishing work.
- Distinctive: line 49
Test thoroughly: check happy paths, error paths, flag combinations, and edge cases (no args, bad input, missing worktrees, etc.).
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What is cmux
cmux is a pure Bash shell tool that manages git worktree lifecycles for running parallel Claude Code sessions. Each worktree gets its own isolated working directory so multiple Claude agents can work on the same repo simultaneously.
Architecture
Single-file shell tool — all logic lives in cmux.sh (~560 lines), which is sourced into the user's shell (bash/zsh). There is no build step, no dependencies, and no test suite.
Function structure:
cmux()— public dispatcher, routes subcommands to_cmux_<cmd>functions_cmux_*()— private functions:_cmux_new,_cmux_start,_cmux_cd,_cmux_ls,_cmux_merge,_cmux_rm,_cmux_rm_all,_cmux_init- Helper functions:
_cmux_repo_root,_cmux_safe_name,_cmux_worktree_dir,_cmux_spinner_start/stop
Key design patterns:
- Idempotent operations (e.g.
cmux newreuses existing worktrees) - Context-aware:
cmux rmandcmux mergewith no args detect the current worktree from$PWD - Branch name sanitization:
feature/foo→feature-foofor directory names - Worktrees live under
.worktrees/<safe-branch-name>/in the repo root
Setup hook system: .cmux/setup is an executable bash script that runs after worktree creation. It handles project-specific init (symlink secrets, install deps, codegen). cmux init uses Claude CLI (claude -p) to auto-generate this hook.
Key files
cmux.sh— the entire applicationinstall.sh— curl-pipe installer that downloads cmux.sh to~/.cmux/and adds source line to shell RC.cmux/setup— project-specific worktree setup hook (committed to repo)examples/setup-node— example setup hook for Node.js projects
Shell conventions
- 2-space indentation
- Functions prefixed
_cmux_for internal,cmuxfor public - Zsh compatibility: uses
setopt localoptions nomonitorwhere needed for job control - Error handling: validate inputs, check
command -v, guard with|| return 1 - No
set -ein cmux.sh (it's sourced, not executed); install.sh usesset -e
QA — mandatory before considering any task done
Always self-test changes to cmux.sh before finishing work. Source the file in a bash subshell and run the affected commands to verify correct output and behavior:
bash -c 'source /path/to/cmux.sh && cmux <subcommand> [args]'Test thoroughly: check happy paths, error paths, flag combinations, and edge cases (no args, bad input, missing worktrees, etc.). Do not consider a task complete until you have verified the changes work.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

