git-worktree-manager

Creates and cleans up Git worktrees with deterministic port allocation and environment sync.

Updated Aug 14, 2026
One-click install
npx skills add https://github.com/Rohithdgrr/REEK-uninstaller --skill git-worktree-manager-rohithdgrr
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: git-worktree-manager
Source: https://github.com/Rohithdgrr/REEK-uninstaller/tree/main/.opencode/skills/git-worktree-manager
Command: npx skills add https://github.com/Rohithdgrr/REEK-uninstaller --skill git-worktree-manager-rohithdgrr

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Running multiple feature branches simultaneously often leads to port collisions, shared databases, and messy manual cleanup. This Skill standardizes Git worktree creation, port assignment, environment file syncing, and safe removal so each branch behaves like an independent local app. ## Core Features & Use Cases - Automated Worktree Setup: Create worktrees from new or existing branches, copy .env* files from the main repo, and optionally install dependencies based on detected lockfiles (npm, pnpm, yarn, bun, pip). - Deterministic Port Allocation: Assign non-conflicting app, database, and Redis ports per worktree using a base-plus-stride formula, persisted in .worktree-ports.json. - Safe Cleanup: Detect stale, dirty, and merged worktrees, then remove only those that are stale, clean, and merged into the base branch. - Use Case: A team running three agents on separate feature branches gives each agent its own worktree with isolated ports (3010/5442/6389, 3020/5452/6399, ...) so dev servers and databases never collide, then runs a weekly cleanup scan to prune merged work. ## Quick Start Ask the AI to create a new Git worktree for branch feature/new-auth named wt-auth based on main, with dependencies installed and ports allocated.

Frequently Asked Questions about git-worktree-manager

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

FAQPage Schema
How do I run multiple Git branches at the same time?▼

Use git worktree to check out multiple branches into separate directories simultaneously. The worktree_manager.py script automates this by creating the worktree, allocating unique ports, and copying environment files in one step.

How do I avoid port conflicts between Git worktrees?▼

Assign each worktree a deterministic port block using a base-plus-stride formula, such as app 3000 + 10*n, db 5432 + 10*n, redis 6379 + 10*n. The script persists assignments in .worktree-ports.json and skips slots already used by other worktrees.

How do I safely remove old Git worktrees?▼

Run worktree_cleanup.py with --remove-merged to delete only worktrees that are stale, have no uncommitted changes, and whose branches are merged into the base branch. Use --force only when you intentionally discard uncommitted work.

Does git worktree copy .env files automatically?▼

No, git worktree only checks out tracked files, so untracked .env files are missing by default. The manager script copies .env, .env.local, .env.development, and .envrc from the main repo into each new worktree.

Can I use Docker Compose with multiple Git worktrees?▼

Yes, use a per-worktree override file or .env-driven port variables mapped from the allocated ports, plus a unique compose project name per worktree. This prevents container, network, and volume name collisions between worktrees.

When should I not create a Git worktree?▼

Skip worktrees for quick local diff reviews or ephemeral checks that stay on the current branch. Worktrees add value when you need isolated dependencies, separate dev servers, or parallel long-running branches.