Parallel Claude Code execution with isolated git worktrees
claude-mux enables you to run multiple Claude Code sessions in parallel without conflicts. Each session gets its own isolated git worktree and branch, allowing you to:
- π― Run multiple AI coding tasks simultaneously - No more waiting for one task to finish
- π Compare different approaches - Try multiple solutions in parallel
- π‘οΈ Isolate experiments - Each session is completely isolated from others
- π Easy cleanup - Remove worktrees when done, or keep them for review
- π¦ Zero dependencies - Just needs git (which you already have)
# Start a refactoring task
$ claude-mux new refactor-auth
π³ Creating worktree: refactor-auth-abc123
β
Worktree created at: .claude-mux/refactor-auth-abc123
πΏ Branch: claude-mux-main-refactor-auth-abc123
π Launching Claude Code...
# In another terminal, start a different task
$ claude-mux new add-tests
π³ Creating worktree: add-tests-def456
β
Worktree created at: .claude-mux/add-tests-def456
πΏ Branch: claude-mux-main-add-tests-def456
π Launching Claude Code...
# View active sessions
$ claude-mux list
Active Claude worktrees:
claude-mux-main-refactor-auth-abc123
Path: /project/.claude-mux/refactor-auth-abc123
Status: active
claude-mux-main-add-tests-def456
Path: /project/.claude-mux/add-tests-def456
Status: activego install github.com/enriikke/claude-mux/cmd/claude-mux@latestDownload the latest release for your platform from the releases page.
# Linux/macOS
curl -L https://github.com/enriikke/claude-mux/releases/latest/download/claude-mux_$(uname -s)_$(uname -m).tar.gz | tar xz
sudo mv claude-mux /usr/local/bin/
# Or wget
wget -qO- https://github.com/enriikke/claude-mux/releases/latest/download/claude-mux_$(uname -s)_$(uname -m).tar.gz | tar xzgit clone https://github.com/enriikke/claude-mux.git
cd claude-mux
go build -o claude-mux ./cmd/claude-mux
sudo mv claude-mux /usr/local/bin/- Git - Required for worktree management
- Claude Code - Install from Anthropic
Add the claude-mux directory to your project's .gitignore:
echo ".claude-mux/" >> .gitignoreThis prevents worktree directories from being tracked in your repository.
# Create a new Claude session with auto-generated name
claude-mux new
# Create a named session
claude-mux new refactor-auth
# List active worktrees
claude-mux list
# Remove a specific worktree
claude-mux remove refactor-auth
# Remove all Claude worktrees
claude-mux prune
# Auto-cleanup after session ends
claude-mux new --cleanup my-taskclaude-mux [command] [flags]
Commands:
new Create a new Claude session with isolated worktree
list List active Claude worktrees
remove Remove a Claude worktree and its branch
prune Remove all Claude worktrees
Flags:
--base-path string Base path for worktrees (default ".claude-mux")
--claude-cmd string Claude Code command (default "claude")
-v, --verbose Enable verbose output
-h, --help Help for claude-mux
--version Version information
New Command Flags:
-c, --cleanup Auto-cleanup worktree after Claude exits
Remove Command Flags:
-f, --force Force removal even if branch has unmerged changes# Use custom worktree location
claude-mux new --base-path /tmp/claude-sessions task1
# Use different Claude command
claude-mux new --claude-cmd "claude-dev" experiment
# Verbose output for debugging
claude-mux new -v debug-task- Validates that you're in a git repository
- Creates a new git worktree with a unique branch name
- Launches Claude Code in the isolated worktree directory
- Preserves or cleans up the worktree based on your preference
Each worktree is completely isolated, allowing multiple Claude instances to edit code without conflicts. When you're done, you can merge the best solutions back to your main branch.
# Clone the repository
git clone https://github.com/enriikke/claude-mux.git
cd claude-mux
# Install dependencies
go mod download
# Build
go build -o claude-mux ./cmd/claude-mux
# Run tests
go test ./...
# Run with race detector
go test -race ./...
# Run linter
golangci-lint run
# Build for all platforms
goreleaser build --snapshot --cleanclaude-mux/
βββ cmd/claude-mux/ # Entry point
βββ internal/ # Private packages
β βββ git/ # Git operations
β βββ worktree/ # Worktree management
β βββ config/ # Configuration
βββ pkg/ # Public packages (future)
Contributions are welcome! Please read CONTRIBUTING.md for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Basic worktree creation and management
- Named sessions support
- Auto-cleanup option
- Session persistence and switching (Phase 1)
- Process management for attach/detach
- Container isolation support (Phase 2)
- Session templates and presets
- Integration with other AI tools
Q: What happens to my changes after Claude exits?
A: By default, worktrees are preserved so you can review and merge changes. Use --cleanup to auto-remove.
Q: Can I run this in a repo with uncommitted changes? A: Yes! Worktrees branch from your current HEAD, uncommitted changes stay in your main working directory.
Q: How do I merge changes from a worktree?
A: Use standard git commands: git merge claude-mux-main-task-abc123 or cherry-pick specific commits.
Q: Does this work with Claude Code's MCP servers? A: Yes! Each Claude instance runs normally with full MCP support.
MIT License - see LICENSE file for details.
- Inspired by tmux's session management
- Built for the Claude Code community
- Thanks to all contributors!
Made with β€οΈ for parallel AI coding