Skip to content

Feature: Support OS temp directory for worktrees (auto-cleanup) #666

@blackas

Description

@blackas

Problem

Worktrees created by using-git-worktrees persist indefinitely in .worktrees/ or ~/.config/superpowers/worktrees/. After a feature branch is merged or discarded, leftover worktree directories can accumulate and consume disk space — especially if the user forgets to run finishing-a-development-branch.

Proposal

Add an option to create worktrees in the OS temporary directory ($TMPDIR or /tmp) so they are automatically cleaned up by the OS (e.g., on reboot or periodic cleanup).

Example path: $TMPDIR/superpowers-worktrees/<project-name>/<branch-name>/

This could be:

  1. A new option in the directory selection prompt (option 3)
  2. Configurable via CLAUDE.md (e.g., Worktree directory: $TMPDIR/superpowers-worktrees/)

Benefits

  • No manual cleanup needed for short-lived feature branches
  • No .gitignore verification required (outside project)
  • No disk space accumulation from forgotten worktrees
  • Works well with the "use and discard" workflow

Considerations

  • OS cleanup timing varies ($TMPDIR is cleaned more aggressively than /tmp on macOS)
  • If the OS removes the directory while git still references it, git worktree prune is needed to clean stale entries
  • Long-running feature branches may not be suitable for temp directories
  • The skill could warn users about this trade-off during directory selection

Suggested UX

No worktree directory found. Where should I create worktrees?

1. .worktrees/ (project-local, hidden)
2. ~/.config/superpowers/worktrees/<project-name>/ (global, persistent)
3. $TMPDIR/superpowers-worktrees/<project-name>/ (temporary, OS auto-cleanup)

Which would you prefer?

Metadata

Metadata

Assignees

No one assigned

    Labels

    claude-codeClaude Code (Anthropic CLI) issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions