workspace-guide
Implementing Worktree-Based Concurrent Local Environments
This skill helps you implement a system for running multiple local development environments simultaneously using git worktrees. It is meant to be adapted to any repository, regardless of tech stack or database engine.
Node consumers install the @paleo/workspace package and write two custom scripts that build a config object and call runWorkspace(config) / runDevServer(config). The package owns the kernel — slot/dev-server registries, port math, branch lifecycle, process-group control, log polling, CLI parsing. Consumers supply project-specific callbacks (finalizeWorktree, printSummary, optional purgeInfrastructure, optional devServerScript) plus a configFiles list with patch functions, and resolve their own dev-limit ladder.
Non-Node consumers reimplement the system from this design doc; the rationale sections below are self-contained.
The assets/ directory contains reference scripts (workspace.mjs, dev-server.mjs) — thin wrappers around the package — plus a template for agent documentation. The scripts are annotated with ADAPT comments to highlight what needs changing.
The Problem
When you work on multiple branches at the same time (or when AI agents work in parallel), you need isolated environments. Git worktrees give you isolated code, but that's not enough: each environment also needs its own ports, its own database, and its own config files. Without automation, setting this up manually for every branch is tedious and error-prone.
Core Concepts
Shared vs per-worktree gitignored directories
The first thing to decide is: for each gitignored directory in your project, should it be shared across worktrees or isolated per worktree?