workmux 0.1.5

An opinionated workflow tool that orchestrates git worktrees and tmux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# workmux

**Git worktrees + tmux windows**

Giga opinionated zero-friction workflow tool that orchestrates git worktrees and
tmux windows to create isolated development environments.

Perfect for running multiple AI agents in parallel without conflict.

## Philosophy

- **One worktree, one tmux window**: Each git worktree gets its own dedicated,
  pre-configured tmux window
- **Frictionless**: Multi-step workflows reduced to simple commands
- **Configuration as code**: Define your tmux layout and setup steps in
  `.workmux.yaml`

## Features

- Create git worktrees with matching tmux windows in a single command (`add`)
- Automatically set up your preferred pane layout (editor, shell, watchers,
  etc.)
- Run post-creation hooks (install dependencies, setup database, etc.)
- Copy or symlink configuration files (`.env`, `node_modules`) into new
  worktrees
- Merge branches and clean up everything (worktree, tmux window, branches) in
  one command (`merge`)
- List all worktrees with their tmux and merge status
- Bootstrap projects with an initial configuration file (`init`)
- Dynamic shell completions for branch names

## Installation

```bash
cargo install workmux
```

## Quick start

1. **Initialize configuration (optional)**:

```bash
workmux init
```

This creates a `.workmux.yaml` file to customize your workflow (pane layouts,
setup commands, file operations, etc.). workmux works out of the box with
sensible defaults, so this step is optional.

2. **Create a new worktree and tmux window**:

```bash
workmux add new-feature
```

This will:

- Create a git worktree at
  `<project_root>/../<project_name>__worktrees/new-feature`
- Create a tmux window named `new-feature`
- Automatically switch your tmux client to the new window

3. **When done, merge and clean up**:

```bash
# Run in the worktree window
workmux merge
```

Merges your branch into main and cleans up everything (tmux window, worktree,
and local branch).

## Configuration

workmux uses a two-level configuration system:

- **Global** (`~/.config/workmux/config.yaml`): Personal defaults for all
  projects
- **Project** (`.workmux.yaml`): Project-specific overrides

Project settings override global settings. For `post_create` and file operation
lists (`files.copy`, `files.symlink`), you can use `"<global>"` to include
global values alongside project-specific ones. Other settings like `panes` are
replaced entirely when defined in the project config.

### Global configuration example

`~/.config/workmux/config.yaml`:

```yaml
window_prefix: wm-
panes:
  - command: nvim .
    focus: true
  - command: clear
    split: horizontal
post_create:
  - mise install
files:
  symlink:
    - node_modules
```

### Project configuration example

`.workmux.yaml`:

```yaml
post_create:
  - '<global>'
  - pnpm install

files:
  symlink:
    - '<global>'  # Include global symlinks (node_modules)
    - .pnpm-store  # Add project-specific symlink

panes:
  - command: claude
    focus: true
  - command: pnpm run dev
    split: horizontal
```

### Configuration options

- `main_branch`: Branch to merge into (optional, auto-detected from remote or
  checks for `main`/`master`)
- `worktree_dir`: Custom directory for worktrees (absolute or relative to repo
  root)
- `window_prefix`: Prefix for tmux window names (default: `wm-`)
- `panes`: Array of pane configurations
  - `command`: Command to run in the pane
  - `focus`: Whether this pane should receive focus (default: false)
  - `split`: How to split from previous pane (`horizontal` or `vertical`)
- `post_create`: Commands to run after worktree creation (in the new worktree
  directory)
- `files`: File operations to perform on worktree creation
  - `copy`: List of glob patterns for files to copy
  - `symlink`: List of glob patterns for files/directories to symlink

**Default behavior:**

- Worktrees are created in `<project>__worktrees` as a sibling directory to your
  project by default
- If no `panes` configuration is defined, workmux provides sensible defaults:
  - For projects with a `CLAUDE.md` file: Opens `claude` in the first pane
  - For all other projects: Opens your default shell (`$SHELL`)
  - Both configurations include a second pane split horizontally

### Shell alias (recommended)

For faster typing, alias `workmux` to `wm`:

```bash
alias wm='workmux'
```

## Commands

- [`add`]#workmux-add-branch-name - Create a new worktree and tmux window
- [`merge`]#workmux-merge-branch-name - Merge a branch and clean up everything
- [`remove`]#workmux-remove-branch-name - Remove a worktree without merging
- [`list`]#workmux-list - List all worktrees with status
- [`init`]#workmux-init - Generate configuration file
- [`open`]#workmux-open-branch-name - Open a tmux window for an existing
  worktree
- [`claude prune`]#workmux-claude-prune - Clean up stale Claude Code entries
- [`completions`]#workmux-completions-shell - Generate shell completions

### `workmux add <branch-name>`

Creates a new git worktree with a matching tmux window and switches you to it
immediately. If the branch doesn't exist, it will be created automatically.

- `<branch-name>`: Name of the branch to create or switch to.

**What happens:**

1. Creates a git worktree at
   `<project_root>/../<project_name>__worktrees/<branch-name>`
2. Creates a new tmux window named after the branch
3. Runs any configured file operations (copy/symlink)
4. Executes `post_create` commands if defined in config
5. Sets up your configured tmux pane layout
6. Automatically switches your tmux client to the new window

**Examples:**

```bash
# Create a new branch and worktree
workmux add user-auth

# Use an existing branch
workmux add existing-work

# Branch names with slashes work too
workmux add feature/new-api
```

---

### `workmux merge [branch-name]`

Merges a branch into the main branch and automatically cleans up all associated
resources (worktree, tmux window, and local branch).

- `[branch-name]`: Optional name of the branch to merge. If omitted,
  automatically detects the current branch from the worktree you're in.

**Common options:**

- `--ignore-uncommitted`: Commit any staged changes before merging without
  opening an editor
- `--delete-remote`, `-r`: Also delete the remote branch after a successful
  merge

**Merge strategies:**

By default, `workmux merge` performs a standard merge commit. You can customize
the merge behavior with these mutually exclusive flags:

- `--rebase`: Rebase the feature branch onto main before merging (creates a
  linear history via fast-forward merge). If conflicts occur, you'll need to
  resolve them manually in the worktree and run `git rebase --continue`.
- `--squash`: Squash all commits from the feature branch into a single commit on
  main. You'll be prompted to provide a commit message in your editor.

**What happens:**

1. Determines which branch to merge (specified branch or current branch if
   omitted)
2. Checks for uncommitted changes (errors if found, unless
   `--ignore-uncommitted` is used)
3. Commits staged changes if present (unless `--ignore-uncommitted` is used)
4. Merges your branch into main using the selected strategy (default: merge
   commit)
5. Deletes the tmux window (including the one you're currently in if you ran
   this from a worktree)
6. Removes the worktree
7. Deletes the local branch

**Typical workflow:**

When you're done working in a worktree, simply run `workmux merge` from within
that worktree's tmux window. The command will automatically detect which branch
you're on, merge it into main, and close the current window as part of cleanup.

**Examples:**

```bash
# Merge branch from main branch (default: merge commit)
workmux merge user-auth

# Merge the current worktree you're in
# (run this from within the worktree's tmux window)
workmux merge

# Rebase onto main before merging for a linear history
workmux merge user-auth --rebase

# Squash all commits into a single commit
workmux merge user-auth --squash

# Merge and also delete the remote branch
workmux merge user-auth --delete-remote
```

---

### `workmux remove <branch-name>` (alias: `rm`)

Removes a worktree, tmux window, and branch without merging. Useful for
abandoning work or cleaning up experimental branches.

- `<branch-name>`: Name of the branch to remove.

**Common options:**

- `--force`, `-f`: Skip confirmation prompt and ignore uncommitted changes
- `--delete-remote`, `-r`: Also delete the remote branch

**Examples:**

```bash
# Remove with confirmation if unmerged
workmux remove experiment

# Use the alias
workmux rm old-work

# Force remove without prompts
workmux rm -f experiment

# Force remove and delete remote branch
workmux rm -f -r old-work
```

---

### `workmux list` (alias: `ls`)

Lists all git worktrees with their tmux window status and merge status.

**Examples:**

```bash
# List all worktrees
workmux list
```

**Example output:**

```
BRANCH      TMUX    UNMERGED    PATH
------      ----    --------    ----
main        -       -           ~/project
user-auth   ✓       -           ~/project__worktrees/user-auth
bug-fix     ✓       ●           ~/project__worktrees/bug-fix
```

**Key:**

- `` in TMUX column = tmux window exists for this worktree
- `` in UNMERGED column = branch has commits not merged into main
- `-` = not applicable

---

### `workmux init`

Generates `.workmux.yaml` with example configuration and `"<global>"`
placeholder usage.

**Examples:**

```bash
workmux init
```

---

### `workmux open <branch-name>`

Opens a new tmux window for a pre-existing git worktree, setting up the
configured pane layout and environment. This is useful if you accidentally
closed the tmux window for a worktree you are still working on.

- `<branch-name>`: Name of the branch that has an existing worktree.

**Common options:**

- `--run-hooks`: Re-runs the `post_create` commands (e.g., `pnpm install`).
- `--force-files`: Re-applies file copy/symlink operations. Useful for restoring
  a deleted `.env` file.

**What happens:**

1. Verifies that a worktree for `<branch-name>` exists and a tmux window does
   not.
2. Creates a new tmux window named after the branch.
3. (If specified) Runs file operations and `post_create` hooks.
4. Sets up your configured tmux pane layout.
5. Automatically switches your tmux client to the new window.

**Examples:**

```bash
# Open a window for an existing worktree
workmux open user-auth

# Open and re-run dependency installation
workmux open user-auth --run-hooks

# Open and restore configuration files
workmux open user-auth --force-files
```

---

### `workmux claude prune`

Removes stale entries from `~/.claude.json` that point to deleted worktree
directories. When you run Claude Code in worktrees, it stores configuration in
`~/.claude.json`. Over time, as worktrees are merged or removed, this file can
accumulate entries for paths that no longer exist.

**What happens:**

1. Scans `~/.claude.json` for entries pointing to non-existent directories
2. Creates a backup at `~/.claude.json.bak` before making changes
3. Removes all stale entries
4. Reports the number of entries cleaned up

**Safety:**

- Only removes entries for absolute paths that don't exist
- Creates a backup before modifying the file
- Preserves all valid entries and relative paths

**Examples:**

```bash
# Clean up stale Claude Code entries
workmux claude prune
```

**Example output:**

```
  - Removing: /Users/user/project__worktrees/old-feature

✓ Created backup at ~/.claude.json.bak
✓ Removed 3 stale entries from ~/.claude.json
```

---

### `workmux completions <shell>`

Generates shell completion script for the specified shell. Completions provide
tab-completion for commands and dynamic branch name suggestions.

- `<shell>`: Shell type: `bash`, `zsh`, or `fish`.

**Examples:**

```bash
# Generate completions for zsh
workmux completions zsh
```

See the [Shell Completions](#shell-completions) section for installation
instructions.

## Workflow example

Here's a complete workflow:

```bash
# Start a new feature
workmux add user-auth

# Work on your feature...
# (tmux automatically sets up your configured panes and environment)

# When ready, merge and clean up
workmux merge user-auth

# Start another feature
workmux add api-endpoint

# List all active worktrees
workmux list
```

## Why workmux?

`workmux` reduces manual setup to a pair of commands and makes it feasible to
run AI-driven development workflows in parallel.

### Without workmux

```bash
# 1. Manually create the worktree and environment
git worktree add ../worktrees/user-auth -b user-auth
cd ../worktrees/user-auth
cp ../../project/.env.example .env
ln -s ../../project/node_modules .
npm install
# ... and other setup steps

# 2. Manually create and configure the tmux window
tmux new-window -n user-auth
tmux split-window -h 'npm run dev'
tmux send-keys -t 0 'claude' C-m
# ... repeat for every pane in your desired layout

# 3. When done, manually merge and clean everything up
cd ../../project
git switch main && git pull
git merge --no-ff user-auth
tmux kill-window -t user-auth
git worktree remove ../worktrees/user-auth
git branch -d user-auth
```

### With workmux

```bash
# Create the environment
workmux add user-auth

# ... work on the feature ...

# Merge and clean up
workmux merge
```

### The parallel AI workflow (with workmux)

Delegate multiple complex tasks to AI agents and let them work at the same time.
This workflow is cumbersome to manage manually.

```bash
# Task 1: Refactor the user model (for Agent 1)
workmux add refactor/user-model

# Task 2: Build a new API endpoint (for Agent 2, in parallel)
workmux add feature/new-api

# ... Command agents work simultaneously in their isolated environments ...

# Merge each task as it's completed
workmux merge refactor/user-model
workmux merge feature/new-api
```

## Shell completions

To enable tab completions for commands and branch names, add the following to
your shell's configuration file.

For **bash**, add to your `.bashrc`:

```bash
eval "$(workmux completions bash)"
```

For **zsh**, add to your `.zshrc`:

```bash
eval "$(workmux completions zsh)"
```

For **fish**, add to your `config.fish`:

```bash
workmux completions fish | source
```

## Requirements

- Rust (for building)
- Git 2.5+ (for worktree support)
- tmux

## Inspiration and related tools

workmux is inspired by [wtp](https://github.com/satococoa/wtp), an excellent git
worktree management tool. While wtp streamlines worktree creation and setup,
workmux takes this further by tightly coupling worktrees with tmux window
management.

For managing multiple AI agents in parallel, tools like
[claude-squad](https://github.com/smtg-ai/claude-squad) and
[vibe-kanban](https://github.com/BloopAI/vibe-kanban/) offer dedicated
interfaces, like a TUI or kanban board. workmux takes a different approach:
**tmux is the interface**. If you already live in tmux, you don't need a new app
or abstraction layer. With workmux, managing parallel agents is managing tmux
windows.

## See also

- [tmux-bro]https://github.com/raine/tmux-bro
- [tmux-file-picker]https://github.com/raine/tmux-file-picker