Skip to main content

Worktrees & Isolation

When Genie creates a team, it provisions an isolated copy of the repository so agents can work on different branches without conflicts. Understanding this isolation model is important for debugging file paths and cleanup.

Isolation Model

Genie uses git clone --shared instead of git worktree for team isolation.

Why Not git worktree?

A known bug in Claude Code can flip core.bare=true on the parent repository via shared .git metadata when using standard git worktrees. This silently corrupts the parent repo, making all worktrees non-functional. git clone --shared creates a full clone that shares object storage with the parent (saving disk space) but has its own .git directory — safe from metadata corruption.

How It Works

Directory Structure

Shared vs. Independent State

Configuring the Base Directory

The worktree base directory defaults to ~/.genie/worktrees/. Override it in config:
Or set GENIE_HOME to relocate everything:

Path Resolution

When a team is created, the worktree path is computed as:
For example:
  • Repo: /home/user/projects/my-api
  • Team: feat/auth-fix
  • Result: ~/.genie/worktrees/my-api/feat--auth-fix
Note that slashes in team names are converted to double-dashes for filesystem safety.

Team Config File

Each team stores its full configuration at ~/.genie/teams/<safe-name>.json:

Cleanup

Disbanding a Team

This removes:
  • The team config file (~/.genie/teams/auth-fix.json)
  • All agent registry entries for team members
  • tmux windows/panes for team agents
  • Native team directory (~/.claude/teams/auth-fix/)
Team disband does not delete the worktree directory by default. This preserves uncommitted work. Delete manually if you want to reclaim disk space:

Cleaning Up Orphaned Worktrees

If worktrees accumulate from disbanded teams, clean them up:

Worktree Gotchas

  • Worktrees share .genie/ state via git rev-parse --git-common-dir. Changes to wish state in one worktree are visible in all others for the same repo.
  • Team name IS the branch name — conventional prefixes (feat/, fix/, chore/) are required.
  • The --shared flag means git objects are hardlinked. Deleting the parent repo’s objects can break worktrees. Don’t run git gc --prune on the parent while worktrees exist.