Git Worktrees
Git worktrees let you check out multiple branches of the same repository into separate directories. This is powerful when you want multiple Mona agents working on different features or tasks in the same codebase.
Why use worktrees with Mona
- Parallel tasks — One agent on a bugfix branch, another on a feature branch
- No interference — Each worktree is an independent working directory
- Shared git history — All worktrees share the same
.gitobject database - Fast switching — No stashing or committing needed to switch contexts
Creating a worktree
# In your main repo
git worktree add ../my-project-feature feature-branch
This creates a new directory ../my-project-feature with the feature-branch checked out.
Running Mona in a worktree
cd ../my-project-feature
monoclaw
Mona operates on the worktree directory just like any other project. She can read, edit, and commit files without affecting the main working directory.
Worktree + profiles
Combine worktrees with profiles for maximum isolation:
# Create profiles for each worktree
monoclaw profile create project-bugfix
monoclaw profile create project-feature
# Use each profile in its worktree
cd ../my-project-bugfix
MONOCLAW_PROFILE=project-bugfix monoclaw
cd ../my-project-feature
MONOCLAW_PROFILE=project-feature monoclaw
Automating worktree creation
Create a helper script:
#!/bin/bash
# ~/.monoclaw/scripts/new-worktree.sh
BRANCH=$1
REPO=$(git rev-parse --show-toplevel)
NAME=$(basename "$REPO")-$BRANCH
git worktree add "../$NAME" "$BRANCH"
cd "../$NAME" || exit
monoclaw profile create "$NAME"
echo "Worktree created at ../$NAME with profile $NAME"
Cleaning up worktrees
git worktree remove ../my-project-feature
This deletes the worktree directory but preserves the branch and git history.
Worktree limitations
- Bare repos — Worktrees require a non-bare repository
- Submodules — Submodule paths can conflict between worktrees
- Large repos — Very large repositories may see disk usage multiply
Best practices
- Use descriptive branch names so worktree directories are self-documenting
- Remove worktrees when done to free disk space
- Combine with profiles to isolate sessions and config per task
- Set up
.monoclaw.mdorAGENTS.mdin each worktree for context-specific instructions