Skip to content

feat(exec): create parallel-group sub-worktrees with native isolation: "worktree"; keep merge-back in worktree-isolation.ts (#1192 follow-up, after the freeze) #1407

Open

Description

@admarble

Follow-up from #1192: docs/investigations/native-worktree-hooks-2026-10.md, decision partial. Waits for the plugin freeze to lift, because it edits /exec SKILL steps 1b/5b.

What

On Claude Code ≥ 2.1.296, spawn /exec's isolateParallel agents with the Agent tool's isolation: "worktree" and no WorktreeCreate hook. Keep merge-back, conflict handling, orphan sweep and reporting in worktree-isolation.ts, retargeted:

  • discover worktrees from the returned worktreePath values and worktree-agent-* branches, instead of exec-agent-*;
  • add a node_modules symlink step for each returned path, because native isolation copies .worktreeinclude files but not node_modules.

Why no hook:

  • A WorktreeCreate hook replaces creation for every isolation: "worktree" spawn in the project, including users' own subagents.
  • With a hook present, native cleanup of an unchanged worktree stops working.
  • WorktreeRemove never fires in headless -p runs (re-probed 2026-10-10), so there's nothing to hang cleanup on.

Acceptance Criteria

  • AC-1: A parallel group's agents run in native isolation: "worktree" worktrees, and worktree-isolation.ts merge-all merges their changes back from the returned worktreePath values. Evidence: an integration test, or a recorded /exec run on a two-agent parallel group showing both changes merged.
  • AC-2: Each returned worktree has node_modules available before an agent runs tests. Evidence: a test on the symlink step.
  • AC-3: cleanup removes leftover worktree-agent-* worktrees and branches after merge-back, since WorktreeRemove doesn't fire headless. Evidence: a test that leaves a changed agent worktree and asserts it is removed after merge.
  • AC-4: On Claude Code < 2.1.296, the old exec-agent-* path still runs. Evidence: a version-gate test.

Non-Goals

  • Shipping a WorktreeCreate or WorktreeRemove hook.
  • Changing how the issue-level worktree is created (ensureWorktree).

Activity

  1. added 2 commits that reference this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions