Skip to content
Edith

Agent docs

Coding agentsBeta

Crew worktrees: one git checkout per coding agent

Agents can each work on their own branch in a separate checkout of the same repository, so two agents never edit the same files. The agents engine creates these git worktrees, opens them as spaces, and cleans them up when you are done.

Start a thread in a new worktree

  1. Start a thread: press New agent (⌘N) and set Open as to Thread, or press New thread in the Threads section.
  2. In the composer, open Where the agent works (⌘⇧X) and choose New worktree instead of Current checkout.
  3. Send your first message. The thread works in its own checkout on its own branch.

Branch (⌘⇧G) in the same composer switches or creates a branch.

A schedule created from the terminal with --worktree also starts each run in a new worktree.

Run setup in each new worktree

A project can run a command in each new worktree, such as installing dependencies:

  1. In the Threads sidebar, right-click the project and choose Project settings….
  2. Under Actions, press Add action and enter a name and a command, such as npm install.
  3. Turn on Run when a worktree is created, then press Save.

If the project has its own settings file that lays out new worktrees, its commands run only after you approve them with Review commands.

Clean up worktrees

Crew can remove worktrees for you on a schedule:

  1. On the Crew page, open Filter (⇧⌘F) and choose Edit launch settings.
  2. Under Worktree cleanup, set Remove after inactivity, Remove when the branch merges and Remove unused worktrees.
  3. Use Keep worktrees with to protect worktrees that hold certain changes.
  4. Press Preview to see what would go, then Clean up now, or let the engine check every hour.

Worktrees with an agent running in them always stay.

To remove one thread's worktree, right-click the thread in the Threads sidebar and choose Delete with worktree. Deleting a thread any other way keeps its worktree.

From the terminal

Terminal
ed crew thread launch . --worktree main --branch fix-login -- fix ited crew engine run claude --cwd ~/code/app --branch fix-login --planed crew worktrees create --branch fix-login --base mained crew worktrees ls --cwd ~/code/apped crew worktrees status --cwd ~/code/app-fixed crew worktrees rename-branch --describe "fix the login form"ed crew worktrees rm ~/code/app-fix-logined crew worktrees cleanup --merged --older-than 14 --dry-run
  • thread launch --worktree names the branch, tag or commit to start from, and --branch the new branch. engine run --branch creates the worktree under ~/.edith/agents/worktrees/<repo>/<branch> and starts a terminal agent in it.
  • create makes a checkout on a new branch, opens an agents space in it and prints its path.
  • status prints a checkout's branch, how far it is ahead of or behind, its pull request and its changed files.
  • rename-branch renames the branch before you publish; a branch already on a remote is not renamed.
  • rm keeps a checkout with uncommitted changes unless you pass --force.
  • cleanup looks only at worktrees Edith made for agents. Without a rule it uses the Worktree cleanup settings. Always try --dry-run first.
  • cancel-setup stops a running setup, and clear-cache deletes the prepared checkouts the engine keeps for fast worktrees.

Every command takes --machine box to work on a machine, with that machine's paths. See ed crew engine for the engine's own worktree commands.

Where to go next