Git Worktrees & Cursor Worktrees: The Elite Developer’s Guide (Nov 2025)
TL;DR - Why This Matters
Traditional Workflow:- One branch at a time
- Stash or commit unfinished work to switch contexts
- Wait for CI/CD to validate changes
- AI agents block each other
- Context switching kills productivity
- Multiple branches simultaneously in separate directories
- AI agents work in parallel without conflicts
- Instant context switching (just switch folders)
- Test branches side-by-side
- No stashing, no conflicts, no waiting
Part 1: Git Worktrees (The Foundation)
What Are Git Worktrees?
Git worktrees let you check out multiple branches from the same repository into different directories, all sharing the same Git history. Traditional Git:.git repository.
Why Git Created This
Problems Git Worktrees Solve:-
Context Switching Hell
- OLD: Stash → switch branch → unstash → pray nothing broke
- NEW:
cdto different worktree folder
-
Testing Multiple Branches
- OLD: Switch branches repeatedly to compare
- NEW: Open both folders side-by-side
-
Code Review While Developing
- OLD: Commit work-in-progress to switch to review branch
- NEW: Keep dev worktree open, review in another worktree
-
CI/CD Testing Locally
- OLD: Can only test one branch at a time
- NEW: Run tests in parallel across worktrees
Git Worktree Commands
Real-World Git Worktree Use Cases
Use Case 1: Emergency Hotfix During Feature Development
Use Case 2: Side-by-Side Branch Comparison
Part 2: Cursor Worktrees (The AI Superpower)
What Cursor Adds to Git Worktrees
Cursor (Nov 2025) takes Git worktrees and supercharges them for agentic, AI-first development:- AI Agent Isolation - Each agent works in its own worktree
- Parallel AI Execution - Multiple AI agents work simultaneously
- Auto-Setup Scripts - Worktrees auto-configure on creation
- Context Preservation - Each worktree maintains separate AI context
- Smart Handoffs - AI agents can pass work between worktrees
Cursor Worktrees Configuration (.cursor/worktrees.json)
This file defines setup scripts that run when creating new worktrees.
Why This Matters:
When you (or an AI agent) creates a new worktree, it needs:
- Dependencies installed (
bun install) - Linting configured
- Environment validated
- Tests passing
.cursor/worktrees.json:
Elite Cursor Worktrees Workflows (Nov 2025)
Workflow 1: Parallel AI Agents
Scenario: You need to implement 3 features simultaneously for a sprint deadline.Workflow 2: AI Experiment Branching
Scenario: Try 3 different AI-generated approaches to a problem.Workflow 3: Code Review + Development
Scenario: You need to review a PR while continuing feature work.Workflow 4: Multi-Version Testing
Scenario: Test that a feature works on multiple release branches.Part 3: Elite Cursor Worktrees Configurations
Our Configuration Breakdown
Pre-Commit Check Configuration
Full Validation Configuration
AI Handoff Configuration
Part 4: How Elite Teams Use This (Nov 2025)
Pattern 1: The Parallel Sprint
Team Structure:- 1 Product Manager
- 1 Human Developer (you)
- 5 AI Agents (via Cursor)
Pattern 2: The Experiment Matrix
Scenario: Unsure of best technical approachPattern 3: The Review Pipeline
Scenario: High-velocity team with constant PRsPattern 4: The Hotfix Factory
Scenario: Production issues need immediate fixesPart 5: Cursor-Specific Advantages (Nov 2025)
1. AI Context Isolation
Problem: AI agents share context = confused responses Cursor Solution: Each worktree has isolated AI context- Agent A in worktree 1: Context about feature-auth
- Agent B in worktree 2: Context about feature-payments
- No cross-contamination
2. Automated Worktree Scripts
Problem: Manual setup for each worktree is tedious Cursor Solution:.cursor/worktrees.json auto-runs scripts
setup-worktree: Auto-runs on creationpre-commit-check: One command validationai-handoff: Validates AI output
3. Visual Worktree Management
Problem: Terminal commands are hard to track Cursor Solution: Visual worktree panel (Nov 2025)- See all worktrees at a glance
- One-click switching
- Status indicators (clean, dirty, running tests)
- AI agent assignments visible
4. Intelligent Agent Routing
Problem: Assigning agents to worktrees manually Cursor Solution: Smart agent routing- “Claude, work on feature-auth in its worktree”
- Cursor automatically routes to correct worktree
- Agent inherits worktree context
Part 6: Common Pitfalls & Solutions
Pitfall 1: Forgetting Which Worktree You’re In
Problem: Make changes in wrong worktree Solution:Pitfall 2: Node Modules Bloat
Problem: Each worktree has its ownnode_modules = disk space explosion
Solution:
Pitfall 3: Stale Worktrees
Problem: Old worktrees pile up after branches are merged Solution:Pitfall 4: Conflicting Ports
Problem: Multiple worktrees try to use same port (8081) Solution:Part 7: Your Worktree Configuration Explained
Configuration 1: setup-worktree
What it does: Prepares new worktree for immediate use
- Automatically on worktree creation
- After pulling latest changes
- When switching to old worktree
Configuration 2: validate-worktree
What it does: Comprehensive validation suite
- Before starting work in worktree
- After AI agent completes work
- When unsure if worktree is healthy
Configuration 3: pre-commit-check
What it does: Fast pre-commit validation
- Before every commit
- In pre-commit hook (optional)
Configuration 4: full-validation
What it does: CI/CD-level validation locally
- Before pushing to GitHub
- Before creating PR
- After major changes
Configuration 5: ai-handoff
What it does: Validates AI agent output
- After AI agent completes task
- Before reviewing AI changes
- When switching from AI to human
Part 8: Advanced Patterns
Pattern 1: The Worktree Matrix
Goal: Test all combinations of featuresPattern 2: The Rolling Review
Goal: Review PRs as fast as they come inPattern 3: The Performance Lab
Goal: Compare performance across branchesPart 9: Integration with Sanctiv Workflow
Sanctiv-Specific Worktree Usage
Use Case 1: Multi-Church Testing
Use Case 2: Guided Journal Experiments
Use Case 3: Dashboard + Mobile Sync
Part 10: The Future (2025+)
Cursor’s Worktree Roadmap
Based on Nov 2025 trajectory:-
AI Agent Pools
- Pre-configured agent teams per worktree
- Auto-assignment based on task type
-
Cross-Worktree Refactoring
- Make change in one worktree
- Automatically propagate to others
-
Worktree Templates
- Pre-built worktree configs for common patterns
- One-click setup for microservices, monorepos
-
Visual Dependency Graphs
- See how worktrees relate to each other
- Understand merge order automatically
-
Cloud Worktrees
- Worktrees in cloud = instant access anywhere
- No local disk space issues
Summary: The Elite Mindset
Old Way (Single Branch):- Linear development
- Context switching overhead
- One thing at a time
- Stash hell
- Parallel development
- Zero context switching
- Multiple things simultaneously
- No stashing ever
- 5-10x velocity
- Experiment fearlessly
- Data-driven decisions
- Human reviews, AI implements
Quick Reference
Essential Commands
When to Use Each Configuration
| Configuration | When to Use | Time Saved |
|---|---|---|
setup-worktree | Creating new worktree | 2-3 min |
validate-worktree | After AI agent work | 1-2 min |
pre-commit-check | Before committing | 30 sec |
smoke-test | Quick validation | 1 min |
full-validation | Before pushing | 3-5 min |
quick-fix | Auto-fix linting | 10 sec |
clean-install | Dependencies broken | 1-2 min |
test-critical | Fast critical checks | 1 min |
validate-docs | Docs changes | 10 sec |
ai-handoff | After AI completes | 30 sec |
The Bottom Line
Worktrees = Multiple Realities Each worktree is a parallel universe where:- Different code exists
- Different experiments run
- Different AI agents work
- Different tests execute
Last Updated: November 19, 2025
For: Sanctiv Development Team
Context: Cursor AI + Git Worktrees Integration