borghei/git-worktree-manager
> sync, branch isolation, and cleanup. Use when working multiple branches at once, running parallel CI validations, or isolating agent workspaces.
npx skills add https://github.com/borghei/Claude-Skills --skill git-worktree-manager
Manage parallel development workflows using Git worktrees with deterministic naming, automatic port allocation, environment file synchronization, dependency installation, and cleanup automation. Optimized for multi-agent workflows where each agent or terminal session owns an isolated worktree with its own ports, environment, and running services.
.env files, install dependencies by lockfile detection, list with clean/dirty + ahead/behind status, and safely remove with uncommitted-change detection.base + index * stride), collision detection against running processes, persistent map in .worktree-ports.json, and Docker Compose override generation.rm -rf operations.Before managing worktrees, confirm these inputs. If any is unknown or vague, ASK — do not assume:
worktree_manager.py action vs port_allocator.py vs worktree_validator.py)Stop rule: ask only the 2-3 that most change the output. If the user says "just draft it," proceed and list your assumptions at the top of the artifact.
| Tool | Purpose | Command |
|------|---------|---------|
| worktree_manager.py | List, create, remove, and clean up worktrees | python scripts/worktree_manager.py list |
| port_allocator.py | Assign/check/release deterministic port blocks; sync registry | python scripts/port_allocator.py status |
| worktree_validator.py | Validate worktree health (stale, missing branch, env parity, port conflicts, lockfile) | python scripts/worktree_validator.py --stale-days 14 |
Load the reference that matches the task — keep this file lean and pull detail on demand:
git worktree commands, the deterministic port-allocation strategy and .worktree-ports.json format, collision-detection snippet, the full setup-worktree.sh script, and the Docker Compose per-worktree override. Read when creating a worktree or wiring up ports/services.cleanup-worktrees.sh safe-cleanup script, the multi-agent assignment pattern and rules, the scenario→action decision matrix, and the post-creation validation checklist. Read when automating cleanup or coordinating agents.This skill covers:
This skill does NOT cover:
pr-review-expert and release-manager)env-secrets-manager)ci-cd-pipeline-builder)monorepo-navigator)| Skill | Integration | Data Flow |
|-------|-------------|-----------|
| env-secrets-manager | Worktree setup copies .env files that contain secrets managed by this skill | .env files flow from main repo to each worktree; secret references remain consistent across all copies |
| ci-cd-pipeline-builder | CI pipelines can spin up worktrees for parallel test matrix execution | Pipeline config triggers setup-worktree.sh per matrix job; port allocation prevents service collisions |
| release-manager | Release branches get dedicated worktrees for stabilization while feature work continues | Release worktree is created from the release branch; merged status drives cleanup automation |
| monorepo-navigator | In monorepo setups, worktrees must respect package boundaries and shared dependencies | Worktree creation inherits the monorepo root lockfile; package-level dev servers use allocated port blocks |
| pr-review-expert | PR reviews can be performed in isolated worktrees with running code for manual validation | Reviewer creates a worktree at the PR branch, runs the dev server on allocated ports, and removes after review |
| tech-debt-tracker | Stale worktrees and abandoned branches surface as tech debt indicators | Cleanup script output feeds into debt tracking; worktree age and merge status inform priority scores |
Take borghei/git-worktree-manager from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.