# Custom directory location (default: ../worktrees)
WORKTREE_BASE_DIR=/custom/path ./scripts/create-worktree.sh feature-name
```

Or, if you’re using Claude Code, you can use the `/worktree` skill, which will prompt you for a name and base branch.

## What Gets Created

[Section titled “What Gets Created”](#what-gets-created)

When you create a worktree, the script:

1. Creates a new git worktree in `../worktrees/{name}` (configurable via `WORKTREE_BASE_DIR`)
2. Allocates unique ports for all services (Django, Vite, PostgreSQL, Redis)
3. Copies and configures `.env` with the new ports
4. Updates `DATABASE_URL` and `REDIS_URL` to use the allocated ports
5. Updates CORS settings to match the new Vite port
6. Copies Claude settings (if present)
7. Runs initial setup (`make setup-env` and `make npm-install-all`)

## Port Allocation

[Section titled “Port Allocation”](#port-allocation)

Worktrees get automatically assigned ports to avoid conflicts:

| Worktree   | Django | Vite | PostgreSQL | Redis |
| ---------- | ------ | ---- | ---------- | ----- |
| Main       | 8000   | 5173 | 5432       | 6379  |
| Worktree 1 | 8001   | 5174 | 5433       | 6380  |
| Worktree 2 | 8002   | 5175 | 5434       | 6381  |

Each worktree runs its own isolated PostgreSQL and Redis instances via Docker Compose, allowing you to:

* Work with different database schemas or data simultaneously
* Test migrations independently without affecting other worktrees
* Run integration tests in complete isolation

## Working in a Worktree

[Section titled “Working in a Worktree”](#working-in-a-worktree)

After creating a worktree:

```bash