Skip to content

πŸ› οΈ Retire create-worktree.sh now that SWE always creates its own task-branch worktree explicitlyΒ #174

@ZaxShen

Description

@ZaxShen

After #170/#171 fixes, every SWE spawn results in two worktrees when only one is needed:

  1. `worktree-agent-` β€” created by CC's automatic WorktreeCreate event firing `scripts/hooks/create-worktree.sh` (because `agents/swe.md` has `isolation: worktree` in its frontmatter).
  2. `fix/` β€” created by SWE's first command (`git worktree add .claude/worktrees/ ` per the new doctrine in πŸ› SWE creates branches; doctrine says bro owns branch creationΒ #170).

The first one is leftover from the original Layer-2 workaround for CC's bug #27134/#44965 (worktree_add defaulting to `origin/HEAD` instead of `HEAD`). With SWE now always creating its own worktree explicitly via Bash, the auto one is redundant β€” and the new `cleanup-worktree-on-task-close.sh` only removes the task-branch worktree, leaving the auto one to accumulate.

Proposed

  • Remove `isolation: worktree` from `agents/swe.md` frontmatter (or change to a value that doesn't trigger CC's auto-worktree if such a value exists).
  • Remove `scripts/hooks/create-worktree.sh` + the WorktreeCreate hooks.json entry.
  • Verify with a fresh L5 dogfood that only the bro-created task-branch worktree gets created and cleaned up.

Risks

  • CC's bug may still bite if a future doctrine change re-introduces auto-worktree.
  • Some flows may rely on the agent isolation that CC's worktree provides for free. Worth checking that the explicit Bash-created worktree provides the same isolation guarantees.

Surfaced by

Local h5 re-run after #172 fixes β€” observed two worktrees in the project after task close, one cleaned, one orphaned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TestsTest infrastructure (L0-L6)WorkflowBro / SWE / pr-reviewer doctrine + planning skills

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions