Skip to content
Agentmart
Submit a tool

create-worktree

Use when creating a git worktree for feature isolation with automatic environment setup including .env files and dependency installation

Skill by giladresisi

IndexedMIT★ 2
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/giladresisi-create-worktree

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use when creating a git worktree for feature isolation with automatic environment setup including .env files and dependency installation

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/create-worktree

What's inside

Skill name
create-worktree
Description
Use when creating a git worktree for feature isolation with automatic environment setup including .env files and dependency installation
License
MIT
Instructions
171 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Create Worktree with Environment Setup

When this command is invoked with `/create-worktree <branch-name> [base-branch] [path=<folder>]`, execute the following steps:

## Step 1: Parse Arguments

Extract the branch name, optional base branch, and optional path override from the command arguments.

Derive the **worktree folder name**:
- If an explicit `path=<folder>` argument was provided, use that.
- Otherwise, use the **last segment** of the branch name (the part after the final `/`).
  - `autoresearch/multisector-mar22` → `multisector-mar22`
  - `feature/auth` → `auth`
  - `feature-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).

## Step 2: Create Git Worktree

Execute the git worktree add command:

```bash
# 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}`.

## Step 3: Identify Source and Target Paths

- **Source:** Current working directory (the original repo)
- **Target:** `../{folder}` (the new worktree)

## Step 4: Copy .env Files

Use Bash to find and copy all .env files. Because .env files are gitignored, Glob cannot see them — use `find` to discover them recursively:

```bash
# 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:
1. Discovers all `.env`, `.env.local`, and `.env.*` files at any depth (up to 6 levels)
2. Excludes `.venv`, `node_modules`, and `.git` directories
3. Creates target subdirectories as needed with `mkdir -p`
4. Works with gitignored files that Glob cannot see

## Step 5: Install Python Dependencies

Check which Python package manager the project uses, then install dependencies in the worktree:

**If project uses `uv`** (has `pyproject.toml` + `uv.lock`):
- Run `uv sync` — recreates `.venv` from the lockfile, no copying needed

```bash
# uv projects — run in the worktree backend directory
cd ../{folder}/backend
uv sync
```

**If project uses `pip`** (has `requirements.txt`):
- Copy the existing venv, then run pip install

```bash
# 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`.

## Step 7: Install npm Dependencies

Use Glob to find all `package.json` files in:
- Top-level: `package.json`
- Frontend: `frontend/package.json`
- Backend: `backend/package.json`

For each package.json found:
1. Navigate to the target worktree directory containing the package.json
2. Run npm install

```bash
# 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).

## Step 8: Report Completion

Provide a summary to the user:
- Worktree created at: `../{folder}`
- .env files copied: [list]
- Python dependencies installed in: [list] (method: uv sync / pip install)
- npm dependencies installed in: [list]

## Platform Detection

From giladresisi/ai-dev-env, MIT.

More from giladresisi/ai-dev-env

Signals

Stars
2
Forks
0
Open issues
0
Last commit (this folder)
May 2, 2026 (6 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from giladresisi

Cite this page

create-worktree skill. Agent Mart. https://agentmart.dev/skills/giladresisi-create-worktree (last updated 2026-10-24)