Skip to main content

The Multi-Agent Development Era

GWTree is built for the AI-assisted development era where multiple AI coding agents can work on different features simultaneously. Git worktrees are the perfect solution for parallel agent execution.

Why Worktrees for AI Agents?

AI coding agents like Claude Code, Command Code, and Cursor need:

Isolated Environments

Each agent needs its own working directory to avoid conflicts with file modifications

Separate Branches

Clean separation of changes allows independent code review and merging

Parallel Execution

Work on multiple features simultaneously instead of waiting for sequential completion

Easy Merging

Review each agent’s work independently and merge when ready

Quick Start: Parallel Agent Setup

Create three worktrees instantly for three different features:
The -x flag (--no-editor) prevents editors from automatically opening, perfect for batch creation.
This creates:
Each with its own branch: auth, api, dashboard

Multi-Agent Workflow

1

Create isolated worktrees

Use batch creation to set up multiple worktrees at once:
From the source code (src/commands/create.ts:326-458), the batch creation function:
  • Prunes stale worktrees once at the start
  • Creates each worktree from the main branch
  • Auto-installs dependencies if configured
  • Handles branch name conflicts automatically
2

Assign agents to worktrees

Open each worktree in a different AI coding tool:
3

Work in parallel

Each agent works independently:
  • Claude Code implements OAuth2 authentication in my-repo-auth/
  • Command Code builds REST API endpoints in my-repo-api/
  • Cursor creates dashboard components in my-repo-dashboard/
No conflicts, no stashing, no branch switching needed.
4

Monitor progress

Check the status of all worktrees:
Output shows:
5

Merge when ready

Merge completed work independently:
Each merge:
  • Switches to main branch
  • Merges the feature branch
  • Removes the worktree
  • Deletes the branch

Real-World Example

Scenario: E-commerce Feature Sprint

You need to ship three features simultaneously:
  1. Payment integration
  2. Product search
  3. User reviews

Traditional Approach (Sequential)

Time to complete: 6 days

GWTree Approach (Parallel)

Time to complete: 2 days

Automatic Dependency Management

GWTree automatically installs dependencies in each worktree:
Supported package managers:
  • pnpm (detected via pnpm-lock.yaml)
  • Bun (detected via bun.lockb)
  • Yarn (detected via yarn.lock)
  • npm (detected via package-lock.json)

Editor Integration

Open each worktree in your preferred editor automatically:
To disable auto-opening when creating multiple worktrees:

Status Monitoring

The status dashboard provides real-time visibility into all agent progress:

Status Indicators

No uncommitted changes, commits are ready to merge to main.
Active work with uncommitted changes or behind main.
Already merged to main, ready for cleanup with gwt clean.

Cleanup Merged Work

After merging, clean up worktrees:
From src/commands/list.ts:375-378, the clean command detects merged worktrees:

Best Practices

Do:
  • Use descriptive, feature-based names: user-auth, payment-flow, admin-panel
  • Run gwt status regularly to monitor all agents
  • Merge completed worktrees promptly to avoid drift from main
  • Use gwt clean to remove merged worktrees
Don’t:
  • Create too many worktrees (3-5 is ideal)
  • Let worktrees get too far behind main (merge or rebase regularly)
  • Forget to clean up merged worktrees (wastes disk space)
  • Use the same worktree for multiple agents (defeats isolation purpose)

Advanced: Custom Workflows

Feature Branch from Non-Main

Press ESC during name input to specify different branch and worktree names:
This creates my-repo-hotfix-auth/ with branch fix/auth-bug-123.

Fast Mode for Automation

Skip all prompts with -y flag:
Uses saved defaults:
  • Auto-stash changes
  • Auto-switch to main
  • Auto-pull latest
  • Auto-install dependencies

Learn More

Naming Patterns

Understand the {repo}-{name} naming convention

Git Worktrees

Deep dive into how git worktrees work