subagent-conflict-detectionlisted
Install: claude install-skill wei18/apple-dev-skills
# Subagent Conflict Detection
## When to invoke
Before dispatching a new subagent via the Agent tool — especially with `isolation: "worktree"` — if ANY other subagent is currently running or has an active worktree.
Trigger phrases / situations:
- "派 subagent" / "dispatch a subagent" / "再派一個" while a prior subagent is in flight
- About to call `Agent` tool when `git worktree list` shows non-main worktrees
- Multiple `[in_progress]` tasks in TaskList that involve subagent work
Skip when: dispatching the first subagent in a session, or all prior subagents have completed AND their worktrees are cleaned/merged.
## The pattern (3-step pre-dispatch check)
### Step 1 — inventory in-flight subagents
```bash
git worktree list | grep -v "\[main\]" | awk '{print $1}'
```
For each worktree path, capture:
- Branch checked out
- Dirty files: `git -C <path> status --short`
- Most recent commit subject: `git -C <path> log -1 --format=%s`
### Step 2 — enumerate the NEW dispatch's likely file scope
Read the planned subagent's task prompt. Extract:
- Explicit file paths it'll edit (usually under "Mission" / "Required reads to edit" sections)
- Likely-touched files via the task domain (e.g. "Settings redesign" → `Sources/.../Settings/`)
- Test files it'll add or modify
### Step 3 — compute intersection
For each in-flight subagent's dirty-file set vs the new dispatch's likely scope:
- **Direct overlap** (same file path): BLOCK dispatch, surface to user. Options: serialize (wait for in-