Skip to content

Standardize Git Worktree Lifecycle for Parallel Branch Development #267

@djm81

Description

@djm81

Standardize Git Worktree Lifecycle for Parallel Branch Development

Why

The repository needs a consistent, low-risk way to run multiple feature streams in parallel using git worktree. Without a standard lifecycle, teams can accidentally use protected branches (dev, main) in worktrees, collide on branch-to-folder mappings, or leave stale worktrees that cause confusion and merge friction.

What Changes

  • NEW: Add a repository helper script (scripts/worktree.sh) that standardizes worktree operations: create, list, and cleanup.
  • NEW: Enforce branch-type policy in helper workflow: only feature/*, bugfix/*, hotfix/*, and chore/* are allowed for worktree creation; dev and main are blocked.
  • NEW: Document deterministic path layout and cleanup rules in AGENTS.md and script usage output.
  • NEW: Add unit tests that validate helper behavior and guardrails (including forbidden branch handling).

Capabilities

  • git-worktree-lifecycle: Developers can create, inspect, and remove branch-specific worktrees with a standardized command flow that reduces branch/path conflicts and protects dev/main usage.

Impact

  • Affected specs: openspec/changes/workflow-01-git-worktree-management/specs/git-worktree-lifecycle/spec.md
  • Affected code: scripts/worktree.sh, tests/unit/tools/test_worktree_helper.py, AGENTS.md, .cursor/commands/wf-create-change-from-plan.md, .cursor/commands/wf-validate-change.md
  • Integration points: local git CLI workflows, OpenSpec branch discipline, and local cleanup after merge to dev
  • Risks: incorrect branch parsing or path checks can block valid workflows; mitigated by explicit tests and clear usage output.
  • Rollback: remove scripts/worktree.sh and related tests/docs, then revert to manual git worktree usage.

OpenSpec Change Proposal: workflow-01-git-worktree-management

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions