Git Worktree Setup
When the user asks to work on something in parallel or separately, always create a git worktree. This ensures the new work is fully isolated in its own directory and Cursor window, without affecting any in-progress work.
Worktree location
All worktrees live in ../worktrees/ relative to the repository root.
Workflow
1. Choose branch prefix
Every branch must use one of these prefixes:
| Prefix | Use when |
|---|---|
feature | New functionality, new screens, new flows. Default when unclear. |
bugfix | Fixing a bug, crash, or incorrect behaviour. |
qol | Quality of life: UI polish, small improvements, refactors, DX. |
Derive from the user's request (e.g. "fix the PDF crash" → bugfix, "tweak the invoice list" → qol).
2. Determine ticket context
- •Ticket number provided (e.g. "ticket 1234", "AB#1087"): use it. The branch name will include the ticket (e.g.
feature/AB-1234-facturen-export). - •No ticket, just a description: use
--no-ticket. Branch has no ticket number (e.g.feature/login-page-redesign). - •Ambiguous: ask if they want to link an ADO ticket, or proceed with
--no-ticket.
3. Run the setup script
Execute from the repository root. First argument is always the prefix (feature, bugfix, or qol).
With a ticket number (branch includes ticket):
bash scripts/worktree/new-worktree.sh <prefix> <ticket-number> <short-description>
Examples:
- •
bash scripts/worktree/new-worktree.sh feature 1234 facturen-export→feature/AB-1234-facturen-export - •
bash scripts/worktree/new-worktree.sh bugfix 5678 pdf-crash-fix→bugfix/AB-5678-pdf-crash-fix - •
bash scripts/worktree/new-worktree.sh qol 1087 ui-tweaks→qol/AB-1087-ui-tweaks
Without a ticket number:
bash scripts/worktree/new-worktree.sh <prefix> --no-ticket <short-description>
Examples:
- •
bash scripts/worktree/new-worktree.sh feature --no-ticket login-page-redesign→feature/login-page-redesign - •
bash scripts/worktree/new-worktree.sh bugfix --no-ticket pdf-crash→bugfix/pdf-crash
Short description: lowercase, kebab-case, 2–4 words. Examples: facturen-export, login-page-redesign, pdf-crash-fix.
The script will:
- •Fetch latest from remote (
git fetch origin) - •Resolve the latest
origin/developSHA and verify no stale local branch exists - •Create a new branch starting from the latest
origin/develop— always a fresh checkout, never a local or outdated develop - •Copy
.envinto the worktree - •Run
npm install - •Run
npx prisma generate(ifprisma/schema.prismaexists) - •Open the worktree in a new Cursor window via the
cursorCLI
4. Confirm to the user
Report:
- •The worktree path
- •The branch name (with prefix: feature/, bugfix/, or qol/; with ticket number when one was used)
- •That a new Cursor window has been opened
- •Remind them they can start working in the new window
5. (Optional) Set ADO ticket to Active
Only if a ticket number was provided or resolved. Use user-ado MCP:
wit_update_work_item(id, updates: [{ op: "add", path: "/fields/System.State", value: "Active" }])
Listing existing worktrees
git worktree list
Important notes
- •Never check out the same branch in two worktrees.
- •Each worktree has its own
node_modulesand.env— they are not shared. - •The
.cursor/directory (rules, skills, agents) is part of the repo and available in every worktree automatically. - •If the worktree directory already exists, the script will abort — remove the old one first or choose a different name.