What are Git Worktrees?

Git worktrees allow you to have multiple working directories from the same repository, enabling parallel development without the complexity of multiple clones or constant branch switching.

Traditional vs. Worktree Workflow

Traditional: Switch branches → Handle PR feedback → Switch back → Lose context

Worktree: Main directory (new features) + Review directory (PR feedback) running simultaneously

Benefits for AI-Assisted Development

  • Parallel PR Reviews: Handle CodeRabbit feedback without interrupting main development
  • Hotfix Support: Quickly fix critical issues while continuing feature work
  • Experimental Features: Test new approaches without affecting stable development
  • Context Preservation: No need to stash/commit incomplete work when switching focus
  • Phase Independence: Work on multiple development phases simultaneously
💡 AI Integration: Your AI assistant will analyze development phases and suggest when parallel workflows would be beneficial, always asking for your permission before making changes.

Setting Up Git Worktrees

1 One-Time Setup

Create dedicated worktrees for different types of work:

# Create worktree for PR reviews and hotfixes git worktree add ../myproject-reviews main # Create worktree for experimental features git worktree add ../myproject-experiments main
2 Verify Setup
# List all worktrees git worktree list # Should show: # /path/to/myproject abc123 [main] # /path/to/myproject-reviews def456 [main]
3 Directory Structure
📁 Projects/ ├── 📁 myproject/ # Main development │ ├── 📄 Plan.md │ └── 📁 src/ └── 📁 myproject-reviews/ # PR feedback & hotfixes ├── 📄 Plan.md └── 📁 src/
⚠️ Important: Each worktree is a complete working directory. Changes in one worktree don't affect others until you commit and merge.

Parallel Development Workflows

1. PR Review Workflow

# Main directory: Continue Phase 3 development cd /path/to/myproject git checkout phase-3-feature # Review directory: Handle CodeRabbit feedback for Phase 2 cd /path/to/myproject-reviews git checkout phase-2-feature # Fix review comments, commit, push # Monitor PR status from either directory gh pr view --comments gh pr status

2. Hotfix Workflow

# Critical bug reported in production cd /path/to/myproject-reviews git checkout main git checkout -b hotfix-critical-bug # Fix issue, test, commit git push -u origin hotfix-critical-bug gh pr create --title "Hotfix: Critical bug" # Main development continues uninterrupted cd /path/to/myproject # Continue feature work...

3. Phase Independence Analysis

Your AI assistant will analyze development phases using these criteria:

  • Does this phase enhance/extend previous phase functionality?
  • Do they share UI components or settings interfaces?
  • Are there logical integration points for better UX?
  • Do they use related frameworks or services?
💡 AI Decision Making: Based on this analysis, your AI assistant will suggest whether phases can be developed in parallel and ask for permission to update your development plan.

4. Cleanup Workflow

# After PR is merged, clean up cd /path/to/myproject-reviews git checkout main git pull origin main git branch -d phase-2-feature # Remove worktree when no longer needed git worktree remove /path/to/myproject-reviews

Real-World Examples

Example 1: Mobile App Development

# Main: Working on Phase 4 (Deep Session Timer) cd /Users/dev/DeepRoot git checkout phase-4-deep-session-timer # Reviews: Handling CodeRabbit feedback for Phase 3 (Movement Feature) cd /Users/dev/DeepRoot-reviews git checkout phase-3-movement-feature # Apply feedback, commit, push

Example 2: Web Application

# Main: Building new authentication system cd /Users/dev/webapp git checkout phase-2-auth-system # Experiments: Testing new UI framework cd /Users/dev/webapp-experiments git checkout experiment-new-ui # Prototype new approach without affecting main work

Example 3: API Development

# Main: Implementing user management endpoints cd /Users/dev/api-project git checkout phase-3-user-management # Reviews: Fixing security review feedback cd /Users/dev/api-project-reviews git checkout phase-2-data-validation # Address security concerns, update tests

Common Parallel Scenarios

  • Independent UI Components: Frontend components that don't share state
  • Separate Microservices: Different services with minimal dependencies
  • Documentation vs. Code: Writing docs while implementing features
  • Testing Strategies: Developing tests for previous phases while building new features
  • Performance Optimization: Optimizing existing code while adding new functionality
⚠️ When NOT to Use Parallel Development:
  • Phases with heavy dependencies
  • Shared database schema changes
  • Core architecture modifications
  • Breaking API changes

Integration with AI Development Plans

Your AI assistant will automatically detect opportunities for parallel workflows and:

  1. Analyze phase dependencies in your DEVELOPMENT_PLAN.md
  2. Suggest specific parallel workflow opportunities
  3. Ask for permission before updating your development plan
  4. Provide specific setup instructions when approved