Agent skill

Git Worktree Manager

by alirezarezvani in alirezarezvani/claude-skills

Run parallel feature work safely with Git worktrees. An agent skill from alirezarezvani/claude-skills.

MITAuto-check: notesAgent Workflows

Install Git Worktree Manager

skills CLI
$ npx skills add alirezarezvani/claude-skills --skill git-worktree-manager -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install alirezarezvani/claude-skills git-worktree-manager --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/alirezarezvani/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/engineering/skills/git-worktree-manager .claude/skills/git-worktree-manager && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
git-worktree-manager
GitHub stars
28k
Used in
1 other repo
Token cost
~1.8k tokens
SKILL.md length
811 words
Files
6 (incl. scripts, references)
Skills in repo
342
Repo updated
First seen
Licence
MIT

At a glance

Run parallel feature work safely with Git worktrees. An agent skill from alirezarezvani/claude-skills.

  • Works in 5 steps: Create a Fully-Prepared Worktree → Run Parallel Sessions → Cleanup with Safety Checks → …
  • Running multiple feature branches simultaneously
  • SKILL.md covers Overview, Core Capabilities, When to Use and Key Workflows, plus 9 more sections
  • Runs Python scripts from its folder; calls python and git

What it does

Git Worktree Manager is an agent skill from alirezarezvani/claude-skills. Run parallel feature work safely with Git worktrees. Standardizes branch isolation, port allocation, environment sync, and cleanup so each worktree behaves like an independent local app. Optimized for multi-agent workflows where each agent or terminal session owns one worktree. Use when running multiple feature branches simultaneously, isolating experimental work, or coordinating multi-agent development across the same repo.

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including scripts and reference files (for example `README.md`, `references/docker-compose-patterns.md` and `references/port-allocation-strategy.md`).

It sits in Agent Workflows, covering Git worktrees. It works with Git and Docker. The repository describes itself as: 380 Claude Code skills & agent skills & plugins (30+ Agents, 70+ custom commands, 380+ skills, customizable references, scripts)for Claude Code, Codex, Gemini CLI, Cursor, and 8… The licence is MIT.

When your agent uses it

  • Running multiple feature branches simultaneously
  • Isolating experimental work
  • Coordinating multi-agent development across the same repo

Example prompts

  • “/git-worktree-manager”

Requirements

  • Python 3
  • Docker

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Create a Fully-Prepared Worktree
  2. Run Parallel Sessions
  3. Cleanup with Safety Checks
  4. Docker Compose Pattern
  5. Port Allocation Strategy

What it can do on your machine

Read from SKILL.md and the folder at commit 19392f7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python
    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Git Worktree Manager loads about 1.8k tokens when it runs, and up to ~2.3k if it reads all its reference files. Until then it costs about 112 tokens; SKILL.md has 811 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~112
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:22
    - Copy local environment files (`.env*`) from main repo to new worktree
  • NoteMentions a .env fileSKILL.md:105
    - Copy `.env*` files
  • NoteMentions a .env fileSKILL.md:140
    3. `.env` files copied successfully (if present in source repo).

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from alirezarezvani/claude-skills at commit 19392f7, republished under its MIT licence (© alirezarezvani). 811 words, ~1,773 tokens.

Download SKILL.mdSave it as .claude/skills/git-worktree-manager/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
git-worktree-manager
description
Run parallel feature work safely with Git worktrees. Standardizes branch isolation, port allocation, environment sync, and cleanup so each worktree behaves like an independent local app. Optimized for multi-agent workflows where each agent or terminal session owns one worktree. Use when running multiple feature branches simultaneously, isolating experimental work, or coordinating multi-agent development across the same repo.

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 -rf operations

Key Workflows

1. Create a Fully-Prepared Worktree
  1. Pick a branch name and worktree name.
  2. Run the manager script (creates branch if missing).
  3. Review generated port map.
  4. Start app using allocated ports.
bash
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:

bash
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
  1. Scan all worktrees and stale age.
  2. Inspect dirty trees and branch merge status.
  3. Remove only merged + clean worktrees, or force explicitly.
bash
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

  1. Creating worktrees inside the main repo directory
  2. Reusing localhost:3000 across all branches
  3. Sharing one database URL across isolated feature branches
  4. Removing a worktree with uncommitted changes
  5. Forgetting to prune old metadata after branch deletion
  6. Assuming merged status without checking against the target branch

Best Practices

  1. One branch per worktree, one agent per worktree.
  2. Keep worktrees short-lived; remove after merge.
  3. Use a deterministic naming pattern (wt-<topic>).
  4. Persist port mappings in file, not memory or terminal notes.
  5. Run cleanup scan weekly in active repos.
  6. Use --format json for machine flows and --format text for human review.
  7. Never force-remove dirty worktrees unless changes are intentionally discarded.
Show full SKILL.md (315 more words)Show less

Validation Checklist

Before claiming setup complete:

  1. git worktree list shows expected path + branch.
  2. .worktree-ports.json exists and contains unique ports.
  3. .env files copied successfully (if present in source repo).
  4. Dependency install command exits with code 0 (if enabled).
  5. Cleanup scan reports no unintended stale dirty trees.

References

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
  1. Confirm main repo has clean baseline or intentional WIP commits.
  2. Confirm target branch naming convention.
  3. Confirm required base branch exists (main/develop).
  4. Confirm no reserved local ports are already occupied by non-repo services.
After Creation
  1. Verify git status branch matches expected branch.
  2. Verify .worktree-ports.json exists.
  3. Verify app boots on allocated app port.
  4. Verify DB and cache endpoints target isolated ports.
Before Removal
  1. Verify branch has upstream and is merged when intended.
  2. Verify no uncommitted files remain.
  3. 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 add fails 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.

© alirezarezvani, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (scripts, references) in engineering/skills/git-worktree-manager of alirezarezvani/claude-skills.

  • SKILL.md
  • README.md
  • references/docker-compose-patterns.md
  • references/port-allocation-strategy.md
  • scripts/worktree_cleanup.py
  • scripts/worktree_manager.py

Open the folder on GitHubat commit 19392f7

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in alirezarezvani/claude-skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Git Worktree Manager next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Git Worktree Manager compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Git Worktree Manager this skillalirezarezvani/claude-skills28k1 repos~1.8kAutomated safety check: NotesMIT
Devcontainer Devstacklok/toolhive-studio170—~3.8kAutomated safety check: NotesApache-2.0
Tnr Dev Serverstudie-tech/TheNinjaRPG104—~2.5kAutomated safety check: NotesNone
Superset Project Setupsuperset-sh/superset15k—~577Automated safety check: NotesCustom licence
Polyphonyalinaqi/maggy707—~980Automated safety check: PassMIT
Git Worktree Managerborghei/Claude-Skills874—~1.6kAutomated safety check: NotesMIT

Similar skills

  • Devcontainer Dev

    stacklok/toolhive-studio

    Spin up and interact with ToolHive Studio's containerized dev environment (Xvfb + noVNC + DinD).

    170 GitHub stars~3.8k tokensUpdated today
    Agent WorkflowsAuto-check: notes
  • Tnr Dev Server

    studie-tech/TheNinjaRPG

    Run a TheNinjaRPG dev server locally from any git worktree, provision disposable test users, and call tRPC endpoints as those users.

    104 GitHub stars~2.5k tokensUpdated today
    DevelopmentAuto-check: notes
  • Superset Project Setup

    superset-sh/superset

    Makes a repository Superset-ready by writing .superset/config.json with setup, teardown and run scripts, then proving it with a real throwaway workspace.

    15k GitHub stars~577 tokensUpdated today
    DevelopmentAuto-check: notes
  • Polyphony

    alinaqi/maggy

    Multi-agent orchestration with container-isolated workspaces — each agent session runs in its own Docker container with independent git branches

    707 GitHub stars~980 tokensUpdated 13 days ago
    DevelopmentAuto-check passed
  • Git Worktree Manager

    borghei/Claude-Skills

    Manage parallel development with Git worktrees: creation with port allocation, environment sync, branch isolation, and cleanup.

    874 GitHub stars~1.6k tokensUpdated today
    DevelopmentAuto-check: notes
  • Subwave Worktree Dev

    perminder-klair/subwave

    Stage a SUB/WAVE git worktree so the dev stack can run from it, then start it.

    1.4k GitHub stars~2.1k tokensUpdated today
    DevelopmentAuto-check: notes

More from alirezarezvani/claude-skills

All 342 skills in this repo
  • Agile Product Owner

    alirezarezvani/claude-skills

    Writes INVEST-checked user stories with acceptance criteria, splits epics, plans sprints from velocity and ranks the backlog with a weighted score.

    28k GitHub starsUsed in 3 repos~3.2k tokens
    Auto-check passed
  • Product Strategist

    alirezarezvani/claude-skills

    OKR cascade toolkit for product leaders: generates aligned company-to-team OKRs from five strategy types and scores how well they line up.

    28k GitHub starsUsed in 2 repos~1.8k tokens
    Auto-check passed
  • App Store Optimization

    alirezarezvani/claude-skills

    App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store.

    28k GitHub starsUsed in 1 repo~4.2k tokens
    Auto-check passed
  • AWS Solution Architect

    alirezarezvani/claude-skills

    Design AWS architectures for startups using serverless patterns and IaC templates.

    28k GitHub starsUsed in 1 repo~2.5k tokens
    Auto-check passed
  • Campaign Analytics

    alirezarezvani/claude-skills

    Calculates attribution, funnel and ROI figures for marketing campaigns with three Python scripts that need only the standard library.

    28k GitHub starsUsed in 1 repo~2.1k tokens
    Auto-check passed
  • Code to PRD

    alirezarezvani/claude-skills

    Reverse-engineers a frontend, backend or fullstack codebase into a product requirements document with per-page docs, an enum dictionary and an API inventory.

    28k GitHub starsUsed in 1 repo~4.9k tokens
    Auto-check passed

Works with

Questions about Git Worktree Manager

What does Git Worktree Manager do?

Run parallel feature work safely with Git worktrees. An agent skill from alirezarezvani/claude-skills. Git Worktree Manager is an agent skill from alirezarezvani/claude-skills. Run parallel feature work safely with Git worktrees.

When should I use Git Worktree Manager?

Git Worktree Manager fits situations like: running multiple feature branches simultaneously; isolating experimental work; coordinating multi-agent development across the same repo.

How do I install Git Worktree Manager in Claude Code?

Run `npx skills add alirezarezvani/claude-skills --skill git-worktree-manager -a claude-code`. Or copy the skill folder (engineering/skills/git-worktree-manager in alirezarezvani/claude-skills) into .claude/skills/git-worktree-manager in your project. Claude Code loads it when a task matches its description.

How do I install Git Worktree Manager in Codex?

Run `npx skills add alirezarezvani/claude-skills --skill git-worktree-manager -a codex`. Or copy the skill folder (engineering/skills/git-worktree-manager in alirezarezvani/claude-skills) into .agents/skills/git-worktree-manager in your project. Codex loads it when a task matches its description.

Can I use Git Worktree Manager in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add alirezarezvani/claude-skills --skill git-worktree-manager -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/git-worktree-manager, .gemini/skills/git-worktree-manager, .github/skills/git-worktree-manager and .opencode/skills/git-worktree-manager in your project.

What does Git Worktree Manager need to run?

Going by SKILL.md and its folder, Git Worktree Manager needs Python for the scripts in its folder and the command-line tools its instructions call (python and git). Our summary lists: Python 3; Docker.

Does Git Worktree Manager access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Git Worktree Manager safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Git Worktree Manager use?

Git Worktree Manager is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Git Worktree Manager use?

About 1.8k tokens (SKILL.md is roughly 7.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 545 tokens, read only when the agent opens those files.

What are the alternatives to Git Worktree Manager?

Skills that share tags, products or a category with Git Worktree Manager: Devcontainer Dev (stacklok/toolhive-studio, 170 stars), Tnr Dev Server (studie-tech/TheNinjaRPG, 104 stars), Superset Project Setup (superset-sh/superset, 15k stars) and Polyphony (alinaqi/maggy, 707 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Git Worktree Manager?

alirezarezvani (a GitHub user) maintains it in alirezarezvani/claude-skills, which has 27,788 GitHub stars. The repository holds 342 skills in this directory. The repository was last updated on August 30, 2026.

Source: alirezarezvani/claude-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.