shared-worktree-safetylisted
Install: claude install-skill vraj-ai/skills
# shared-worktree-safety
Most multi-agent disasters are not reasoning failures. They are **two writers in one checkout**.
## The six invariants
### 1. Capture a baseline before touching anything
```powershell
git rev-parse --abbrev-ref HEAD
git status -sb
git log --oneline -5
```
Plus, if tracked: the ticket's current state and latest comments. Write this down. Everything later is judged against it.
**List explicitly which dirty paths are NOT yours.** That list is a contract with yourself.
### 2. Preserve dirty paths you do not own
Files dirty at baseline that your ticket doesn't own are **sacred**:
- Don't stage them.
- Don't revert them.
- Don't "clean up" them.
- Don't stash them. A stash is a silent theft from whoever was mid-edit.
If your change genuinely requires touching one, **stop and report the collision** rather than resolving it unilaterally.
### 3. Mid-run file changes are a concurrency signal
A file that changed since you read it means **someone else is working**. Do not blindly apply your edit over a stale read.
```
detect change → re-read the file → re-evaluate whether your edit still applies
```
If your edit no longer makes sense against the new content, that's a collision. Report it.
### 4. Stage narrowly, always
```powershell
git add <explicit paths> # yes
git add -A # never
git add . # never
git commit -a # never
```
In a shared tree, `-A` commits someone else's half-finished work und