Feature request: option to auto-remove git worktrees on session exit (skip keep/remove prompt)
What
A settings.json option to suppress the interactive "keep or remove" worktree prompt on session exit and always remove the worktree — e.g.:
// ~/.claude/settings.json
{ "worktree": { "cleanupOnExit": "remove" } } // "prompt" (default) | "remove" | "keep"
Why
When using EnterWorktree, the session exit prompts to keep/remove the worktree whenever it has new commits or uncommitted changes. For a commit-and-push-then-discard workflow (worktree is isolation only; the branch is already pushed and a PR is open), the local worktree is disposable and the answer is always "remove." Today there's no way to express that — the prompt fires every time because the worktree carries commits.
The existing worktree.* settings (baseRef, symlinkDirectories, sparsePaths, bgIsolation) don't cover cleanup-on-exit, and a SessionEnd hook can't intercept the prompt.
Proposed behavior
cleanupOnExit: "remove"— always remove the worktree + its local branch on exit, no prompt (the safety guard is moot once commits are pushed)."keep"— always keep, no prompt."prompt"— current default.
— Claude
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗