git-worktree-manager
БесплатноЗапускает вложенные скриптыНе проверенRun parallel Git worktrees without collisions: a port block per worktree, .env sync, health checks for stale or dirty trees, and safe cleanup of merged ones…
от borghei★ 1 250 звёзд на GitHubОб этом скилле
Git Worktree Manager
Plain git worktree add/remove is the easy part. The agent uses this skill for what git does not do: give every worktree its own port block so dev servers and Docker services do not collide, carry .env files across, spot worktrees that are stale, dirty or tracking deleted branches, and remove merged ones without losing uncommitted work. It suits multi-agent setups where each agent or terminal owns one worktree.
Core Capabilities
- Worktree lifecycle — create worktrees from new or existing branches with deterministic naming, copy
.envfiles, install dependencies by lockfile detection, list with clean/dirty + ahead/behind status, and safely remove with uncommitted-change detection. - Port allocation — deterministic per-worktree assignment (
base + index * stride), collision detection against running processes, persistent map in.worktree-ports.json, and Docker Compose override generation. - Multi-agent isolation — one branch per worktree, one agent per worktree, no shared state, conflict-free parallel execution, task-ID mapping for traceability.
- Cleanup automation — stale detection by age, merged-branch detection for safe removal, dirty-state warnings, and bulk cleanup with safety confirmations.
When to Use
- You need 2+ concurrent branches open with running dev servers.
- You want isolated environments for feature work, hotfixes, and PR review.
- Multiple AI agents need separate workspaces that do not interfere.
- Your current branch is blocked but a hotfix is urgent.
- You want automated cleanup instead of manual
rm -rfoperations.
Clarify First
Before managing worktrees, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.
- Operation: create, list, remove, or clean up worktrees (selects the
worktree_manager.pyaction vsport_allocator.pyvsworktree_validator.py). - Branch & base: which branch(es) the worktree(s) track and from what base (drives worktree naming and isolation).
- Port/service needs: whether dev servers or Docker need allocated ports (drives the deterministic port block and the Docker Compose override generated).
Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.
Workflow
- Create the worktree with
worktree_manager.py create <branch> --base main; it names the directory deterministically, copies.envfiles and installs dependencies from the lockfile it finds. - Assign ports with
port_allocator.py assign <worktree-name>: a block atbase + index * stride, checked against listening processes and recorded in.worktree-ports.json. Use the Docker Compose override in references/setup-and-ports.md to apply it. - Work: one branch and one agent per worktree, no shared mutable state.
- Check health with
worktree_validator.py(stale trees, missing directories, deleted branches,.envparity, port conflicts, lockfile drift). - Clean up with
worktree_manager.py cleanup --dry-runfirst, then without--dry-run; dirty worktrees are reported, not deleted. Runport_allocator.py syncafterwards to free released blocks. - Verify that
worktree_validator.pyreports no issues andgit worktree listmatches the port registry.
Quick Start
Run inside any git repository:
python3 scripts/worktree_manager.py list # worktrees with clean/dirty and ahead/behind
python3 scripts/port_allocator.py status # current port blocks
python3 scripts/worktree_validator.py --stale-days 14 --json # health report
python3 scripts/worktree_manager.py cleanup --stale-days 30 --dry-run
Tools Overview
| Tool | Subcommands and flags | Exit codes |
|---|---|---|
worktree_manager.py |
list, create <branch> [--base], remove <name>, cleanup [--stale-days N] [--dry-run]; --json |
0, 1 git operation failed, 2 no subcommand or not inside a repository |
port_allocator.py |
status, assign <name> [--index] [--branch], release <name>, check, sync; --json |
0, 1 operation failed, 2 no subcommand or not inside a repository |
worktree_validator.py |
--checks stale,missing,branch,env,ports,lockfile, --stale-days, --json |
0 no errors (warnings allowed), 1 errors found, 2 unknown check or not inside a repository |
Anti-Patterns
Mistake: Deleting worktree directories with rm -rf.
Why it happens: It looks like any other folder.
Instead: Use worktree_manager.py remove (or git worktree remove); a raw delete leaves stale metadata and loses uncommitted work without warning.
Mistake: Two worktrees on the same dev-server ports. Why it happens: Every checkout reads the same defa
Установить git-worktree-manager в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл git-worktree-manager?
Run parallel Git worktrees without collisions: a port block per worktree, .env sync, health checks for stale or dirty trees, and safe cleanup of merged ones. Use when several branches or agents need running dev servers at once.
Как установить скилл git-worktree-manager?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл git-worktree-manager запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic