cmux-and-worktrees
Original:🇺🇸 English
Translated
Manage parallel development with cmux-style git worktrees in one repository. Use this skill whenever the user asks to run multiple agents in parallel, create or resume isolated worktrees, list/switch/merge/remove worktrees, set up `.cmux/setup`, or recover from worktree conflicts. In this environment, always use the `cmx` alias in commands.
3installs
Added on
NPX Install
npx skill4agent add psycho-baller/ai-agents-config cmux-and-worktreesTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →CMX and Worktrees
Run concurrent coding sessions safely by isolating each task in a git worktree.
Non-Negotiable Command Rule
- Use for every command in this skill.
cmx - Do not substitute in normal operation.
cmux - If fails, check alias availability with
cmxbefore taking any fallback action.type cmx
Preflight
- Verify current directory is inside a git repo:
bash
git rev-parse --is-inside-work-tree- Verify is available:
cmx
bash
type cmx- Ensure worktrees are ignored in git:
bash
rg -n '^\.worktrees/$' .gitignore || echo '.worktrees/' >> .gitignore- Inspect active worktrees:
bash
cmx lsCore Commands
- Create new isolated task:
cmx new <branch> - Resume existing task:
cmx start <branch> - Jump to worktree:
cmx cd [branch] - List worktrees:
cmx ls - Merge into primary checkout:
cmx merge [branch] [--squash] - Remove worktree + branch:
cmx rm [branch | --all] [--force] - Generate setup hook:
cmx init [--replace] - Show/set layout config: ,
cmx configcmx config set layout <nested|outer-nested|sibling> [--global] - Update tool:
cmx update - Show version:
cmx version
Standard Workflow
- Start feature work:
bash
cmx new feature-auth- Start urgent fix in parallel:
bash
cmx new fix-payments- Merge and clean up bugfix:
bash
cmx merge fix-payments --squash
git commit -m "fix(payments): resolve checkout bug"
cmx rm fix-payments- Resume feature:
bash
cmx start feature-authSetup Hook Workflow
- Generate a project-specific setup hook:
bash
cmx init- If needed, regenerate:
bash
cmx init --replace- Commit so future worktrees inherit setup automatically.
.cmux/setup
Branch and Path Behavior
- Treat as "new branch + new worktree".
new - Treat as "reuse existing worktree/session".
start - Expect worktree paths under in nested layout.
.worktrees/<branch>/ - Expect branch sanitization (e.g., becomes
feature/foopath name).feature-foo
Safety Rules
- Ask for confirmation before .
cmx rm --all - Ask for confirmation before .
cmx rm --force - Prefer for compact history unless user requests full merge commits.
cmx merge <branch> --squash - Ensure worktree changes are committed before merging.
- Remove finished worktrees after successful merge to reduce branch/worktree drift.
Troubleshooting
- : move to repo root, then rerun.
Not in a git repo - : run
Worktree not found, then choose correct branch or create withcmx ls.cmx new <branch> - Merge blocked by uncommitted changes: commit or stash inside the worktree, then retry.
- Remove blocked by dirty tree: clean state first, or use only with explicit confirmation.
cmx rm --force