
I got tired of writing the same 80-line setup script for every AI worktree
If you've been running parallel AI coding agents — Claude Code, Aider, Codex, anything — you've hit this wall. Each agent needs its own worktree. Each worktree needs its own environment. And that means every time you spin one up, you're either manually editing .env files or you've got a setup script that looks something like this: #!/bin/bash # conductor.json worktree script — set up isolated environment BRANCH_NAME="${CONDUCTOR_BRANCH_NAME}" SLUG="${BRANCH_NAME//\//_}" SLUG="${SLUG//-/_}" BASE_PORT=3000 USED_PORTS=$(cat ~/.worktree-ports 2>/dev/null || echo "") PORT=$BASE_PORT while echo "$USED_PORTS" | grep -q "^$PORT$"; do PORT=$((PORT + 1)) done echo "$PORT" >> ~/.worktree-ports DB_NAME="myapp_${SLUG}" COMPOSE_PROJECT="myapp_${SLUG}" REDIS_PORT=$((PORT + 1000)) cat > .env.local << EOF PORT=$PORT DB_NAME=$DB_NAME DATABASE_URL=postgres://localhost/$DB_NAME COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT REDIS_URL=redis://localhost:$REDIS_PORT EOF createdb "$DB_NAME" 2>/dev/null || true echo "S
Continue reading on Dev.to
Opens in a new tab




