Worktree Conventions
This guide explains how to structure and manage Git worktrees for project work in the Arda workspace. Follow these conventions whether you are working alone or coordinating a multi-agent team.
Why Worktrees
Section titled “Why Worktrees”Arda projects routinely span multiple repositories. When a feature touches both operations and common-module, for example, you need to make changes in two separate repositories simultaneously. Working directly in the main clone of each repository creates two problems:
- Switching between branches in the main clone interrupts other in-flight work.
- Two parallel agents writing to the same clone without coordination produce merge conflicts.
Git worktrees let you check out a separate branch into a separate directory while sharing the repository’s object store. You can have as many worktrees as you need — one per repository per task — each on its own branch. The main clone is always clean and ready for review or unrelated work.
Worktrees also make rollback clean. Abandoning a failed task is a single git worktree remove and git branch -D, with no residue in the main clone.
Directory Convention
Section titled “Directory Convention”Standard Layout (New Projects)
Section titled “Standard Layout (New Projects)”New projects use a grouped parent directory at the workspace root:
arda/├── projects/│ └── <project-name>-worktrees/ # parent directory for this project's worktrees│ ├── <repo>-base/ # consolidation or multi-agent base worktree│ ├── <repo>-<task>/ # task-specific worktree for a given repo│ ├── documentation/ # worktree for documentation changes│ └── workspace/ # worktree for skill or config changesFor example, a project called inventory with tasks registry and builder would produce:
arda/├── projects/│ └── inventory-worktrees/│ ├── operations-registry/│ ├── operations-builder/│ ├── common-module-base/│ └── documentation/Legacy Layout (Being Phased Out)
Section titled “Legacy Layout (Being Phased Out)”Earlier projects placed worktrees directly at the workspace root:
arda/├── <project>-worktrees/│ └── <task>/You may encounter this layout in older projects. Do not create new projects using this pattern.
Branch Naming
Section titled “Branch Naming”All branches include a GitHub username prefix so that branches are clearly attributed and can coexist without collision in the shared remote.
| Context | Pattern | Example |
|---|---|---|
| Human-driven work | <github-username>/<description> | jmpicnic/add-bulk-import |
| Agent-driven work | <github-username>-ag/<description>-<ticket-repo>-<ticket-number> | jmpicnic-ag/fix-delete-management-782 |
| Integration branch | <github-username>/<project>/integration | jmpicnic/inventory/integration |
| Task branch (multi-agent) | <github-username>/<project>/<task> | jmpicnic/inventory/registry |
Creating Worktrees
Section titled “Creating Worktrees”Single-Agent Work (One Worktree per Repo)
Section titled “Single-Agent Work (One Worktree per Repo)”When you are working alone on a feature that touches one repository, create one worktree:
# Create the parent directorymkdir -p /Users/jmp/code/arda/projects/my-feature-worktrees
# Create the worktree on a new branchgit -C /Users/jmp/code/arda/operations worktree add \ /Users/jmp/code/arda/projects/my-feature-worktrees/operations \ -b jmpicnic/my-feature/operationsIf the feature also touches documentation:
git -C /Users/jmp/code/arda/documentation worktree add \ /Users/jmp/code/arda/projects/my-feature-worktrees/documentation \ -b jmpicnic/my-feature/documentationMulti-Agent Work (Base + Task Worktrees)
Section titled “Multi-Agent Work (Base + Task Worktrees)”When multiple agents work in parallel on the same repository, add a base worktree for consolidation and a separate task worktree for each agent:
# Integration branch as the basegit -C /Users/jmp/code/arda/operations worktree add \ /Users/jmp/code/arda/projects/inventory-worktrees/operations-base \ -b jmpicnic/inventory/integration
# Task worktrees branched off integrationgit -C /Users/jmp/code/arda/operations worktree add \ /Users/jmp/code/arda/projects/inventory-worktrees/operations-registry \ -b jmpicnic/inventory/registry
git -C /Users/jmp/code/arda/operations worktree add \ /Users/jmp/code/arda/projects/inventory-worktrees/operations-builder \ -b jmpicnic/inventory/builderEach agent works exclusively in its assigned worktree. After all tasks complete, merge each task branch into the integration branch:
git -C /Users/jmp/code/arda/projects/inventory-worktrees/operations-base \ merge --no-ff jmpicnic/inventory/registry
git -C /Users/jmp/code/arda/projects/inventory-worktrees/operations-base \ merge --no-ff jmpicnic/inventory/builderThen open a single PR from jmpicnic/inventory/integration to main.
Integration Branch Strategy
Section titled “Integration Branch Strategy”The integration branch strategy isolates project work from main until all tasks are verified and ready to ship together.
main └── jmpicnic/inventory/integration (integration branch, opened as one PR to main) ├── jmpicnic/inventory/registry (task branch, merged into integration) └── jmpicnic/inventory/builder (task branch, merged into integration)Steps:
- Create the integration branch off
mainbefore creating any task branches. - Create task branches off the integration branch.
- Agents work independently on their task branches.
- When each task is complete, merge its branch into the integration branch. Resolve any conflicts here, not on
main. - When all tasks are merged and the integration branch passes CI, open one PR to
main. - After the PR is merged, clean up worktrees and task branches.
These rules apply to all project work, whether human-driven or agent-driven:
- Always use absolute paths in agent tool calls. Agents inherit the spawning agent’s working directory, which may not match the worktree you intend. Relative paths silently operate on the wrong directory.
- Never work directly in main clones for project work. Reserve main clones for reviewing, pulling updates, and unrelated ad-hoc changes.
- Verify no uncommitted changes before removing a worktree. Run
git -C <worktree-path> statusfirst. Removing a worktree with uncommitted changes discards that work permanently. - Use
workspace/instructions/claude/scripts/reset-worktrees.shfor phase-gate resets. This script verifies each worktree, resets branches to a known state, and re-applies the integration base. Do not reset worktrees manually when multiple task branches are involved. - Do not push task branches directly to
main. All merges tomaingo through a PR. Task branches merge to the integration branch; the integration branch goes tomainvia PR. - Spell out worktree parent paths explicitly in permission allow-lists. The glob pattern
*-worktrees/**does not reliably match hyphenated directory names in Claude Code’s permission system. List each worktree parent explicitly (e.g.,inventory-worktrees/**).
Cleanup
Section titled “Cleanup”When a project is complete and all PRs are merged, remove the worktrees and their branches.
1. Verify each worktree has no uncommitted changes:
git -C /Users/jmp/code/arda/projects/inventory-worktrees/operations-registry statusgit -C /Users/jmp/code/arda/projects/inventory-worktrees/operations-builder status2. Remove each worktree:
git -C /Users/jmp/code/arda/operations worktree remove \ /Users/jmp/code/arda/projects/inventory-worktrees/operations-registry
git -C /Users/jmp/code/arda/operations worktree remove \ /Users/jmp/code/arda/projects/inventory-worktrees/operations-builder
git -C /Users/jmp/code/arda/operations worktree remove \ /Users/jmp/code/arda/projects/inventory-worktrees/operations-base3. Prune stale worktree metadata:
git -C /Users/jmp/code/arda/operations worktree prune4. Delete the task branches (after confirming they are merged):
git -C /Users/jmp/code/arda/operations branch -d jmpicnic/inventory/registrygit -C /Users/jmp/code/arda/operations branch -d jmpicnic/inventory/buildergit -C /Users/jmp/code/arda/operations branch -d jmpicnic/inventory/integration5. Remove the empty parent directory:
rmdir /Users/jmp/code/arda/projects/inventory-worktreesRelated Pages
Section titled “Related Pages”- Working with AI Agent Assistants — How multi-agent teams use worktrees during a project run.
- Development Workflows — Build and test commands for each repository.
- Multi-Repository Gradle Development — Composite build patterns when
common-modulechanges accompany a consuming service change.
Copyright: (c) Arda Systems 2025-2026, All rights reserved
Copyright: © Arda Systems 2025-2026, All rights reserved