Skip to content

Worktrees

Run sessions, tasks, and Loops in isolated Git checkouts while sharing the parent workspace's runtime context.

For people running agent work11 pages in this section

A Worktree is a linked Git checkout inside one CompozyOS workspace. It has its own branch and files, but keeps the parent workspace's identity, memory, agents, skills, configuration, and permissions. Use one when parallel agents need independent working directories in the same repository.

The workspace remains the ownership and data-isolation boundary. A Worktree is a nested execution context, not another workspace: its sessions, task runs, events, status cache, and API reads all carry the parent workspace_id plus a worktree_id.

Lifecycle

StateMeaning
pendingCreation is moving through branch, checkout, copy, and setup.
readySessions and runs may bind to the Worktree.
failedBoot recovery could not preserve a usable checkout.
missingGit no longer reports the recorded path. History remains attached.
removingRemoval owns the Worktree while safety checks and cleanup run.
removedThe linked checkout is gone; the branch and Git history remain.
dismissedA retained tombstone was explicitly cleared from the catalog.

Git is the source of truth for linked checkouts. CompozyOS combines Git discovery with its own records so it can show unmanaged checkouts, adopt them, retain history when paths disappear, and refuse unsafe removal.

A failed setup_command is different from lifecycle failed: the checkout stays ready, while setup_state: "failed" and setup_error flag the bootstrap result.

How work binds

  • A session chooses the workspace root, an existing ready Worktree, or a new Worktree before its first prompt. Changing the environment later creates a new session; it never moves a live one.
  • A Task policy resolves to the workspace root, one named Worktree, or a fresh Worktree per run. The resolved choice is saved on the run and does not change after enqueue.
  • A Loop agent action resolves root, worktree, per_run, or directory. A node value wins over the Loop default; run-loop forwards the parent environment unless the child resolves its own.

In this section

Start here

  1. Create or adopt a checkout.
  2. Select it for a session, a Task, or a Loop.
  3. Use the assisted exit to commit and publish work.
  4. Remove or recover the checkout without losing history.

Use Git 2.37 or newer. If Git is missing, too old, or the workspace is not Git-backed, the worktree surface returns a structured diagnostic instead of partially enabling lifecycle actions.

On this page