gabriel / muse public
worktree.md markdown
110 lines 3.7 KB
Raw
sha256:be3641f35bdbcc094677776a77b9aa6a5dab891f8fab201dc162d03c2bab5aea fix(read): strip position:null from structured_delta ops in… Sonnet 4.6 patch 23 days ago

muse worktree — multiple simultaneous branch checkouts

A worktree is a second (or third, or hundredth) checked-out working directory linked to the same .muse/ object store. Each worktree has its own branch and its own state/ directory — multiple agents (or engineers) can work on different branches simultaneously with zero interference.

Mental model

myproject/                    ← main worktree
  state/                      ← main branch files
  .muse/                      ← shared object store, commits, refs

myproject-feat-audio/         ← linked worktree
  state/                      ← feat/audio files (populated at creation)

myproject-hotfix-001/         ← another linked worktree
  state/                      ← hotfix/001 files

All worktrees share one .muse/ store. A commit made in myproject-feat-audio/ is immediately visible (by commit ID) to the main worktree and all other linked worktrees.

Subcommands

muse worktree add <name> <branch>

Create a new linked worktree checked out at <branch>.

muse worktree add feat-audio feat/audio
muse worktree add hotfix-001 hotfix/001

The worktree directory is created as a sibling of the repository root, named <repo>-<name>. Its state/ is pre-populated from the branch's latest snapshot.

Constraints:

  • <name> is validated like a branch name (no path separators, no control characters).
  • <branch> must already exist.
  • A worktree with the same <name> must not already exist.

muse worktree list

List all worktrees (main + linked).

  name                     branch                          HEAD          path
──────────────────────────────────────────────────────────────────────────────────
* (main)                   main                            cccccccc0000  /Users/me/myproject
  feat-audio               feat/audio                      a1b2c3d4ef56  /Users/me/myproject-feat-audio
  hotfix-001               hotfix/001                      deadbeef0012  /Users/me/myproject-hotfix-001

The * marks the main worktree.

muse worktree remove <name>

Remove a linked worktree and its state/ directory.

muse worktree remove feat-audio
muse worktree remove feat-audio --force   # skip confirmation

The branch itself is not deleted — only the worktree directory and its metadata entry are removed.

muse worktree prune

Remove metadata entries for worktrees whose directories no longer exist (e.g. manually deleted).

muse worktree prune

Agent workflows

Parallel agent tasks

# Each agent works in its own worktree on its own branch:
muse worktree add agent-001 feat/agent-001
muse worktree add agent-002 feat/agent-002
muse worktree add agent-003 feat/agent-003

# Agents run independently in:
#   myproject-agent-001/state/
#   myproject-agent-002/state/
#   myproject-agent-003/state/

Simultaneous hotfix + feature

# Keep working on the feature in the main worktree
# while fixing the hotfix in a linked worktree:
muse worktree add hotfix hotfix/critical-bug
cd ../myproject-hotfix
muse commit -m "fix: patch the critical bug"
muse push
cd ../myproject
# Continue on main branch, uninterrupted

Worktree HEAD tracking

Each linked worktree has its own HEAD file stored at .muse/worktrees/<name>.HEAD. This is independent of the main worktree's .muse/HEAD, allowing each worktree to be on a different branch simultaneously.

Exit codes

Code Meaning
0 Success
1 Validation error (invalid name, branch not found, etc.)
File History 3 commits
sha256:0313c134f0ef4518a9c3a0ec359ffdc42546dc720010730374edfe0857caf7ef rename: delta_add → delta_upsert across wire format, source… Sonnet 4.6 minor 22 days ago
sha256:c06a9b9b9fee26c68ea725b44d54b2c0a171301ce9de746d5b656617b4463a9a fix: repair four test failures from post-migration audit Sonnet 4.6 patch 28 days ago
sha256:1900655993c83c4107067375548a7be823e471d2515830842f1a12cba4bd3cdf fix: unified object store migration — idempotent writes, JS… Sonnet 4.6 minor 29 days ago