skills/create-worktree/SKILL.md
Use when creating a git worktree for feature isolation with automatic environment setup including .env files and dependency installation
npx skillsauth add giladresisi/ai-dev-env create-worktreeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When this command is invoked with /create-worktree <branch-name> [base-branch] [path=<folder>], execute the following steps:
Extract the branch name, optional base branch, and optional path override from the command arguments.
Derive the worktree folder name:
path=<folder> argument was provided, use that./).
autoresearch/multisector-mar22 → multisector-mar22feature/auth → authfeature-auth → feature-auth (no slash, use as-is)The worktree will be created at ../{folder}. The git branch is still created as {branch-name} (preserving the full hierarchical name).
Execute the git worktree add command:
# If base-branch provided:
git worktree add ../{folder} -b {branch-name} {base-branch}
# If no base-branch provided:
git worktree add ../{folder} -b {branch-name}
The worktree will be created in the parent directory at ../{folder}.
../{folder} (the new worktree)Use Bash to find and copy all .env files. Because .env files are gitignored, Glob cannot see them — use find to discover them recursively:
# Find and copy all .env* files, excluding tooling directories
find . -maxdepth 6 \( -name ".env" -o -name ".env.local" -o -name ".env.*" \) \
! -path "*/.venv/*" ! -path "*/node_modules/*" ! -path "*/.git/*" | while read env_file; do
env_file="${env_file#./}"
target_dir=$(dirname "../{folder}/$env_file")
mkdir -p "$target_dir"
cp "$env_file" "../{folder}/$env_file"
echo "Copied $env_file"
done
This approach:
.env, .env.local, and .env.* files at any depth (up to 6 levels).venv, node_modules, and .git directoriesmkdir -pCheck which Python package manager the project uses, then install dependencies in the worktree:
If project uses uv (has pyproject.toml + uv.lock):
uv sync — recreates .venv from the lockfile, no copying needed# uv projects — run in the worktree backend directory
cd ../{folder}/backend
uv sync
If project uses pip (has requirements.txt):
# Copy venv (all platforms)
cp -r backend/venv ../{folder}/backend/venv
# Install dependencies
# Windows
cd ..\{folder}\backend && venv\Scripts\python -m pip install -r requirements.txt
# Unix/Mac
cd ../{folder}/backend && venv/bin/python -m pip install -r requirements.txt
Check both top-level and backend/ for pyproject.toml/uv.lock or requirements.txt.
Use Glob to find all package.json files in:
package.jsonfrontend/package.jsonbackend/package.jsonFor each package.json found:
# Windows
cd ..\{folder}\frontend
npm install
# Unix/Mac
cd ../{folder}/frontend
npm install
Important: Install npm dependencies in ALL directories that have a package.json file (top-level, frontend/, backend/, or any other subdirectories).
Provide a summary to the user:
../{folder}Detect the platform using:
# Check if Windows (look for .bat or .ps1 files, or check OS)
uname -s # Returns "MINGW64_NT" or similar on Windows Git Bash
Use appropriate commands (copy vs cp, robocopy vs cp -r, Scripts vs bin) based on platform.
User runs: /create-worktree feature-auth main
Expected output (branch has no /, so folder = branch name):
Creating worktree 'feature-auth' based on 'main'...
✓ Worktree created at ../feature-auth
Copying .env files...
✓ Copied backend/.env
✓ Copied frontend/.env
Installing Python dependencies...
✓ uv sync in backend/ (recreated .venv from uv.lock)
Installing npm dependencies...
✓ Installed frontend/package.json (127 packages)
✓ Installed backend/package.json (43 packages)
Worktree setup complete! You can now work in ../feature-auth
User runs: /create-worktree autoresearch/multisector-mar22 master
Expected output (last segment of branch name used as folder):
Creating worktree 'autoresearch/multisector-mar22' based on 'master'...
✓ Worktree created at ../multisector-mar22
(branch: autoresearch/multisector-mar22, folder: multisector-mar22)
...
Worktree setup complete! You can now work in ../multisector-mar22
testing
Creates a new git worktree in the auto-co-trader project for any purpose — optimization, regression, backtesting, brainstorming, etc. Use this skill when the user wants to CREATE or SET UP a new worktree — phrases like "prepare a new worktree", "set up a worktree", "create a new worktree for <purpose>", "prep a new worktree", "new worktree for autoresearch", "prepare optimization from [strategy]", or "create a worktree using [strategy]". Do NOT use this skill when the user is already in a worktree and wants to start/run/begin a task — that is handled by the relevant program file in the worktree session.
development
Use when running comprehensive project validation including tests, type checking, linting, API connectivity checks, and server startup verification
research
Use when performing a meta-level analysis of plan adherence after implementation to identify process improvements and suggest CLAUDE.md updates
documentation
Use when investigating a GitHub issue to identify root cause, assess impact, and create a fix strategy document