Version: 0.6.0 (latest 0.7.0)
Command: none (Agent tool dispatch with isolation: "worktree")
What happened:
Over ~15 sessions, background agents dispatched with isolation: "worktree"
left their worktrees under .claude/worktrees/. Auto-clean only removes an
UNCHANGED worktree, so every agent that did real work left one behind, each
with its own node_modules. The framework dev server (Next.js) watches the
repo root and has no ignore setting: after every edit it rescanned all
15 copies, sat at 100% CPU and stopped answering. It took profiling the
server process to find the cause. The worktrees are git-ignored, so nothing
surfaced them.
What I expected:
flow keeps the repo free of agent worktrees:
- A WorktreeCreate hook that places agent worktrees OUTSIDE the repository
(e.g. ~/.claude/worktrees//), so no in-repo watcher ever
sees them. Claude Code documents this hook as the way to replace
worktree creation; there is no setting to relocate .claude/worktrees.
- A SessionStart (or SessionEnd) hook that runs
git worktree prune and
removes agent worktrees whose branch is already merged into the default
branch. Unmerged work is never touched. There is no per-subagent hook,
so session-level is the only place.
- A line in the /flow:continue recap when leftover agent worktrees exist.
^ assumed — correct me on where these belong in flow
Repro:
A monorepo with a large node_modules. Dispatch two agents with
isolation: "worktree" that commit; merge their branches; start the
framework dev server; edit a file. The watcher rescans every copy.
^ assumed — the profile showed the watcher thread busy and the hang
disappeared once the copies were removed; the exact trigger is inferred.
Workaround used:
git worktree remove --force && git branch -D for each
merged agent worktree, then git worktree prune. Documented in the
project's CLAUDE.md until flow ships the hooks.
Version: 0.6.0 (latest 0.7.0)
Command: none (Agent tool dispatch with isolation: "worktree")
What happened:
Over ~15 sessions, background agents dispatched with isolation: "worktree"
left their worktrees under .claude/worktrees/. Auto-clean only removes an
UNCHANGED worktree, so every agent that did real work left one behind, each
with its own node_modules. The framework dev server (Next.js) watches the
repo root and has no ignore setting: after every edit it rescanned all
15 copies, sat at 100% CPU and stopped answering. It took profiling the
server process to find the cause. The worktrees are git-ignored, so nothing
surfaced them.
What I expected:
flow keeps the repo free of agent worktrees:
(e.g. ~/.claude/worktrees//), so no in-repo watcher ever
sees them. Claude Code documents this hook as the way to replace
worktree creation; there is no setting to relocate .claude/worktrees.
git worktree pruneandremoves agent worktrees whose branch is already merged into the default
branch. Unmerged work is never touched. There is no per-subagent hook,
so session-level is the only place.
^ assumed — correct me on where these belong in flow
Repro:
A monorepo with a large node_modules. Dispatch two agents with
isolation: "worktree" that commit; merge their branches; start the
framework dev server; edit a file. The watcher rescans every copy.
^ assumed — the profile showed the watcher thread busy and the hang
disappeared once the copies were removed; the exact trigger is inferred.
Workaround used:
git worktree remove --force && git branch -D for each
merged agent worktree, then git worktree prune. Documented in the
project's CLAUDE.md until flow ships the hooks.