Git Worktree Setup, App Isolation, and Cleanup
Set up parallel Git worktrees with separate ports, secrets, dependencies, and local data, then retire them safely.
Before & after
Same prompt, same agent — the only difference is the skill.
You could use Git worktrees to work on multiple branches simultaneously. Worktrees are a Git feature that lets you check out different branches in separate directories. You'd need to manage the directory structure, make sure each worktree has the right environment set up, and handle cleanup when you're done. It's a bit manual, but it's definitely doable. You might also want to think about how to handle things like running servers on different ports for each worktree. Would you like some general guidance on how to set this up?
WORKTREE SETUP wg create --branch feature/auth feature-auth → Creates .worktrees/feature-auth with isolated git state → Returns port assignment: 3001 (main is 3000) wg create --branch feature/payments feature-payments → Creates .worktrees/feature-payments → Assigns port 3002 ISOLATION SUMMARY Main worktree: ./ → PORT 3000 → node_modules/ → .env.local feature-auth: .worktrees/feature-auth → PORT 3001 → symlinked node_modules (shared) → .env.3001 feature-payments: .worktrees/feature-payments → PORT 3002 → symlinked node_modules → .env.3002 ENVIRONMENT SYNC Each worktree gets DATABASE_URL, API_KEY from shared .env.production (read-only) PORT and LOG_FILE override per worktree CLEANUP wg cleanup → removes all stale worktrees, frees ports, confirms git branches still exist before deletion
About this skill
Two branches are checked out, but both apps still hit the same database, fight over port 3000, or overwrite shared files. This skill sets up Git worktrees with explicit runtime isolation and checks what is actually running before calling the setup complete.
What it does
- Creates worktrees from an explicit base commit without disturbing the current checkout.
- Detects occupied branches, conflicting paths, locked worktrees, and stale registrations.
- Assigns separate app ports, callback URLs, local data stores, and worker namespaces where the project supports them.
- Provisions ignored environment files without exposing secrets or sharing writable dependency directories.
- Verifies process ownership, effective ports, and application identity for each running instance.
- Retires worktrees after checking tracked changes, untracked and ignored files, running processes, and branch merge status.
What you get
A task-to-worktree map with branches, base commits, runtime settings, launch commands, and verification results. Cleanup includes a record of what was removed and what was preserved.
Best for
Developers running multiple features, experiments, review checkouts, or agent sessions in the same repository, especially when each checkout needs its own running app.
SKILL.md preview
---
name: git-worktree-setup-app-isolation-and-cleanup
description: >-
… (sign up to view the full skill)More development skills
View all Development skills →Performance Bottleneck Profiling: Node, Python, Go
Classifies a slowdown, gives exact profiler commands, reads the output, and proves the fix with same-conditions p95/p99 numbers.
Feature Scaffolding with Working Tests
Turn a short feature spec into code, runnable tests, and integration wiring that match your existing project.
Feature Flag Rollouts and Kill Switches
Design staged flag rollouts, verify rollback paths, and audit flag debt with explicit defaults, gates, and retirement plans.
Microcontroller Firmware and RTOS Engineering
Build and debug MCU firmware with bounded ISR/RTOS timing, safe DMA ownership, and measured power budgets.