git-worktree
Skill4 starsChanged 17 days agoMITView on GitHub
Use when the user asks to create, enter/switch to, or remove a git worktree on Windows — makes it under `.claude/worktrees/` and provisions a shared node_modules (junction) and local `.env` so it runs without a reinstall. Windows + PowerShell only. Trigger on `/git-worktree`.
- Reads credentials
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
- CodeWithBehnam/cc-docs★ 2same name
- hmj1026/dhpk★ 2same name
- tsubakimoto/skills★ 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 repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ask-firstSkill
- claude-project-rulesSkill
- compact-markdownSkill
- humanizeSkill
- pr-reviewSkill
- empty-commitSkill
- github-issue-creatorSkill
- git-mergeSkill
- handoff-sessionSkill
- html-landing-pageSkill
- offload-taskSkill
- readme-craftSkill
- skill-auditSkill
- study-notesSkill
- visualize-itSkill
- zoom-outSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 25 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Never npm install / npm ci in a worktree whose node_modules is a junction — mutates main repo's deps.
- Very specific: line 17
Never delete a worktree directory while a node_modules junction is live.
- Very specific: line 109
Only .env* copied. Other gitignored local state — saved auth/session state, tokens, caches, build output — absent.
“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
Windows + PowerShell only. Worktrees live at <repo>/.claude/worktrees/<name>. Add .claude/worktrees/ to the repo's .gitignore — Claude Code doesn't.
Scripts: scripts/wt-create.ps1, scripts/wt-remove.ps1 (PowerShell 5.1+). Run as powershell -NoProfile -File <skill dir>\scripts\<script>.ps1 .... Below, $SKILL = this skill's directory (e.g. $HOME\.claude\skills\git-worktree).
Commands: create (/git-worktree feature-login), switch (/git-worktree switch), remove (/git-worktree remove). Bare /git-worktree → switch.
Hard rules
- Never
npm install/npm ciin a worktree whosenode_modulesis a junction — mutates main repo's deps. Only the drift path (Create step 3,npm cioption) makes a realnode_moduleswhere installing is safe. - Never delete a worktree directory while a
node_modulesjunction is live. Unlink first (Remove step 3) — a recursive delete that follows the junction can eat main'snode_modules. - Removal always user-confirmed. Never automatic, never inferred from "PR raised" or "work done".
- Copy
.env, never link it. A link → worktree edit silently rewrites the real secrets file.
Create
1. Guard. Record MAIN = git rev-parse --show-toplevel first — after entering, cwd is the worktree and this resolves differently.
powershell -NoProfile -File "$SKILL\scripts\wt-create.ps1" -Main "$MAIN"Exit 1 → already inside .claude/worktrees/; worktrees don't nest. Tell user to /git-worktree remove or exit first.
2. Enter. EnterWorktree(name: "<name>") → creates .claude/worktrees/<name> on a new branch, switches session cwd. Set WT = returned path. Report the branch name from the result.
Base ref = worktree.baseRef setting: fresh (default) branches from origin/<default-branch>, head from current local HEAD. Don't change it. User wants to stack on unpushed local work → worktree.baseRef must be head in settings first; don't flip it silently.
3. node_modules + .env (one script):
powershell -NoProfile -File "$SKILL\scripts\wt-create.ps1" -Main "$MAIN" -Wt "$WT"Script:
- node_modules skipped if
$WT\package.jsonabsent,$WT\node_modulesexists, or main has none. - Compares on-disk
package-lock.json(main's installed tree matches main's working-copy lockfile, not any committed ref). Identical → junction. Junctions need no admin or Developer Mode, unlike symlinks. - Copies root-level
.env*from main that Wt lacks. Gitignored, so checkout has none; tracked ones already present, so the existence check is the whole filter. - Prints
node_modules: <mode>andenv copied: <files>.
Exit codes: 0 ok, 1 error/guard refusal, 2 lockfile DRIFT.
Exit 2 (also when lockfile missing on either side) → not linked; branch's deps don't match what's installed. .env still copied. Stop, report, ask user:
- junction anyway (read-only work, raising a PR without running anything) → re-run with
-ForceJunction, or npm ciin$WT— gives a realnode_modules; slow, use a long timeout (10 min). Needs$WT\package-lock.jsonornpm-shrinkwrap.json; neither → offer the project's own install command instead.
Exit 1 → report the printed error.
WARN junction (existing) (exit 0, Switch re-run) → branch's lockfile changed since linking. Report it; any install needs wt-remove.ps1 -Unlink first, else npm ci writes into main's node_modules.
4. Report path, branch, base, node_modules mode (junction / real / skipped), files copied, and what Not provisioned leaves out.
Switch
List candidates with branch and dirty state; user picks:
git worktree list --porcelaingit -C <path> status --short per entry for dirty state.
Set MAIN = first worktree entry of that list (the main worktree) before entering; Create step 3 needs it.
EnterWorktree(path: "<chosen>"), then re-run Create step 3 — worktrees from a bare git worktree add, or made before this skill, usually lack node_modules and .env.
From inside a worktree, EnterWorktree(path) only reaches worktrees under the same repo's .claude/worktrees/. Worktrees elsewhere (sibling dirs) → exit to main repo first.
Remove
1. Identify target: current worktree, or the one user named.
2. Report and confirm.
powershell -NoProfile -File "$SKILL\scripts\wt-remove.ps1" -Wt "$WT" -ReportLists uncommitted files, ignored files (copied .env, build output; node_modules excluded, step 3 handles it), and unpushed commits on the worktree's HEAD (capped at 30 each). Wait for explicit confirmation. Any list non-empty → say so plainly; that work dies with the worktree.
3. Unlink node_modules — after confirmation, before any removal command touches the directory:
powershell -NoProfile -File "$SKILL\scripts\wt-remove.ps1" -Wt "$WT" -UnlinkRemoves the junction only (non-recursive DirectoryInfo.Delete(); target keeps contents). Real directory or none → untouched. Exit codes: 0 ok, 1 error, 3 node_modules is a non-junction link (e.g. symlink) → stop, tell user. Script never removes the worktree itself.
4. Remove. Session created the worktree via EnterWorktree → ExitWorktree(action: "remove") (discard_changes: true only after user confirmed step 2).
Otherwise ExitWorktree(action: "keep") to return to main repo, then:
git worktree remove <path>
git branch -d <branch>
git worktree pruneremove refusing a dirty tree needs --force; branch -d refusing an unmerged branch needs -D. Both only after step-2 confirmation, never pre-emptively. remove failing as locked → git worktree unlock <path>, retry.
Not provisioned
Only .env* copied. Other gitignored local state — saved auth/session state, tokens, caches, build output — absent; project's own setup step regenerates it on first run. Say so in the create report so a slow first run isn't mistaken for failure.
Per-repo one-time check
Root-level tooling that globs the whole tree compiles/lints every nested worktree copy. First use in a repo → check all three, offer fixes:
- .gitignore — needs
.claude/worktrees/. - tsconfig — affected only when
includeis unanchored from repo root (["./**/*.ts"]). Includes anchored to a source dir (["src/**/*.ts"]) never reach.claude/; addingexcludethere is dead config. When it applies, addingexcludediscards TypeScript's implicit default → listnode_modulesalongside.claude. - eslint — nearly always affected, regardless of tsconfig. Flat config (
eslint.config.mjs) auto-ignores only**/node_modules/and.git/→.claudeneeds an explicitglobalIgnoresentry; eslintrc needsignorePatterns. Worse withparserOptions.project+createDefaultProgram: true— worktree files fall outside the project's program, each gets a slow fallback program.
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.

