From stylish-git
Create a git worktree in a sibling directory for isolated feature work
How this skill is triggered — by the user, by Claude, or both
Slash command
/stylish-git:create-worktreeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Create a git worktree as a sibling directory of the current project and set up the development environment.
Create a git worktree as a sibling directory of the current project and set up the development environment.
Language rule: Communicate with the user in the same language they are using. If Korean, respond in Korean. If English, use English. Only commands and file paths remain as-is.
git_root=$(git rev-parse --show-toplevel)
project_name=$(basename "$git_root")
parent_dir=$(dirname "$git_root")
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")
Extract branch info from the user's request.
Prefix — infer from work context:
| Prefix | Purpose |
|---|---|
feature/ | New feature |
fix/ | Bug fix |
chore/ | Maintenance, refactoring |
docs/ | Documentation |
Branch name — extract keywords from the user's description.
feature/login-pageIf both prefix and name can be inferred confidently, propose and proceed. If uncertain, ask the user.
Directory name follows {project}-{feature-keyword} pattern.
Feature keyword is the core word(s) from the branch name without the prefix.
# e.g., project=my-app, branch=feature/login-page → my-app-login-page
worktree_dir="$parent_dir/${project_name}-${feature_keyword}"
git worktree add "$worktree_dir" -b "$branch_name"
Conflict handling:
Detect the package manager from the lockfile in the worktree root. Skip this step if no lockfile is found.
| Lockfile | Install command |
|---|---|
pnpm-lock.yaml | pnpm install |
yarn.lock | yarn install |
package-lock.json | npm install |
bun.lockb / bun.lock | bun install |
After installing dependencies, run the build script from package.json if it exists.
(Required for monorepos or projects with inter-package dependencies)
Worktrees do not include .gitignored files, so copy necessary config from the original.
Scan the entire tree since nested packages may also have .claude/ directories.
cd "$git_root"
fd -H -I -t d --glob '.claude' --exclude node_modules --exclude .git \
| while read dir; do
mkdir -p "$worktree_dir/$dir"
cp -r "$dir/." "$worktree_dir/$dir/"
done
If .env, .env.local, or similar environment files exist, ask the user whether to copy them.
Ask the user if they need anything else:
| Item | Value |
|---|---|
| Path | /full/path/to/worktree |
| Branch | feature/login-page |
| Base | main (abc1234) |
| Dependencies | Installed (pnpm) |
cd)/stylish-git:cleanup-branchnpx claudepluginhub stylelist94/claude-plugins --plugin stylish-gitGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.