Worktree Isolation
SkillAI & modelsThis skill lets your agent isolate Compozy runtime state so parallel worktrees and QA runs can happen at the same time without clashing on shared state. It is meant for situations where another agent or runtime may share the machine, or when a parallel worktree is being created. It is not intended for single-worktree or build-only work.
Available today. Use it from your connected AI after setup.
No other account needed.
After adding it, ask your agent to set up an isolated runtime before creating a parallel worktree or running QA alongside other agents. Skip it for single-worktree or build-only work.
Then ask your AI: use the Worktree Isolation skill
What your AI can do with it
- Set up an isolated runtime environment for a parallel worktree
- Keep concurrent QA runs from clashing on shared state
- Separate Compozy runtime state when other agents or runtimes share the machine
- Run concurrent worktrees without state clashes
What this skill tells your AI
The instructions your AI receives, as published by compozy/compozy in .agents/skills/eng/eng-worktree-isolation/SKILL.md and read by ahel’s review.
Provision one owned runtime envelope for a concurrent worktree or non-bootstrap
test run. Production-like QA should prefer eng-qa-bootstrap, which adds a
manifest, provider homes, browser policy, and targeted teardown evidence.
Creating the parallel checkout itself is a separate step: make worktree-new SLUG=<slug> (→ ./scripts/worktree.sh) adds a sibling worktree and bootstraps it (mise pins, bun install + skill/AGENTS.md symlinks; BUILD=1/E2E=1 opt-ins); make worktree-bootstrap preps an existing checkout; ./scripts/worktree.sh rm <slug> removes. Go caches are shared machine-wide — no per-worktree Go setup. This skill then isolates the RUNTIME state that agents inside that worktree use. Opt-in make gate-full and local E2E self-queue machine-wide (L-030); required scoped lanes need no lock and PR CI owns full verification.
Required Inputs
- scenario-slug (optional): a short kebab-case slug used to name the COMPOZY_HOME directory and tmux socket. Defaults to
compozy-iso-<timestamp>.
Procedures
Step 1: Confirm the Concurrency Branch
- Look for explicit signals in the user's request: parallel-worktree language, "another agent is running", "tem outro agent trabalhando", "QA in parallel", or invocation under a worktree path like
Compozy/_worktrees/<slug>/. - If no concurrency signal is present and no parallel runtime is planned, stop; this skill does not apply.
- Confirm the scenario-slug, defaulting to a timestamped slug when omitted.
Done when: the concurrent runtime/test branch and one unique scenario slug are explicit.
Step 2: Allocate COMPOZY_HOME
- Run the bootstrap/mutating helper
python3 .agents/skills/eng/eng-worktree-isolation/scripts/allocate-isolation.py --slug "<scenario-slug>" [--prefer-worktree]. Pass--prefer-worktreeonly from an actual parallel worktree. The script:- Creates a unique
COMPOZY_HOMEdirectory under${TMPDIR:-/tmp}/compozy-iso-<slug>-<random>/OR uses the worktree-scopedCompozy/_worktrees/<slug>/.compozy/when invoked from a worktree. - Picks a free TCP port on
127.0.0.1for the daemon HTTP server. - Creates a unique UDS path under
COMPOZY_HOME. - Picks a unique tmux socket path under the COMPOZY_HOME (e.g.,
${COMPOZY_HOME}/tmux-bridge.sock).
- Creates a unique
- The script prints export statements, including
COMPOZY_ISOLATION_ROOT, suitable foreval "$(...)".
Done when: the allocator returns one non-default, owned root and unique HTTP/UDS/tmux addresses.
Step 3: Source the Envelope
- Capture the exported variables:
COMPOZY_ISOLATION_ROOT,COMPOZY_HOME,COMPOZY_HTTP_PORT,COMPOZY_UDS_PATH,TMUX_BRIDGE_SOCKET. - For shells:
eval "$(python3 .agents/skills/eng/eng-worktree-isolation/scripts/allocate-isolation.py --slug "<slug>" [--prefer-worktree])". - For Make/CI invocations: pass the variables as overrides to the daemon start command.
- Confirm the daemon does NOT write to
~/.compozy/or default port 23230.
Done when: the current shell exposes the exact allocator output and no default runtime path is reachable by the planned command.
Step 4: Verify Isolation Before Action
- Confirm
COMPOZY_HOMEis non-default and writable. - Confirm the chosen ports are not already bound (re-pick if necessary).
- Confirm the tmux socket path is non-default and not held by another process.
- Print a one-line summary:
slug, COMPOZY_HOME, http port, uds path, tmux socket.
Done when: every address is free immediately before launch and the summary identifies the owned root.
Step 5: Run the Isolated Scenario
- Hand off to the inner skill (
eng-real-scenario-qa,qa-execution,make test-e2e-runtime, etc.). - Prefer
eng-qa-bootstrapfor production-like local QA because its own allocator also provides provider homes, a manifest, browser policy, Web proxy env, and teardown evidence. - Inner skills inherit the env via the shell session. Do not re-allocate.
Done when: every child process uses the same envelope and none writes to another worktree or default home.
Step 6: Cleanup (processes ALWAYS, files optionally)
- Process teardown is mandatory on every terminal path. Run the mutating teardown helper only for this run's envelope:
python3 .agents/skills/eng/eng-qa-bootstrap/scripts/teardown-qa-env.py --root "$COMPOZY_ISOLATION_ROOT" - Confirm the targeted teardown reports
TEARDOWN_ALL_CLEAN=true. Survivors are a blocking failure. - The
COMPOZY_HOMEdirectory is left in place for forensic inspection unless the caller explicitly requests--purgefor a temporary envelope. - Never purge a worktree-scoped
.compozy; it belongs to the user's checkout. - Use
make qa-reapor teardown--allonly for an intentional machine-wide stale-lab recovery, never as normal cleanup while other runs may be active.
Done when: the owned envelope is clean, unrelated labs remain untouched, and any retained files contain no live process state.
Error Handling
- No free port available: retry with a wider range. If still no luck, surface the busy ports and exit.
- COMPOZY_HOME path collision: the script uses random suffixes; collision is essentially impossible. If it happens, retry once.
- User invokes without concurrency signal but with
--force: apply isolation. Some users always want isolated runs. - Worktree-scoped path lacks write permission: fall back to TMPDIR-scoped path with a logged warning.
- Targeted teardown cannot prove ownership: stop and report the root/PIDs; never widen normal cleanup to
--all.
Signals
- GitHub stars
- 3k
- Forks
- 177
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
eng-worktree-isolation- Source
- github.com/compozy/compozy