Skip to content
Edith

Agent docs

TutorialBeta· About 10 minutes

Give each agent its own git worktree with Crew

By the end of this tutorial, each of your agents will work on its own branch in a separate checkout of the same repository, so two agents never edit the same files, and you will know how to check, rename and remove those checkouts when the work is done. You need Crew running on a Mac in the Edith beta, a git repository, and an agent CLI such as Claude Code or Codex. See Get Crew.

Know what the engine does for you

A git worktree is a second checkout of the same repository on its own branch. The agents engine creates these worktrees, starts the agent inside one, and cleans them up when you ask. Your main checkout stays on the branch you had.

Start a thread in its own worktree

  1. Open Crew from the sidebar and switch to Threads.
  2. If the repository is not listed yet, press Add project in the Threads sidebar and choose its folder.
  3. Press New thread (⌘N) and pick the agent.
  4. In the composer, press the workspace control, Where the agent works (⌘⇧X), and switch it from Current checkout to New worktree.
  5. Type a Branch name, or leave it empty and the engine names it. Under Base, pick the branch to start from, or keep Default branch.
  6. Write the task and send it.

Repeat for each agent. Each thread gets its own branch and folder, so they never edit the same files. To start another thread in a worktree you already have, right-click its thread and choose New thread in this worktree.

From the terminal

--worktree names the branch, tag or commit to start from, and --branch names the new branch:

Terminal
ed crew thread launch . --worktree main --branch fix-login --wait -- fix the failing login tested crew thread launch . --provider codex --worktree main --branch csv-export -- add CSV export to reports

. means the project that holds the current folder. --wait waits for the reply and prints it.

Start a terminal agent on its own branch

New agent opens a terminal agent in a space, not on a new branch. To give a terminal agent its own worktree, start it from a terminal. The engine creates a worktree under ~/.edith/agents/worktrees/<repo>/<branch> and starts the agent inside it:

Terminal
ed crew engine run claude --cwd ~/code/app --branch fix-login --plan

--plan starts it in plan mode. Leave it out to let the agent start working right away.

When you want the checkout first and the agent later, create the worktree by hand. It opens as an agents space, so you can then start an agent there from New agent (⌘N):

Terminal
ed crew worktrees create --branch fix-login --base mained crew worktrees create --branch fix-login --base origin/main --from-origin

Without --branch, the engine names the branch. --path picks the folder for the checkout, and --label names the space.

Check each worktree

Open the thread and press Diff (⌘D) in the thread toolbar to see what changed in its worktree, turn by turn.

From the terminal

List every checkout of the repository with its branch, and whether an agents space has it open, then look at one in detail:

Terminal
ed crew worktrees ls --cwd ~/code/apped crew worktrees status --cwd ~/code/app-fixed crew worktrees repos --cwd ~/code

status prints the branch, how far it is ahead of or behind its upstream and the default branch, its pull request and its changed files. repos lists every repository below a folder, most recently active first.

Rename the branch before you publish

Branch names picked in a hurry rarely survive review. Renaming is a terminal step. Rename the branch, or let the engine name it from a short description:

Terminal
ed crew worktrees rename-branch fix-login-formed crew worktrees rename-branch --describe "fix the login form" --cwd ~/code/app-wt

A branch that is already on a remote is not renamed. --only-if <name> renames only while the branch still has that name.

Remove a worktree when you are done

Deleting a thread keeps its worktree unless you ask. Right-click the thread in the Threads sidebar, choose Delete…, then Delete with worktree. Delete thread keeps the checkout.

From the terminal

Terminal
ed crew worktrees rm ~/code/app-fix-logined crew thread rm th_01 --remove-worktree

rm removes a checkout the engine manages and closes its space. The branch stays. A checkout with uncommitted changes is kept unless you pass --force.

Clean up in bulk

The engine can remove old agent worktrees for you. It only looks at worktrees Edith made for agents, and never removes one with an agent running in it.

  1. On the Crew page, open Filter (⇧⌘F) and choose Edit launch settings.
  2. Find the Worktree cleanup section.
  3. Set the rules: Remove after inactivity, Remove when the branch merges and Remove unused worktrees. Keep worktrees with protects worktrees that still have changes.
  4. Press Preview to see what would go, then Clean up now.

With rules set, the engine checks Edith's worktrees every hour and removes the ones they match.

From the terminal

Always see what cleanup would do first:

Terminal
ed crew worktrees cleanup --dry-run --mergeded crew worktrees cleanup --merged --older-than 14

--merged, --older-than <days> and --unchanged pick the rule. Without a rule the saved worktree rules apply, and when none are set nothing is removed.

Work on another machine

When you start a thread, pick the machine in the composer before you send; the worktree is made on that machine. Every ed crew worktrees command takes --machine, with that machine's paths:

Terminal
ed crew worktrees ls --machine box --cwd /srv/app