Install
mkdir -p .claude/skills/git-worktree-manager && curl -L -o skill.zip "https://mcp.directory/api/skills/download/2081" && unzip -o skill.zip -d .claude/skills/git-worktree-manager && rm skill.zipInstalls to .claude/skills/git-worktree-manager
About this skill
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 install command exits with code
0(if enabled). - Cleanup scan reports no unintended stale dirty trees.
References
- port-allocation-strategy.md
- docker-compose-patterns.md
- README.md for quick start and installation details
Decision Matrix
Use this quick selector before creating a new worktree:
- Need isolated dependencies and server ports -> create a new worktree
- Need only a quick local diff review -> stay on current tree
- Need hotfix while feature branch is dirty -> create dedicated hotfix worktree
- Need ephemeral reproduction branch for bug triage -> create temporary worktree and cleanup same day
Operational Checklist
Before Creation
- Confirm main repo has clean baseline or intentional WIP commits.
- Confirm target branch naming convention.
- Confirm required base branch exists (
main/develop). - Confirm no reserved local ports are already occupied by non-repo services.
After Creation
- Verify
git statusbranch matches expected branch. - Verify
.worktree-ports.jsonexists. - Verify app boots on allocated app port.
- Verify DB and cache endpoints target isolated ports.
Before Removal
- Verify branch has upstream and is merged when intended.
- Verify no uncommitted files remain.
- Verify no running containers/processes depend on this worktree path.
CI and Team Integration
- Use worktree path naming that maps to task ID (
wt-1234-auth). - Include the worktree path in terminal title to avoid wrong-window commits.
- In automated setups, persist creation metadata in CI artifacts/logs.
- Trigger cleanup report in scheduled jobs and post summary to team channel.
Failure Recovery
- If
git worktree addfails due to existing path: inspect path, do not overwrite. - If dependency install fails: keep worktree created, mark status and continue manual recovery.
- If env copy fails: continue with warning and explicit missing file list.
- If port allocation collides with external service: rerun with adjusted base ports.
More by alirezarezvani
View all skills by alirezarezvani →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversOptimize Facebook ad campaigns with AI-driven insights, creative analysis, and campaign control in Meta Ads Manager for
Access NixOS packages, system options, Home Manager, and nix-darwin configs with advanced caching. Explore nix package t
TaskManager streamlines project tracking and time management with efficient task queues, ideal for managing projects sof
3D Printer Manager enables remote control, file handling, and advanced STL editing with seamless integration for better
Easily manage and export bookmarks and favorites in Chrome with Raindrop.io. The top bookmark manager for collections, t
Securely manage and access secrets with a bridge to Infisical. Supports secret server solutions like AWS Secrets Manager
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.