worktree-supportlisted
Install: claude install-skill dean0x/devflow
# Worktree Support
Canonical patterns for worktree-aware agents and multi-worktree discovery in commands.
## Iron Law
> **WORKTREE_PATH IS A PREFIX, NOT A FLAG**
>
> When WORKTREE_PATH is provided, it changes how you resolve ALL paths — git commands,
> file reads, .devflow/docs/ paths. It's not a toggle; it's a coordinate system shift.
---
## Agent Path Resolution
When `WORKTREE_PATH` is provided to an agent:
| Operation | Without WORKTREE_PATH | With WORKTREE_PATH |
|-----------|----------------------|-------------------|
| Git commands | `git ...` | `git -C {WORKTREE_PATH} ...` |
| .devflow/docs/ paths | `.devflow/docs/...` | `{WORKTREE_PATH}/.devflow/docs/...` |
| Source files | `{file}` | `{WORKTREE_PATH}/{file}` |
| Default | Use cwd | Use WORKTREE_PATH as root |
If `WORKTREE_PATH` is omitted, behavior is unchanged (use cwd). This is the common case.
---
## Worktree Discovery Algorithm (Commands)
For commands that auto-discover worktrees (`/code-review`, `/resolve`):
### Step 1: List Worktrees
Run `git worktree list --porcelain`
### Step 2: Parse Each Entry
Extract: `worktree {path}`, `HEAD {sha}`, `branch refs/heads/{name}`
### Step 3: Filter
Exclude:
- **Bare worktrees** (no branch)
- **Detached HEAD** (no named branch)
- **Protected branches**: `main`, `master`, `develop`, `integration`, `trunk`, `release/*`, `staging`, `production`
- **Mid-rebase or mid-merge**: check `git -C {path} status` for "rebase in progress" or "merging"
### Step 4: Check for