Skip to Content
Orca Guide
Daily Workflow

Worktree Isolation & The 4 Real Pitfalls

Understand base ref vs start-from ref, Pinned worktrees, Force Delete & Preserved branches, plus concrete scripts.setup fixes for dependencies, .env files, port collisions, and shared DBs.

Orca 1.4.xUpdated 2026-12-0410 minDaily WorkflowUnofficial Community Guide

🎯 Goal

  • Master Orca's worktree lifecycle: base ref vs start-from ref, Pinned worktrees, Force Delete (plus Always force delete), and Preserved branches.
  • Eliminate the 4 real engineering pitfalls that git worktree does NOT isolate automatically: missing dependencies, gitignored .env secrets, localhost port collisions, and shared database / Docker volume pollution.

📋 Prerequisites

  • At least one repository added to Orca with local dependencies (package.json / pyproject.toml), .env config, or a local dev server.
  • Knowledge of your dev server's default port (e.g., :3000 / :5173) and local database setup (SQLite / Postgres / Docker Compose).

Before editing your config, explore the interactive Workspace Simulator below—click across the 3 worktrees and open the Env & Ports tab to see how true workspace isolation looks across paths, .env.local, ports, and DB schemas:

acme/web-app
3x parallel quota
Claude Codelocalhost:3001
zsh · .orca/worktrees/acme-web-app/feat-oauth-pkceGhostty Engine
$ claude "Implement PKCE code_verifier & callback exchange with tests"
● Read src/auth/session.ts, src/app/api/auth/callback/route.ts
● Edit src/auth/pkce.ts (+118 -14) · added S256 challenge & timing-safe check
● Run PORT=3001 npm test -- auth/pkce.test.ts
✓ 14/14 PKCE assertions passed · dev server live on http://localhost:3001
⟳ Generating edge-case test for expired state cookie...

🛠️ Step-by-Step

Core Worktree Model: Refs, Pinning & Safe Cleanup

Keep these four Orca primitives clear when juggling parallel branches:

PrimitiveBehaviorWhen to Use
base refRepo-level baseline (defaults to origin/main) for diff targets and PR bases.Change in repo settings if your main integration branch is master or develop.
start-from refPer-worktree origin branch or commit selected when spawning a new worktree.Stack work onto an unmerged feature branch, or launch 3 agents from the exact same commit hash.
Pinned worktreesKeeps key worktrees anchored at the top of the sidebar.Pin long-lived feature branches or a clean reference checkout so short-lived runs never bury them.
Force Delete & Preserved branchesNormal deletion warns on dirty files or unmerged work; Force Delete (and the arrow-menu Always force delete) removes the worktree directory cleanly.Whenever a branch has local unmerged commits, Orca's Preserved branches safety guard keeps the local Git branch intact after deleting the worktree so committed work is never silently lost.

Use Always Force Delete Intentionally

Enabling Always force delete from the delete button's arrow menu speeds up tearing down losing race branches—just remember untracked scratch files inside that worktree directory are removed immediately (only committed work is protected by Preserved branches).

Pitfall 1: Missing Dependencies (node_modules / .venv)

Why it happens: git worktree add checks out Git-tracked files only. Ignored directories like node_modules or .venv start completely absent, causing agents to fail immediately on npm test or vite.

Fix: Use pnpm (its content-addressable store hardlinks identical packages in seconds without duplicating gigabytes on disk), npm ci --prefer-offline, or uv sync --frozen, wired into scripts.setup inside orca.yaml:

scripts:
  setup: |
    if [ -f pnpm-lock.yaml ]; then
      pnpm install --frozen-lockfile
    elif [ -f package-lock.json ]; then
      npm ci --prefer-offline
    elif [ -f pyproject.toml ]; then
      uv sync --frozen
    fi

Pitfall 2: Missing Gitignored .env & Local Secret Files

Why it happens: .env, .env.local, and local dev certificates stay out of Git, leaving every fresh worktree without required runtime secrets.

Fix: Inside scripts.setup, copy .env* files from $ORCA_ROOT_PATH (your primary checkout) into the new worktree—never commit secrets to Git.

scripts:
  setup: |
    if [ -f "$ORCA_ROOT_PATH/.env.local" ]; then
      cp "$ORCA_ROOT_PATH/.env.local" .env.local
    fi

Why cp beats ln -s here: Pitfalls 3 and 4 require appending worktree-specific PORT and DATABASE_URL values. If .env.local is symlinked, an edit in Worktree A silently mutates every other worktree!

Pitfall 3: Localhost Port Collisions (EADDRINUSE :3000)

Why it happens: Git worktrees isolate files on disk, not TCP ports on 127.0.0.1. Running three Next.js or Vite dev servers on :3000 guarantees EADDRINUSE crashes—or worse, opens the wrong branch in your browser tab.

Fix: Assign per-worktree PORT offsets or hashed dynamic ports inside .env.local (or CLI flags like PORT=3001 / vite --port 3002), paired with Orca's per-worktree browser tabs:

scripts:
  setup: |
    cp "$ORCA_ROOT_PATH/.env.local" .env.local 2>/dev/null || true
    PORT_NUM=$((3100 + $(printf '%s' "${ORCA_WORKSPACE_NAME:-default}" | cksum | awk '{print $1 % 800}')))
    echo "PORT=$PORT_NUM" >> .env.local

Because each worktree owns its own embedded Chromium tab set in Orca, Worktree A stays pinned to http://localhost:3142 while Worktree B stays pinned to http://localhost:3589.

Pitfall 4: Shared Local Database & Docker Volume Pollution

Why it happens: Two agents running prisma migrate dev or destructive seed scripts against the exact same dev.db or localhost:5432/app_dev instance corrupt each other's schemas and break tests non-deterministically.

Fix: Isolate databases per worktree during scripts.setup and tear them down cleanly in scripts.archive:

Keep DATABASE_URL relative to the worktree root rather than pointing to a shared path under /tmp or $ORCA_ROOT_PATH:

# ✅ Each worktree owns an isolated SQLite file
DATABASE_URL="file:./prisma/dev.db"

Run migrations or copy a clean seed snapshot inside scripts.setup.

⚠️ Common Pitfalls

  1. Symlinking node_modules across worktrees
    If Branch A upgrades a dependency while Branch B stays on an older lockfile, a shared symlinked node_modules breaks builds unpredictably. Always let pnpm store hardlinks or scripts.setup install independently per worktree.
  2. Symlinking .env.local and then overriding PORT or DATABASE_URL per worktree
    Any write to a symlinked .env.local modifies every parallel workspace. Copy .env.local from $ORCA_ROOT_PATH first, then append per-worktree overrides.
  3. Thinking Force Delete wiped unpushed commits
    When local unmerged commits exist on the branch, Orca's Preserved branches protection keeps the local Git branch intact—run git branch or create a new worktree from that branch to recover your commits.

✅ Checklist & Next Steps

  • orca.yaml (or mapped conductor.json) defines scripts.setup and scripts.archive.
  • New worktrees auto-install dependencies and copy .env.local safely without committing secrets.
  • Running 2+ dev servers simultaneously uses distinct ports without EADDRINUSE.
  • Database migrations or container seeds in one worktree do not affect parallel branches.

On this page