VS Code extension: no worktree cleanup on tab close or /clear
Resolved 💬 3 comments Opened Mar 6, 2026 by T-P-F Closed Apr 4, 2026
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//newdoes not trigger cleanup/exitdoes 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)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗