git-worktree-manager
Skill0 starsChanged 7 months agoMITView on GitHub
Git Worktree Manager
- Reads credentials
- Deletes or force-pushes
We split this skill into the rules it gives an agent
26 rules. 21 are common, 0 are distinctive, and 5 are very specific to this project.
21
Common
Most of the 5 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 14
Use this skill to run parallel feature work safely with Git worktrees.
- Common: line 20
Create worktrees from new or existing branches with deterministic naming
- Common: line 40
Run the manager script (creates branch if missing).
- Common: line 42
Start app using allocated ports.
- Common: line 54
If you use JSON automation input:
- Common: line 76
Remove only merged + clean worktrees, or force explicitly.
- Very specific: line 85
Use per-worktree override files mapped from allocated ports.
- Very specific: line 91
Default strategy is base + (index * stride) with collision checks:
- Common: line 127
Keep worktrees short-lived.
- Very specific: line 128
Use a deterministic naming pattern (wt-<topic>).
- Common: line 130
Run cleanup scan weekly in active repos.
- Very specific: line 131
Use --format json for machine flows and --format text for human review.
- Common: line 132
Never force-remove dirty worktrees unless changes are intentionally discarded.
- Common: line 136
Before claiming setup complete:
- Common: line 152
Use this quick selector before creating a new worktree:
- Common: line 170
Verify git status branch matches expected branch.
- Common: line 172
Verify app boots on allocated app port.
- Common: line 173
Verify DB and cache endpoints target isolated ports.
- Common: line 177
Verify branch has upstream and is merged when intended.
- Common: line 178
Verify no uncommitted files remain.
- Common: line 179
Verify no running containers/processes depend on this worktree path.
- Very specific: line 183
Use worktree path naming that maps to task ID (wt-1234-auth).
- Common: line 190
If git worktree add fails due to existing path: inspect path, do not overwrite.
- Common: line 191
If dependency install fails: keep worktree created, mark status and continue manual recovery.
- Common: line 192
If env copy fails: continue with warning and explicit missing file list.
- Common: line 193
If port allocation collides with external service: rerun with adjusted base ports.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 textIf 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 json2. 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 text4. 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.
Other versions7 projects use a version of this.
Word for word · 1
- csiddhant796-blip/claude-skills-collection★ 2100% same
Edited · 3
- Hassaan146/claude-skills★ 1896% same
- Hussain-Elfalah/Agentic-Skills★ 296% same
- mahiunfiltered/claude-code-skills★ 196% same
Wrote their own version · 3
- nuonco/nuon★ 120same name
- Cure-Consulting-Group/ProductEngineeringSkills★ 3same name
- DROOdotFOO/agent-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- skills/agenthub/CLAUDE.mdCLAUDE.md
- skills/autoresearch-agent/CLAUDE.mdCLAUDE.md
- agent-designerSkill
- agenthubSkill
- agent-workflow-designerSkill
- api-design-reviewerSkill
- api-test-suite-builderSkill
- autoresearch-agentSkill
- browser-automationSkill
- changelog-generatorSkill
- ci-cd-pipeline-builderSkill
- codebase-onboardingSkill
- database-designerSkill
- database-schema-designerSkill
- dependency-auditorSkill
- docker-developmentSkill
- env-secrets-managerSkill
- everything-claude-code-conventionsSkill
- focused-fixSkill
- helm-chart-builderSkill
- interview-system-designerSkill
- mcp-server-builderSkill
- migration-architectSkill
- monorepo-navigatorSkill
- observability-designerSkill
- performance-profilerSkill
- pr-review-expertSkill
- rag-architectSkill
- release-managerSkill
- runbook-generatorSkill
- secrets-vault-managerSkill
- engineering-advanced-skillsSkill
- skill-security-auditorSkill
- skill-testerSkill
- spec-driven-workflowSkill
- sql-database-assistantSkill
- tech-debt-trackerSkill
- terraform-patternsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

