git-worktree-manager
Что он делает
Этот скилл создаёт дополнительные рабочие копии git-проекта, чтобы несколько веток были открыты одновременно. Он также удаляет ненужные копии. Он нужен разработчикам, которые работают над несколькими функциями сразу.
Когда использовать
- ✓Когда нужно работать с двумя или более ветками одного проекта одновременно.
- ✓Когда несколько ИИ-агентов должны каждый работать в своей ветке, не мешая друг другу.
- ✓Когда старые рабочие копии накапливаются, и вы хотите безопасно их удалить.
Ссылка на скилл
https://github.com/alirezarezvani/claude-skills/blob/main/engineering/skills/git-worktree-manager/SKILL.mdСкопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.
Как использовать
Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.
Готовое сообщение для вставки
Для Claude Code, Codex или Cursor: запустите в папке проекта, и скилл установится.
Скачайте SKILL.md и положите его в папку скиллов вашего агента.
Пример запроса к вашему ИИ
“Создай отдельную рабочую копию этого проекта для моей новой функции входа, чтобы я мог держать открытой свою текущую ветку.”
5 новых скиллов в неделю. 1 минута чтения.
Как это работает
Он использует скрипты, чтобы создать каждую копию в отдельной папке, выделить свободные порты и скопировать файлы окружения, затем перед любой очисткой проверяет наличие несохранённых изменений.
Технический текст (оригинальный SKILL.md)
Оригинальный текст автора на английском, прямо с GitHub.
Git Worktree Manager
Tier: POWERFUL
Category: Engineering
Domain: Parallel Development & Branch Isolation
Overview
Use this skill to run parallel feature work safely with Git worktrees. It standardizes branch isolation, port allocation, environment sync, and cleanup so each worktree behaves like an independent local app without stepping on another branch.
This skill is optimized for multi-agent workflows where each agent or terminal session owns one worktree.
Core Capabilities
- Create worktrees from new or existing branches with deterministic naming
- Auto-allocate non-conflicting ports per worktree and persist assignments
- Copy local environment files (
.env*) from main repo to new worktree - Optionally install dependencies based on lockfile detection
- Detect stale worktrees and uncommitted changes before cleanup
- Identify merged branches and safely remove outdated worktrees
When to Use
- You need 2+ concurrent branches open locally
- You want isolated dev servers for feature, hotfix, and PR validation
- You are working with multiple agents that must not share a branch
- Your current branch is blocked but you need to ship a quick fix now
- You want repeatable cleanup instead of ad-hoc
rm -rfoperations
Key Workflows
1. Create a Fully-Prepared Worktree
- Pick a branch name and worktree name.
- Run the manager script (creates branch if missing).
- Review generated port map.
- Start app using allocated ports.
python scripts/worktree_manager.py \
--repo . \
--branch feature/new-auth \
--name wt-auth \
--base-branch main \
--install-deps \
--format text
If you use JSON automation input:
cat config.json | python scripts/worktree_manager.py --format json
# or
python scripts/worktree_manager.py --input config.json --format json
2. Run Parallel Sessions
Recommended convention:
- Main repo: integration branch (
main/develop) on default port - Worktree A: feature branch + offset ports
- Worktree B: hotfix branch + next offset
Each worktree contains .worktree-ports.json with assigned ports.
3. Cleanup with Safety Checks
- Scan all worktrees and stale age.
- Inspect dirty trees and branch merge status.
- Remove only merged + clean worktrees, or force explicitly.
python scripts/worktree_cleanup.py --repo . --stale-days 14 --format text
python scripts/worktree_cleanup.py --repo . --remove-merged --format text
4. Docker Compose Pattern
Use per-worktree override files mapped from allocated ports. The script outputs a deterministic port map; apply it to docker-compose.worktree.yml.
See docker-compose-patterns.md for concrete templates.
5. Port Allocation Strategy
Default strategy is base + (index * stride) with collision checks:
- App:
3000 - Postgres:
5432 - Redis:
6379 - Stride:
10
See port-allocation-strategy.md for the full strategy and edge cases.
Script Interfaces
python scripts/worktree_manager.py --help- Create/list worktrees
- Allocate/persist ports
- Copy
.env*files - Optional dependency installation
python scripts/worktree_cleanup.py --help- Stale detection by age
- Dirty-state detection
- Merged-branch detection
- Optional safe removal
Both tools support stdin JSON and --input file mode for automation pipelines.
Common Pitfalls
- Creating worktrees inside the main repo directory
- Reusing
localhost:3000across all branches - Sharing one database URL across isolated feature branches
- Removing a worktree with uncommitted changes
- Forgetting to prune old metadata after branch deletion
- Assuming merged status without checking against the target branch
Best Practices
- One branch per worktree, one agent per worktree.
- Keep worktrees short-lived; remove after merge.
- Use a deterministic naming pattern (
wt-<topic>). - Persist port mappings in file, not memory or terminal notes.
- Run cleanup scan weekly in active repos.
- Use
--format jsonfor machine flows and--format textfor human review. - Never force-remove dirty worktrees unless changes are intentionally discarded.
Validation Checklist
Before claiming setup complete:
git worktree listshows expected path + branch..worktree-ports.jsonexists and contains unique ports..envfiles copied successfully (if present in source repo).- Dependency ins
Частые вопросы
Он удалит мою несохранённую работу?
Шаг очистки сначала проверяет наличие незакоммиченных изменений, поэтому он призван не допускать потери работы.
Работает ли каждая копия на своих портах?
Да, скилл назначает порты каждой рабочей копии, чтобы два сервера разработки не конфликтовали.
Копирует ли он мои локальные файлы настроек?
Да, он копирует локальные файлы окружения из основного проекта в новую рабочую копию.
Подробности
Оригинальное описание автора
Use when running several branches or agents in parallel on one repo. Creates worktrees with isolated ports and env via worktree_manager.py and removes stale ones with worktree_cleanup.py.
Популярность
- Звёзды на GitHub
- 29k
- Место в рейтинге
- #9588
- Лицензия
- MIT
- Обновлён
- 02.11.2026
Комментарии
- …
Другие скиллы из этого репозитория
agent-launcher-orchestrator
29kПомогает агенту пошагово спланировать, собрать, протестировать и запланировать управляемого агента Claude в вашем собственном аккаунте, начиная с одной понятной цели.
grade-iterate
29kПозволяет агенту оценивать работу управляемого ИИ-агента по рубрике и улучшать её за фиксированное число раундов, чтобы процесс никогда не зацикливался.
interview
29kПозволяет агенту взять у вас интервью об идее ИИ-агента и превратить ваши ответы в простой план сборки до запуска чего-либо.
run-without-you
29kПомогает агенту настроить управляемого ИИ-агента на запуск по расписанию или при наступлении события, с проверкой времени cron перед запуском.
Похожие скиллы
openclaw-update
394kПомогает агенту обновить уже работающий OpenClaw Gateway, выбрав способ обновления по тому, как он был установлен, и сохранив вашу сессию.
diagnose-gateway
394kПомогает агенту выяснить, почему ваш OpenClaw Gateway не работает, проверяя настройки, каналы и порты, но ничего не меняя.
crabbox-apps
394kПомогает агенту открыть и запустить приложение на временной облачной машине, а затем показать его вид на боковой панели чата.