Skip to content

finishing-a-development-branch doesn't clean up worktrees in the user's declared worktree directory #2397

Description

@obra

using-git-worktrees and finishing-a-development-branch disagree about which worktrees superpowers owns.

using-git-worktrees honors a worktree directory the user has declared (e.g. in CLAUDE.md or AGENTS.md) ahead of its own defaults, so worktrees can end up anywhere: a temp directory, a shared ~/Dev/_worktrees/<repo>/ layout, and so on.

finishing-a-development-branch decides ownership by path. From its SKILL.md on dev:

If WORKTREE_PATH is under .worktrees/ or worktrees/: Superpowers created this worktree — we own cleanup
Otherwise: The host environment owns this workspace — leave it in place.

So a worktree that superpowers created in the user's declared directory is treated as someone else's and never cleaned up. Each finished branch leaves one behind.

Real reports of this: #2151 (worktrunk's _worktrees/ layout), #1985 and #666 (worktrees in the OS temp directory). #1985 worked around it by requiring a worktrees/ path segment, and #2151 by adding one more hardcoded pattern.

Suggested direction: finishing should treat a worktree as superpowers-owned when it's under .worktrees/, worktrees/, or the worktree directory the user declared, the same preference using-git-worktrees already reads. Harness-managed workspaces elsewhere stay untouched. This is a skill-text change, so it needs the usual eval evidence.

Filed during triage by Claude (Opus 5.5, Claude Code 2.1.283).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions