git-worktree
Skill2 starsChanged 8 months agoMITView on GitHub
Safely guide Git worktree workflows: creating a separate checkout for a branch or task, listing active worktrees, moving, locking, unlocking, removing, repairing, or pruning worktrees, and resolving errors caused by a branch already being checked out elsewhere. Use this skill whenever a user mentions `git worktree`, parallel Git checkouts, working on multiple branches at once, a worktree path that was moved or deleted manually, or wants to clean up a stale worktree. Before proposing a state-changing command, inspect the repository and affected worktrees, preserve Git's safeguards, and make destructive consequences explicit.
30 other projects use a version of this.
Adopted by
Most recently taken up by
- aegntic/compound-engineeringtheir own version, first seen Nov 8, 2026
- sbluemin/fleet-harnesstheir own version, first seen Nov 8, 2026
- yht-4403/jc-agent-skillstheir own version, first seen Nov 8, 2026
- yuri-xyz/skillstheir own version, first seen Nov 8, 2026
- iliaal/ai-skillstheir own version, first seen Nov 7, 2026
- eliasjnior/claude-skillstheir own version, first seen Nov 1, 2026
Used with
Projects with it also use agent-native-architecture, document-review and 7 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
CodeWithBehnamSkillagent-native-architecture
Build applications where agents are first-class citizens. Use this skill when designing autonomous agents, creating MCP tools, implementing self-modifying systems, or building apps where features are outcomes achieved by agents operating in a loop.
Also in 3 projects that use this
CodeWithBehnamSkilldocument-review
This skill should be used to refine brainstorm or plan documents before proceeding to the next workflow step. It applies when a brainstorm or plan document exists and the user wants to improve it.
Also in 3 projects that use this
MicrosoftSkillgit-commit
Stage user-selected paths, confirm the exact staged set, and create one local Conventional Commit, or generate a commit message for staged changes without committing. Use when you want a guarded commit or a ready-to-paste message.
Also in 3 projects that use this
MicrosoftSkillgrill-with-docs
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
Also in 3 projects that use this
OpenAISkillbrainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Also in 3 projects that use this
BlockSkillfrontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Also in 4 projects that use this
Other versions30 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 30
- davidondrej/skills★ 4.3ksame name
- iliaal/ai-skills★ 45same name
- sbluemin/fleet-harness★ 17same name
- BackToCimaCoppi/Praxis★ 6same name
- dzianisv/skills★ 4same name
- KroxiDev/engineering-skills★ 4same name
- MithunWijayasiri/dotclaude★ 4same name
- CodeWithBehnam/cc-docs★ 2same name
- hmj1026/dhpk★ 2same name
- yuri-xyz/skills★ 2same name
20 more not listed
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 repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- azure-paas-supportSkill
- azure-resource-abbreviationsSkill
- backlog-apiSkill
- csharp-file-based-appsSkill
- dependabot-auto-mergeSkill
- devblog-updatesSkill
- github-changelogSkill
- github-entra-federated-credentialsSkill
- hatena-blog-publisherSkill
- marp-cssSkill
- marp-deckSkill
- summarized-postSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. 0 are common, 11 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 25 edited versions we read keep these.
11
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Use the current local Git help and the official documentation when command behavior or version support matters:
- Distinctive: line 29
Do not state that a Git option is available until it has been checked against the user's Git version when compatibility is relevant.
- Distinctive: line 40
Before a state-changing command, inspect:
- Very specific: line 56
Use git worktree list --porcelain when a script or reliable parsing is needed.
- Distinctive: line 62
Prefer explicit branches and paths.
- Very specific: line 78
Use a relative sibling path such as ../project-feature only when the user has confirmed the layout.
- Very specific: line 83
Never suggest -B for a new worktree unless the user explicitly intends to reset an existing branch.
- Very specific: line 85
Do not add --force merely to bypass an error.
- Distinctive: line 87
If a branch is already checked out, list worktrees and use a different branch, remove the old worktree only after checking it is clean, or …
- Very specific: line 90
Before remove, check git -C <path> status --short.
- Very specific: line 95
Start stale cleanup with git worktree prune --dry-run --verbose.
- Distinctive: line 98
Treat paths containing spaces as one shell argument.
- Distinctive: line 102
After every mutation, show a concise verification sequence:
- Distinctive: line 152
If status is not clean, stop and explain the choices.
- Distinctive: line 156
If the primary repository and moved worktree still exist, run from the primary repository:
- Distinctive: line 163
If a worktree directory was intentionally deleted manually, preview stale entries first:
- Distinctive: line 172
Use this order unless the user asks for only a command:
- Very specific: line 179
Keep normal operations concise.
“Common” is measured: kept by at least 6 in 10 of the 25 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 Skill
Help users manage multiple working directories from one Git repository without accidentally sharing a branch, deleting uncommitted changes, or removing worktree metadata that Git needs. Git allows one non-detached branch to be checked out by only one worktree at a time; verify this constraint before creating or switching a worktree.
Source of truth
Use the current local Git help and the official documentation when command behavior or version support matters:
git worktree -h- https://git-scm.com/docs/git-worktree
Do not state that a Git option is available until it has been checked against the user's Git version when compatibility is relevant.
Workflow
1. Identify the intent and affected paths
Determine whether the user wants to create, inspect, move, lock, unlock, remove, repair, or prune a worktree. Identify the repository, target path, branch, and starting commit. Ask one focused clarification question when any of these would change the command or risk profile.
Before a state-changing command, inspect:
git rev-parse --show-toplevel
git worktree list --porcelain
git branch --show-current
git status --shortFor an existing worktree, inspect it explicitly:
git -C <worktree-path> status --short
git -C <worktree-path> branch --show-currentUse git worktree list --porcelain when a script or reliable parsing is needed. It is stable
across Git versions and configuration; combine it with -z only when code must safely parse
unusual path names.
2. Choose the safest command
Prefer explicit branches and paths. Do not rely on Git inferring a branch name from a directory name when a user needs a predictable checkout.
| Goal | Safe starting command |
| New worktree with a new task branch | git worktree add -b <branch> <path> [<start-point>] |
| Worktree for an existing branch that is not checked out elsewhere | git worktree add <path> <branch> |
| Temporary inspection at a commit without a branch | git worktree add --detach <path> <commit-ish> |
| See all registrations and their state | git worktree list --verbose |
| Protect a portable or long-lived worktree | git worktree lock --reason "<reason>" <path> |
| Allow an intentionally locked worktree to be managed | git worktree unlock <path> |
| Relocate a registered worktree | git worktree move <worktree> <new-path> |
| Reconnect metadata after moving/deleting paths manually | git worktree repair [<path>...] |
| Preview stale-registration cleanup | git worktree prune --dry-run --verbose |
| Remove a clean worktree | git worktree remove <path> |
Use a relative sibling path such as ../project-feature only when the user has confirmed the
layout. Otherwise show the exact absolute or repository-relative path being used.
3. Respect safeguards
- Never suggest
-Bfor a new worktree unless the user explicitly intends to reset an existing branch; it can discard branch history by resetting it to the chosen start point. - Do not add
--forcemerely to bypass an error. Explain which protection Git reported, inspect the affected branch or path, and offer a non-destructive alternative first. - If a branch is already checked out, list worktrees and use a different branch, remove the old worktree only after checking it is clean, or make a detached checkout when that serves the user's purpose. Do not force the same branch into two normal worktrees.
- Before
remove, checkgit -C <path> status --short. An empty result supports ordinary removal; non-empty output means changes need committing, moving, stashing, or explicit destructive confirmation. git worktree remove --forcediscards an unclean worktree. A locked worktree needs force twice. Only show either form after the user has explicitly accepted that loss or override.- Start stale cleanup with
git worktree prune --dry-run --verbose; runprune --verboseonly after reviewing the preview. Userepairwhen the on-disk worktree still exists but its registration links are out of date. - Treat paths containing spaces as one shell argument. Quote them in shell examples.
4. Verify the result
After every mutation, show a concise verification sequence:
git worktree list --verbose
git -C <worktree-path> status --short
git -C <worktree-path> branch --show-currentFor a newly created worktree, also confirm the branch relationship when relevant:
git -C <worktree-path> status --branch --shortCommon scenarios
Start a task without leaving the current branch
git fetch origin
git worktree add -b feature/<topic> ../<repository>-<topic> origin/mainExplain the chosen start point and replace origin/main with the repository's actual integration
branch when it differs. If the repository does not need a fetch, omit it rather than adding
network activity by default.
Work on an existing local branch
First confirm it is not already checked out:
git worktree list --verbose
git branch --show-currentThen use:
git worktree add ../<repository>-<branch> <branch>Remove a completed worktree
git -C ../<repository>-<topic> status --short
git worktree remove ../<repository>-<topic>
git worktree list --verboseIf status is not clean, stop and explain the choices. Do not silently stash or discard work.
Repair after a manual filesystem move
If the primary repository and moved worktree still exist, run from the primary repository:
git worktree repair <new-worktree-path>
git worktree list --verboseIf a worktree directory was intentionally deleted manually, preview stale entries first:
git worktree prune --dry-run --verbose
git worktree prune --verboseResponse format
Use this order unless the user asks for only a command:
- Situation — current worktree/branch state and the goal.
- Safe command — the smallest command sequence with placeholders replaced where known.
- Before running — branch, path, dirty-state, or destructive-operation caveats that apply.
- Verify — command(s) that prove the intended worktree is registered and clean.
Keep normal operations concise. When blocked by Git safeguards, describe the actual conflict and
present the safest alternatives rather than treating --force as the default solution.
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.

