Worktree Lifecycle

Automate Git worktree creation, management, and cleanup with automatic port allocation.

Updated May 13, 2025
One-click install
npx skills add https://github.com/GolferGeek/orchestrator-ai --skill worktree-lifecycle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Worktree Lifecycle
Source: https://github.com/GolferGeek/orchestrator-ai/tree/main/.claude/skills/worktree-lifecycle-skill
Command: npx skills add https://github.com/GolferGeek/orchestrator-ai --skill worktree-lifecycle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps manage parallel development by provisioning Git worktrees for feature branches with automatic port isolation, reducing conflicts and manual steps.

Core Features & Use Cases

  • Create worktrees with /create_worktree: Spin up isolated environments for features.
  • Auto-port calculation: Ports are derived to avoid conflicts, with optional offsets.
  • Lifecycle management: List active worktrees, start/stop services, and clean up when done.

Quick Start

Create a worktree with auto-calculated ports: /create_worktree feature/new-feature

Create a worktree with a specific port offset: /create_worktree feature/new-feature 2

List worktrees: /list_worktrees

Remove a worktree: /remove_worktree feature/new-feature

Frequently Asked Questions about Worktree Lifecycle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate git worktree creation for parallel feature development?

Automate git worktree creation using the /create_worktree command with your feature branch name. The Skill provisions isolated environments, automatically calculates ports to avoid conflicts, and handles environment setup and service startup for each worktree, eliminating manual steps across multiple branches.

Can I avoid port conflicts when running multiple git worktrees simultaneously?

Port conflicts are prevented through automatic port allocation derived from a base port. The Skill calculates unique ports for each worktree, with optional offsets via /create_worktree feature/branch-name offset-number, ensuring isolated environments without manual port management.

What's the complete lifecycle management process for git worktrees?

The Skill manages the full lifecycle: create worktrees with /create_worktree, list active worktrees with /list_worktrees, start or stop services within each environment, and remove worktrees cleanly with /remove_worktree when development completes, automating cleanup and resource deprovisioning.

How do I set up isolated development environments for multiple feature branches?

Create isolated worktrees for each feature branch using /create_worktree feature/branch-name. Each worktree receives auto-allocated ports, independent service instances, and environment isolation, allowing developers to work on parallel branches without interfering with shared ports or dependencies.

Does git worktree automation work with DevOps automation workflows?

Yes, the Skill integrates into DevOps automation pipelines through scriptable worktree commands and lifecycle control. Automated port isolation and service management support continuous integration environments where multiple isolated builds or test runs execute concurrently on the same machine.

What happens when I remove a worktree—are resources cleaned up automatically?

The /remove_worktree command executes full cleanup: services are stopped, ports are released, and the worktree directory is removed. Automatic cleanup eliminates manual deprovisioning steps and prevents orphaned processes or port binding conflicts from accumulated worktrees.