Create a new git worktree from origin/trunk in ~/worktrees.nosync and copy node_modules. Use when the user wants to "create a worktree", "new worktree", "start a worktree branch", or needs an isolated working directory for a feature branch.
Ships in sejas-ai-code-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Create a new git worktree based on origin/trunk in ~/worktrees.nosync, with node_modules copied from the current directory for fast setup.
Gather information:
Fetch latest from origin:
git fetch origin trunk
Create the worktree directory if needed:
mkdir -p ~/worktrees.nosync
Append a timestamp suffix to the branch name to keep it unique, then create the worktree:
SUFFIX=$(date +%m%d%H) # monthdayhour, e.g. 072415
git worktree add ~/worktrees.nosync/<branch-name>-$SUFFIX -b <branch-name>-$SUFFIX origin/trunk
The suffix applies to both the branch and the worktree directory (they share the name). If the user explicitly asks for an exact branch name with no suffix, skip it.
Copy node_modules if it exists in the source directory. Use cp -c — on APFS it clones the files instead of copying bytes, so a multi-GB node_modules lands instantly and costs no extra disk until something writes to it. Fall back to a plain copy on non-APFS volumes:
SRC=$(git rev-parse --show-toplevel); WT=~/worktrees.nosync/<branch-name>-$SUFFIX
cd "$SRC" && find . -maxdepth 4 -name node_modules -type d -not -path "*/node_modules/*" | while read -r nm; do
mkdir -p "$WT/$(dirname "$nm")"
cp -Rc "$SRC/$nm" "$WT/$nm" 2>/dev/null || cp -R "$SRC/$nm" "$WT/$nm"
done
The find loop also picks up per-workspace node_modules (monorepos), not just the root one — miss those and workspace builds fail in the worktree.
Report success with the path to the new worktree:
Worktree created at: ~/worktrees.nosync/<branch-name>-<suffix>
If the user doesn't specify a branch name, suggest a format based on context:
feature/<short-description>fix/<issue-id> or fix/<short-description>stu-<ticket-number>-<short-description> (for Studio)Always remove worktrees through git, never rm -rf the directory. A manual rm leaves git's admin entry (<repo>/.git/worktrees/<name>) behind, or deleting the admin entry leaves the on-disk dir behind — either way you get orphans that git worktree prune cannot detect, silently wasting disk (build dirs alone can be multiple GB per orphan).
Correct teardown:
git worktree remove ~/worktrees.nosync/<branch-name> # refuses if uncommitted work — that's the safety net
git worktree prune # sweep any stale admin entries
When the user asks to "check worktrees", "clean up worktrees", or "worktree doctor", run this from inside the repo to list on-disk dirs that git no longer tracks:
comm -23 \
<(ls -d ~/worktrees.nosync/*/ 2>/dev/null | xargs -n1 basename | sort) \
<(git worktree list --porcelain | sed -n 's#.*worktrees.nosync/##p' | sort)
Each line printed is an orphan (dir exists, not registered). Before deleting any orphan:
.git pointer: cat ~/worktrees.nosync/<name>/.git — and whether the admin dir it names still exists.out, dist, node_modules, cli, bin) are regenerable — safe to strip first to reclaim the bulk of the space cheaply.rm -rf, then git worktree prune.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
40 skills in this plugin
/ai-prsList all open PRs targeting the Studio AI command with draft status, approval state, and requested reviewers/ai-radarUse when Antonio wants to catch up on frontier AI — "what's new in AI", "AI radar", "what is karpathy working on", "AI trends", "research digest", "what should I learn next", "where to invest learning time", or /ai-radar./blog-postThis skill should be used when the user asks to "write a blog post", "draft a blog post", "create a blog post", "write an article about", or wants to produce a markdown blog post on any topic. Outputs to ~/claude.nosync/posts/./sejas-ai-code-skills:worktreefrom sejas-ai-code-skills
sejas-ai-code-skills@cascade-code-general-misc-3 is listed by joshuarweaver/cascade-code-general-misc-3 — review the source before installing
npx claudepluginhub joshuarweaver/cascade-code-general-misc-3 --plugin sejas-ai-code-skills