Worktree Workflow

Last Updated: 2026-02-02 Status: 📋 Active Process

Overview

This document defines our workflow for managing features, experiments, and parallel development using git worktrees.

Philosophy: Keep experimental work isolated, track everything with issues, maintain consistency across naming.

Core Principles

  1. Issue-First Development - Create GitHub issue before starting work (unless throwaway experiment)
  2. Naming Consistency - Issue name, branch name, worktree name, and agent name are synchronized
  3. Branch from Main - All worktrees branch from main (unless explicitly branching from experiment)
  4. Fast-Forward Merges - Claude coordinates integration using git merge --ff-only
  5. PR Closes Issue - Merging a PR should close the associated issue (unless it's an epic with subtasks)
  6. Process Serves Velocity - Don't let process slow down quick fixes and small enhancements; git commit messages are sufficient for small work

When to Skip the Full Process

Use experiment/scratch worktrees without issues for:

How we'll handle these:

Example:

# Brainstorming glassmorphism effects
git worktree add ../worktree/experiment-glassmorphism -b experiment-glassmorphism

# Quick typography fix
git worktree add ../worktree/scratch-font-sizing -b scratch-font-sizing

Experimental work might:

Philosophy: Good git commit messages > heavyweight process for small work

Workflow Steps

1. Create GitHub Issue

When: Before starting any non-trivial feature or experiment

Process:

  1. Discuss feature/experiment with Claude
  2. Create GitHub issue with:
    • Title: Clear, concise feature name (e.g., "Ambient Menu")
    • Description: Problem statement, goals, scope
    • Labels: Appropriate tags (enhancement, experiment, bug, etc.)
    • Milestone: If applicable
  3. Note the issue number (e.g., #10)

Skip this step only for:

2. Determine Naming

Pattern: Convert issue title to kebab-case

Examples:

Synchronized names:

Not a hard rule, but strong correlation. Goal is to avoid confusion.

3. Create Worktree + Branch

Command:

# From main repository directory (/Users/tony/code/zus)
git worktree add ../worktree/<branch-name> -b <branch-name>

Example:

git worktree add ../worktree/ambient-menu -b ambient-menu

What this does:

Branch source:

4. Work in Worktree

Navigate to worktree:

cd ../worktree/ambient-menu

Development:

Running dev server:

5. Create Pull Request

When: Feature/experiment is ready for review

Process:

  1. Push latest changes: git push
  2. Create PR using GitHub CLI or web UI
  3. Title: Match or reference issue name
  4. Description:
    • Summary of changes
    • Reference issue: "Closes #10" or "Part of #5"
    • Test plan
    • Screenshots/demos if applicable
  5. Link to issue: Use "Closes #10" to auto-close issue on merge

6. Merge to Main

Process:

  1. Review PR (Tony reviews, or self-review if minor)
  2. Merge strategy: Fast-forward merge preferred
  3. Claude coordinates merge: git merge --ff-only ambient-menu
  4. Push to main: git push origin main
  5. PR is closed, issue is closed (if "Closes #N" was used)

If fast-forward fails:

7. Cleanup Worktree

After merge:

# From main repository
git worktree remove ../worktree/ambient-menu

# Delete branch (if no longer needed)
git branch -d ambient-menu
git push origin --delete ambient-menu

Keep worktree if:

Special Cases

Experiment/Scratch Worktrees

When: Brainstorming, quick fixes, exploration, small enhancements

Process:

Examples:

When to formalize: If experimental work reveals a substantial feature, create an issue retroactively and follow the full workflow for continued development.

Epic Issues with Subtasks

When: Large feature with multiple PRs

Process:

Building on Experiments

When: One experiment depends on another

Process:

Naming Convention Reference

Issue Title Format:

Branch/Worktree/Label Format:

Commit Message Format:

Worktree Management

List all worktrees

git worktree list

Current worktrees

Remove a worktree

git worktree remove ../worktree/<name>

Prune stale worktrees

git worktree prune

Benefits of This Workflow

  1. Isolation: Experiments don't interfere with main development
  2. Traceability: Every feature tracked via issue → branch → PR
  3. Consistency: Clear naming makes navigation easy
  4. Parallel Work: Multiple experiments can run simultaneously
  5. Clean History: Fast-forward merges keep git history linear
  6. Context Switching: Easy to switch between experiments without stashing

Example End-to-End Flow

Scenario: Implementing the Ambient Menu feature

  1. Create Issue:

    • Title: "Ambient Menu"
    • Description: Command palette triggered by Ctrl+/
    • Issue #10 created
  2. Create Worktree:

    git worktree add ../worktree/ambient-menu -b ambient-menu
    cd ../worktree/ambient-menu
    
  3. Develop:

    • Implement feature
    • Commit: "Add ambient menu component (#10)"
    • Push: git push -u origin ambient-menu
  4. Create PR:

    • Title: "Ambient Menu"
    • Body: "Closes #10"
    • Push and create PR
  5. Merge:

    • Review approved
    • Claude: git merge --ff-only ambient-menu
    • Push: git push origin main
    • Issue #10 auto-closed
  6. Cleanup:

    git worktree remove ../worktree/ambient-menu
    git branch -d ambient-menu
    

Claude's Role

Claude coordinates:

Claude ALWAYS:

This is a living document. Update as workflow evolves.