Skip to content

kurotch321/create-worktree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

create-wt

A bash tool that creates git worktrees with environment files and settings automatically copied over. Designed for use with Claude Code's multi-worktree workflow.

What it does

  1. Creates a new git worktree as a sibling directory (../<repo>-wt<N>, auto-numbered)
  2. Copies gitignored .env* files from repo root and packages/*/ (monorepo support)
  3. Copies .claude/settings.local.json if present
  4. Auto-detects and runs the appropriate package manager install (pnpm > yarn > npm)
  5. cds into the worktree and launches claude (default behavior)

Installation

Copy the create-wt script to somewhere on your PATH:

cp create-wt /usr/local/bin/

Or clone and symlink:

git clone https://github.com/kurotch321/create-worktree.git
ln -s "$(pwd)/create-worktree/create-wt" /usr/local/bin/create-wt

Usage

create-wt <branch>                    # branch from HEAD, then cd + claude
create-wt <branch> --base <base-ref>  # branch from specific ref, then cd + claude
create-wt <branch> --create-only      # create worktree only (no cd/claude)

Examples

# Start working on a feature branch in a new worktree
create-wt feat/123-new-api

# Branch from staging instead of HEAD
create-wt feat/123-new-api --base staging

# Just create the worktree without launching claude
create-wt feat/fix-bug --create-only

Options

Option Description
<branch> Branch name to create (required)
--base <ref> Base branch/commit to create from (default: HEAD)
--create-only Create worktree only, skip cd and claude launch
-h, --help Show help

How it works

The script must be run from inside a git repository. It will:

  1. Find the repo root via git rev-parse --show-toplevel
  2. Create a worktree at ../<repo-name>-wt<N> (auto-increments N to avoid collisions)
  3. If the branch already exists, check it out; otherwise, create it from --base (default: HEAD)
  4. Copy any .env* files that are gitignored (checked via git check-ignore -q)
  5. For monorepos, also copy .env* files from packages/*/
  6. Copy .claude/settings.local.json if it exists
  7. Run the detected package manager's install command (pnpm install --frozen-lockfile, yarn install --frozen-lockfile, or npm ci)
  8. cd into the worktree and launch claude (unless --create-only is set)

Requirements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages