Skip to content

marcus888-techstack/test-workspace-worktree

Repository files navigation

🚀 Git Worktree Boss Mode: Parallel Development Mastery

Transform your development workflow from sequential to parallel. Control multiple development streams like a boss. Perfect for agentic coding where multiple AI assistants work on different features simultaneously.

🎁 Using This Template

This is a Git Worktree Template Repository ready for your next project!

Quick Start with This Template:

  1. Clone or fork this repository

    git clone <this-repo-url> your-project-name
    cd your-project-name
  2. Start creating your worktrees

    ./worktree-manager.sh create feature/your-first-feature
  3. Open in Cursor/VS Code

    cursor myproject.code-workspace
    # or
    code myproject.code-workspace
  4. Start developing!

    • Your project files go in the main directory
    • Each feature gets its own worktree
    • Use the included tools and guides below

🎯 Why This Changes Everything

Imagine having multiple versions of your codebase open simultaneously, each in its own branch, each with its own terminal, each potentially running a different AI coding assistant. No more context switching. No more stashing changes. No more "let me just quickly fix this bug" interrupting your feature work.

This is Boss Mode for developers.

The Traditional Way (Slow & Painful)

Feature A → Switch Branch → Stash → Bug Fix → Switch Back → Unstash → Lost Context 😫

The Worktree Way (Fast & Powerful)

Feature A ────────────────→ Complete ✅
Feature B ────────────────→ Complete ✅  
Bug Fix  ──→ Complete ✅
Review   ────→ Complete ✅

All happening in parallel!

🌟 What Makes This Awesome

1. Multi-Agent Development

Run multiple AI coding assistants (Claude Code, Copilot, etc.) simultaneously:

  • Terminal 1: Claude working on authentication
  • Terminal 2: Claude implementing data processing
  • Terminal 3: Claude fixing bugs
  • Terminal 4: You reviewing and coordinating

2. Zero Context Switching

  • Each worktree maintains its own state
  • Switch between features instantly
  • No stashing, no merge conflicts from switching
  • Keep your mental model intact

3. Visual Organization

The Cursor/VS Code workspace shows all branches at once:

📁 🏠 Main Branch
📁 🔐 Feature: Authentication  
📁 📊 Feature: Data Processing
📁 🚨 Hotfix Branch

4. Boss-Level Control

  • See all active development streams
  • Monitor progress across features
  • Coordinate complex releases
  • Manage team members' work areas

⚡ Quick Start (Be Running in 2 Minutes)

1. Initial Setup

# Clone this repo
git clone <your-repo-url>
cd test-workspace-worktree

# Make the manager script executable
chmod +x worktree-manager.sh

# Create your first worktree
./worktree-manager.sh create feature/my-awesome-feature

2. Open Boss Mode in Cursor/VS Code

# This opens ALL your worktrees in one window
cursor myproject.code-workspace
# or
code myproject.code-workspace

3. Start Parallel Development

Open multiple terminals (one per worktree) and start coding:

# Terminal 1 (Authentication worktree)
claude "implement OAuth2 login with Google"

# Terminal 2 (Data worktree)  
claude "create data validation pipeline"

# Terminal 3 (Main branch)
claude "update documentation"

🎮 The Boss Workflows

🏭 Workflow 1: The Parallel Feature Factory

Scenario: You're building a SaaS app with multiple features in development

# Create worktrees for each feature
./worktree-manager.sh create feature/user-authentication
./worktree-manager.sh create feature/payment-integration  
./worktree-manager.sh create feature/email-notifications
./worktree-manager.sh create feature/analytics-dashboard

# Open the workspace
cursor myproject.code-workspace

# Now you have 4 terminals, 4 Claude instances, 4 features progressing in parallel!

Boss Move: Start each morning by checking progress across all worktrees:

./worktree-manager.sh status

🚨 Workflow 2: The Emergency Response Team

Scenario: Critical bug in production while you're deep in feature work

# Don't panic! Create a hotfix worktree
./worktree-manager.sh create hotfix/critical-payment-bug

# Switch to it instantly
./worktree-manager.sh switch hotfix/critical-payment-bug

# Fix it with Claude
claude "fix the payment processing timeout issue in checkout.py"

# Meanwhile, your feature work remains untouched!

🔬 Workflow 3: The Review Laboratory

Scenario: Review PRs without contaminating your workspace

# Create a review worktree
./worktree-manager.sh create review/pr-456

# In that worktree
git fetch origin pull/456/head:review/pr-456
git checkout review/pr-456

# Test everything in isolation
npm test
claude "analyze this PR for security vulnerabilities"

🧪 Workflow 4: The Experiment Sandbox

Scenario: Try risky refactoring without fear

# Create experimental worktree
./worktree-manager.sh create experiment/crazy-optimization

# Go wild with Claude
claude "refactor this entire module to use async generators"

# If it works, great! If not, just delete it:
./worktree-manager.sh remove experiment/crazy-optimization

📚 Complete Command Reference

Worktree Manager Commands

Command Description Example
list Show all worktrees ./worktree-manager.sh list
create Create new worktree ./worktree-manager.sh create feature/new-api
remove Delete a worktree ./worktree-manager.sh remove feature/old-api
switch Open worktree in Cursor ./worktree-manager.sh switch feature/new-api
status Show status of all worktrees ./worktree-manager.sh status
clean Remove all worktrees (except main) ./worktree-manager.sh clean

Direct Git Worktree Commands

# List all worktrees with details
git worktree list

# Add worktree with new branch
git worktree add worktrees/feature-x -b feature/x

# Add worktree from existing remote branch
git worktree add worktrees/feature-y origin/feature/y

# Remove worktree (clean)
git worktree remove worktrees/feature-x

# Force remove (with uncommitted changes)
git worktree remove --force worktrees/feature-x

# Clean up stale worktree info
git worktree prune

🚀 Advanced Boss Techniques

1. Coordinating Multiple AI Agents

# Create a coordination script
cat > coordinate.sh << 'EOF'
#!/bin/bash
echo "🎯 Deploying AI Agents..."

# Agent 1: Frontend
(cd worktrees/feature-frontend && claude "implement responsive dashboard") &

# Agent 2: Backend  
(cd worktrees/feature-backend && claude "create REST API endpoints") &

# Agent 3: Database
(cd worktrees/feature-database && claude "optimize query performance") &

wait
echo "✅ All agents completed!"
EOF

chmod +x coordinate.sh
./coordinate.sh

2. Cross-Worktree Operations

# Search across ALL worktrees
grep -r "TODO" worktrees/

# Run tests across all worktrees
for dir in worktrees/*/; do
    echo "Testing $dir"
    (cd "$dir" && npm test)
done

# Sync all worktrees with main
for dir in worktrees/*/; do
    (cd "$dir" && git pull origin main)
done

3. Workspace Customization

Add to your .code-workspace file:

{
    "folders": [
        {
            "name": "🏠 Main Branch",
            "path": "."
        },
        {
            "name": "🚀 Feature: ${featureName}",
            "path": "worktrees/feature-${featureName}"
        }
    ],
    "settings": {
        "terminal.integrated.profiles.osx": {
            "worktree-main": {
                "path": "bash",
                "args": ["-c", "cd ${workspaceFolder:🏠 Main Branch} && bash"]
            }
        }
    }
}

4. Git Hooks for Worktrees

Create .git/hooks/post-checkout:

#!/bin/bash
echo "📍 Switched to $(git branch --show-current)"
echo "📊 Status: $(git status --porcelain | wc -l) uncommitted changes"

🎯 Real-World Boss Scenarios

Scenario 1: Startup Feature Blitz

You're a CTO with 3 developers and 2 weeks to launch:

# Create worktrees for each developer
./worktree-manager.sh create dev/alice-payment
./worktree-manager.sh create dev/bob-auth  
./worktree-manager.sh create dev/charlie-frontend

# Daily standup: Check all progress
./worktree-manager.sh status

# Integrate features
cd worktrees/integration
git merge dev/alice-payment dev/bob-auth dev/charlie-frontend

Scenario 2: Agency Juggling Multiple Clients

# Organize by client
./worktree-manager.sh create client/acme-corp
./worktree-manager.sh create client/wayne-enterprises
./worktree-manager.sh create client/stark-industries

# Each client gets dedicated AI assistant
# Never mix up client code again!

Scenario 3: Open Source Maintenance

# Handle multiple PRs simultaneously
./worktree-manager.sh create pr/feature-1234
./worktree-manager.sh create pr/bugfix-5678
./worktree-manager.sh create pr/docs-9012

# Test all PRs in parallel
parallel --jobs 3 'cd worktrees/{} && npm test' ::: pr/*

💡 Pro Tips & Best Practices

1. Naming Conventions

feature/payment-integration     # Features
bugfix/issue-1234              # Bug fixes  
hotfix/critical-security       # Emergency fixes
experiment/new-architecture    # Experiments
review/pr-5678                 # PR reviews
release/v2.0.0                 # Release prep
dev/alice-feature             # Personal branches

2. Worktree Lifecycle

# Morning: Check status
./worktree-manager.sh status

# Before creating: Check if exists
git worktree list | grep feature-name

# After merging: Clean up
./worktree-manager.sh remove feature/completed-feature

# Weekly: Prune stale worktrees
git worktree prune

3. Performance Optimization

  • Keep worktrees on the same disk as main repo
  • Limit active worktrees to 5-7 for best performance
  • Use git worktree prune regularly
  • Consider separate worktrees for large binary files

4. Team Collaboration

# Share worktree setup
git add myproject.code-workspace
git commit -m "Add team workspace configuration"

# Document active worktrees
echo "## Active Development" >> WORKTREES.md
git worktree list >> WORKTREES.md

🔧 Troubleshooting

Issue: "fatal: worktree already exists"

# Solution 1: Remove and recreate
git worktree remove worktrees/branch-name
./worktree-manager.sh create branch-name

# Solution 2: Force removal
rm -rf worktrees/branch-name
git worktree prune

Issue: Can't remove worktree with changes

# Save changes first
cd worktrees/feature-branch
git stash save "WIP: Saving before worktree removal"

# Or force remove
git worktree remove --force worktrees/feature-branch

Issue: Worktree shows wrong branch

cd worktrees/problem-worktree
git checkout correct-branch
git pull origin correct-branch

Issue: "fatal: worktree prune failed"

# Manual cleanup
rm -rf .git/worktrees/broken-worktree
git worktree prune

🎉 You're Now a Worktree Boss!

With this setup, you can:

  • ✅ Run multiple AI coding sessions in parallel
  • ✅ Handle emergencies without disrupting feature work
  • ✅ Review code without contaminating your workspace
  • ✅ Experiment fearlessly with isolated environments
  • ✅ Coordinate team development like a pro
  • ✅ Ship features faster with parallel development

Next Steps

  1. Create your first feature worktree
  2. Open the boss workspace in Cursor/VS Code
  3. Start your first parallel AI coding session
  4. Experience the power of true parallel development

Remember: You're not just coding anymore. You're orchestrating a symphony of development streams. You're the boss of your codebase.


Built with ❤️ for developers who refuse to work sequentially

Questions? Check the worktree-guide.md for more details.

Contributing? Create a worktree for your feature and submit a PR!

👥 Contributors

Marcus
Marcus

💻 📖 🤔 🎨

See our Contributors Guide for more information.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages