Skip to content

VS Code extension: no worktree cleanup on tab close or /clear #31488

Description

@T-P-F

Description

When using Claude Code in the VS Code extension (tab, not terminal), worktrees created via /worktree are never cleaned up automatically. They accumulate in .claude/worktrees/ and must be manually removed with git worktree remove.

CLI behavior (works correctly)

In the CLI, exiting a session (/exit, Ctrl+D) triggers worktree cleanup:

  • No changes: worktree and branch are auto-removed
  • Changes exist: user is prompted to keep or remove

VS Code extension behavior (no cleanup path)

  • Closing the tab does not trigger cleanup
  • /clear / /reset / /new does not trigger cleanup
  • /exit does not exist in the VS Code extension

There is no way to trigger worktree cleanup from the VS Code extension without manually running git commands.

Expected behavior

Closing the Claude Code tab or starting a new conversation (/clear) should trigger the same worktree cleanup flow as /exit does in the CLI.

Environment

  • Claude Code VS Code extension
  • macOS / Linux (Codespaces)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workingplatform:vscodeIssue specifically occurs in VS CodestaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions