# Agent Isolation Workflow This repository uses per-agent worktree isolation. Every agent task must run in its own branch and worktree. ## Rules - Do not edit from the shared integration checkout. - Do not `git checkout` branches in shared checkouts while other agents may be active. - Use one worktree per task and one branch per worktree. - Keep a `.agent-lock` file in each active worktree. - Keep OpenSpec change artifacts in the main checkout under `openspec/changes/`, even when implementation work happens in an agent worktree. ## Standard Flow 1. Create isolated worktree and branch from integration base: - `scripts/agent-worktree.sh create [base-branch]` 2. Work only in that worktree path: - `.worktree/` - Exception: create and edit OpenSpec documents in the main checkout at `openspec/changes//`. 3. Commit and push branch: - `agent/` 4. Open PR into integration branch. 5. After merge, remove worktree: - `scripts/agent-worktree.sh remove ` ## Lock File Contract Each active worktree contains `.agent-lock` with owner/task/timestamp. If lock ownership is unclear, stop and ask before making edits.