Files
knowledge-base/6 - Zettelkasten/20260414230719 Agent 工具 worktree 隔离是 Windows 原生并行的关键.md

54 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
created: "2026-04-14 23:07"
type: zettel
tags: [zettel, claude-code, ECC, orchestration, parallel, windows, worktree]
source: "Claude Code Agent tool 参数: isolation"
---
# Agent 工具 worktree 隔离是 Windows 原生并行的关键
ECC 的 `dmux-workflows``scripts/orchestrate-worktrees.js` 都依赖 tmuxWindows 原生环境跑不了。绕过这个限制最干净的方案不是切 WSL是用 Claude Code 内置 `Agent` 工具的 `isolation: "worktree"` 参数。
## 机制
`Agent` 工具在 spawn 子代理时接受 `isolation: "worktree"`——平台会自动为该子代理建一个临时 git worktree子代理在隔离分支上做修改无改动时自动清理有改动则把 path 和 branch 返还给主代理,由主代理决定合并还是丢弃。
这和 `claude-devfleet` 的 worktree 策略本质一致,只是调度层从 HTTP MCP 变成主代理自己。
## 为什么重要
1. **零外部依赖** — 不需要 tmux、不需要额外服务Claude Code 开箱即用
2. **天然隔离** — git worktree 保证多个子代理改同一个仓库也不会互相踩脚
3. **失败可丢弃** — 改坏了直接扔掉 worktree主会话干净无污染
4. **和现有 agent 生态复用** — 任何 `subagent_type`general-purpose、csharp-reviewer、security-reviewer……都能套 worktree
## 适用边界
- ✅ 互相独立的迁移任务、并行审查、多模块改造
- ✅ 想在 Windows 上复刻 dmux 「多 pane 并行」效果
- ❌ 跨模块强耦合、子代理需要实时看到彼此中间状态
- ❌ 需要长时间运行、跨会话存活(用 `claude-devfleet``autonomous-agent-harness` crons
## 和其他编排方式的关系
| 需求 | 用这个 |
|------|--------|
| 几个独立子任务,当前会话内搞定 | **Agent + isolation: worktree**(本 zettel |
| DAG 依赖、跨会话、自动 merge | `claude-devfleet`MCP |
| Linux/WSL 上可视化多 pane | `dmux-workflows` |
| 定时 / 长周期无人值守 | `autonomous-agent-harness` + crons |
---
## Related
- [[ECC 编排替代方案 (orchestrate 迁移)]]
- [[dmux 多Agent并行编排]]
- [[Autonomous Agent Harness 自主代理框架]]
- [[Everything Claude Code Agent 编排模式]]
## Source
- Claude Code `Agent` tool 原生参数 `isolation`
- ECC `skills/claude-devfleet/SKILL.md` 的 worktree 隔离策略(同源思路)