git-worktree
Skill2 starsChanged 3 months agoMITView on GitHub
Create, synchronize, and safely retire isolated Git worktrees for implementation work. Use whenever the user asks to work in a worktree, isolate a change on a branch, create a feature checkout, update a worktree after branch changes, or clean up merged worktrees, or says "make sure its in a worktree", "/implement in a worktree", or "in a new worktree / branch". Clone or fork into `~/git/<provider>/<user>/<repo>` (a normal `git clone` already follows `~/git/github.com/anthonyposchen/<repo>`); do not `gh repo fork --clone` into the current directory. New worktrees mirror a source checkout below ~/git at ~/worktree/<provider>/<user>/<repo>/<branch-name>.
27 other projects use a version of this.
Adopted by
Most recently taken up by
- KroxiDev/engineering-skillstheir own version, first seen Oct 5, 2026
- fmind/dottheir own version, first seen Oct 5, 2026
- sbluemin/fleet-harnesstheir own version, first seen Oct 4, 2026
- iliaal/ai-skillstheir own version, first seen Oct 3, 2026
- davidondrej/skillstheir own version, first seen Oct 3, 2026
- aprameyak/coding-skillstheir own version, first seen Oct 2, 2026
Used with
Projects with it also use caveman, triage and 4 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.
MicrosoftSkillcaveman
Ultra-compressed response style that reduces output token count while preserving technical accuracy, with intensity levels and auto-clarity safety rules
Also in 3 projects that use this
Google CloudSkilltriage
Gather context on a change or bug and plan the implementation.
Also in 3 projects that use this
AWSSkillgrill-me
A relentless interview to sharpen a plan or design.
Also in 4 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
AWSSkilltdd
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
Also in 3 projects that use this
GoogleSkillcode-review
Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.
Also in 4 projects that use this
Other versions27 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 27
- davidondrej/skills★ 4.1ksame name
- nwiizo/ccswarm★ 153same name
- ratacat/claude-skills★ 56same name
- iliaal/ai-skills★ 43same name
- sbluemin/fleet-harness★ 17same name
- cropsgg/skills★ 15same name
- fmind/dot★ 10same name
- caidanw/skills★ 9same name
- BackToCimaCoppi/Praxis★ 6same name
- dzianisv/skills★ 4same name
17 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 repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- act-within-scopeSkill
- asd-ste100Skill
- codingSkill
- context-managementSkill
- create-verification-skillSkill
- dockerfileSkill
- domain-modelingSkill
- encode-lessonsSkill
- experience-firstSkill
- eyes-onSkill
- flux-ghcr-image-automationSkill
- flux-kustomize-layoutSkill
- frontend-designSkill
- git-commit-workflowSkill
- grill-with-docsSkill
- implement-ticketsSkill
- maintain-verification-skillSkill
- makefileSkill
- omarchy-developmentSkill
- releaseSkill
- skill-evaluationSkill
- technical-writingSkill
- test-auditSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 8 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 22 edited versions we read keep these.
8
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
- Distinctive: line 10
Keep implementation changes isolated from the primary checkout while making every checkout easy to find.
- Very specific: line 23
Keep slashes in a branch name as path separators.
- Distinctive: line 40
If already inside a linked worktree, check that its path equals the derived target and that it is on the intended branch.
- Very specific: line 48
Create the target's parent directories, then create the worktree from the source checkout: use git worktree add -b <branch> <target> for a …
- Distinctive: line 60
Treat a worktree as the checkout for one branch for its full lifetime.
- Distinctive: line 62
Create or resume the worktree before editing it.
- Distinctive: line 63
When you learn that its branch changed remotely, was rebased, or received review changes, synchronize it before doing more work.
- Distinctive: line 75
When a branch is known to be merged, run the guarded cleanup immediately from the primary checkout:
- Very specific: line 85
When the user abandons an unmerged branch, remove its clean checkout from the primary checkout with worktree-lifecycle.sh remove …
- Distinctive: line 89
After a worktree directory was manually removed or a filesystem restore, inspect with git worktree list and run git worktree prune only …
- Very specific: line 93
Run worktree-lifecycle.sh cleanup-merged without --apply to preview every candidate.
- Very specific: line 99
When the user asks for automatic cleanup, run worktree-lifecycle.sh install-post-merge-hook from the primary checkout.
- Distinctive: line 112
Do not create a worktree for the primary branch when it is already checked out in the primary checkout.
“Common” is measured: kept by at least 6 in 10 of the 22 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
Goal
Keep implementation changes isolated from the primary checkout while making every checkout easy to find. A source repository at:
~/git/<provider>/<user>/<repo>has branch worktrees at:
~/worktree/<provider>/<user>/<repo>/<branch-name>Keep slashes in a branch name as path separators. For example,
feature/add-search belongs at
~/worktree/github/acme/widgets/feature/add-search.
Workflow
- Confirm the current directory belongs to a Git working tree with
git rev-parse --show-toplevel. Resolve its canonical path. - Find the primary checkout with
git worktree list --porcelain. Its path must be below~/git/; otherwise stop and ask for a source checkout or an explicitly approved path. Do not guess a different storage layout. - Choose the branch named by the user. If none is named, derive a concise,
descriptive branch name from the requested work and state it before
creating the worktree. Validate it with
git check-ref-format --branch. - Derive the relative source path below
~/git/, then construct the exact target path below~/worktree/by appending the branch name. Do not shorten, flatten, hash, or otherwise change either part of the path. - If already inside a linked worktree, check that its path equals the derived target and that it is on the intended branch. Continue there only when both match. If it is an older worktree at another path, leave it untouched and ask before changing location.
- Inspect
git worktree list --porcelainbefore creating anything. If the target already exists and is registered, resume it. If the branch is already checked out elsewhere, do not force it into another worktree; resume that checkout when it matches the required target or ask for a different branch. - Create the target's parent directories, then create the worktree from the
source checkout: use
git worktree add -b <branch> <target>for a new branch, orgit worktree add <target> <branch>for an existing unoccupied branch. Base a new branch on the source checkout's currentHEADunless the user specifies another base. - Change into the target and verify
git rev-parse --show-toplevel,git branch --show-current, andgit status --short. Perform all requested edits, tests, and commits from this worktree. Never edit the primary checkout as part of this workflow.
Manage the lifecycle
Treat a worktree as the checkout for one branch for its full lifetime.
- Create or resume the worktree before editing it.
When you learn that its branch changed remotely, was rebased, or received review changes, synchronize it before doing more work. From the primary checkout, run this Bash helper:
<skill-path>/scripts/worktree-lifecycle.sh sync <branch-name>The command fetches the branch's remote, then fast-forwards only a clean worktree. If the worktree has local changes or diverged history, leave it intact and report the condition instead of stashing, resetting, rebasing, or forcing an update.
When a branch is known to be merged, run the guarded cleanup immediately from the primary checkout:
<skill-path>/scripts/worktree-lifecycle.sh cleanup-merged --applyIt fetches the default remote branch, removes only clean mirrored worktrees whose branches are ancestors of that branch, and then deletes their merged local branches. It never deletes remote branches.
- When the user abandons an unmerged branch, remove its clean checkout from
the primary checkout with
worktree-lifecycle.sh remove <branch-name>. Keep the branch unless the user explicitly asks to delete it. - After a worktree directory was manually removed or a filesystem restore,
inspect with
git worktree listand rungit worktree pruneonly when the stale entries are understood.
Run worktree-lifecycle.sh cleanup-merged without --apply to preview every
candidate. Report skipped dirty, detached, non-mirrored, and unmerged worktrees
so the user can decide their fate.
Automate local merge cleanup
When the user asks for automatic cleanup, run
worktree-lifecycle.sh install-post-merge-hook from the primary checkout. The
opt-in hook runs the same guarded merged-branch cleanup after a local merge or
pull. It refuses to overwrite another hook. It needs Bash and Git.
Hosted Git providers cannot run a command on this machine when a pull request is merged remotely. When an agent learns about that merge, it must run the cleanup step above; the fetch in that command makes remote merges visible locally.
Safety
- Preserve existing worktrees, branches, and uncommitted changes. Do not use
--force, remove a worktree, prune metadata, reset, or clean as setup. - Do not create a worktree for the primary branch when it is already checked out in the primary checkout. Choose a task branch instead.
- Report the branch and absolute worktree path before beginning the requested implementation. Cleanup after a known merge is part of this lifecycle; all other cleanup requires an explicit user request.
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.

