Skip to content

Worktrees

AgentDock Pro's AIgency layer can isolate individual tasks in their own git worktree.

AgentDock Pro

Git worktree support is part of AgentDock Pro's AIgency orchestration layer. The base workspace model — in both AgentDock and AgentDock Pro — has no worktree concept on its own; a workspace is just a project folder and a name. Worktree isolation only applies to tasks running inside an AIgency run.

Why AIgency uses worktrees

When AIgency runs multiple tasks concurrently against the same workspace, letting every task write to the same working directory at the same time risks one task's file changes clobbering another's. Isolating a task in its own git worktree gives it a private working directory and branch, so it can run independently and be integrated later.

When a task gets an isolated worktree

A task is isolated in its own worktree only when:

  • The run's workspace-mode preference is set to worktree, or it's auto and the run's concurrency is greater than 1, and
  • The workspace folder is actually a git repository.

If the folder isn't a git repository, or worktree creation fails for any reason, AIgency falls back to running the task directly in the shared workspace rather than blocking the run.

Note

Tasks of kind integration always run in the shared workspace directly — they're never isolated in a worktree, since their job is to bring isolated work back together.

Where worktrees live

Isolated worktrees are created under:

<project>/.aigency-worktrees/<runId8>/<taskId>

on a dedicated branch named:

aigency/<runId8>/<taskId8>-<slug>

See Branches for how these names are used.

Safety around concurrent worktrees

AIgency's worktree allocation is collision-safe: before assigning a worktree slot, it checks real git worktree list and git branch state rather than assuming what's free. It also handles retry/reuse for restarted tasks, detects conflicts between concurrently-isolated tasks' file changes when integrating their work, and cleans up worktrees when a task or the run itself is deleted.

For the fuller picture of how tasks get assigned to worktrees during a run, see Execution.