Skip to content

[Feature Request] Interactive worktree cleanup command (wtp clean) #88

@fdarian

Description

@fdarian

Problem

When working with multiple worktrees, stale worktrees accumulate over time — branches get merged, work gets pushed, but the worktrees linger on disk. Cleaning them up manually requires checking each one: is the branch merged? Are there uncommitted changes? Are all commits pushed? This is tedious and error-prone, especially with many worktrees.

Proposal

Add a wtp clean command that provides an interactive way to review and remove worktrees. The command should:

  • Validate each worktree against merge status, uncommitted changes, and unpushed commits
  • Present a clear overview showing which worktrees are safe to remove and why
  • Let the user choose which worktrees to remove via an interactive multi-select
  • Pre-select safe worktrees (merged, clean, pushed) so the common case is fast
  • Support --force for removing worktrees that have uncommitted changes

Demo

CleanShot.2026-02-16.at.00.05.45.mp4

Expected Behavior

$ wtp clean

Select worktrees to remove:
    WORKTREE          STATUS   NOTE
> [x] feature-done   safe     merged, clean, pushed
  [x] bugfix-123     safe     merged, clean, pushed
  [ ] wip-refactor   unsafe   uncommitted changes
  [ ] experiment      unsafe   unpushed commits (3 ahead)

Safe worktrees are pre-selected. Unsafe ones are shown with reasons so the user can make an informed decision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions