block / block/buzz

Buzz should manage agent-created worktree lifecycle and disk cleanup

Open
#5,781 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

Agent-created worktrees currently accumulate under `~/.buzz/REPOS/*-worktrees` after their backing work is merged or abandoned. Nothing appears to auto-prune them or warn before disk pressure becomes severe.

## Incident that exposed this

On 2026-08-13, `~/.buzz/REPOS/block-buzz-worktrees` was 164 GB and the disk was 95% full:

- `channel-visibility-update`: 25G; backing PR #5119 had been squash-merged; remote branch gone
- `1743-relay-offline-notice`: 41G; unmerged/in-flight, but user explicitly requested deletion due to disk pressure
- other stale/detached worktrees were also present but were intentionally left untouched during cleanup

Manual cleanup of only the two user-requested worktrees recovered ~62 GiB of available disk space (`df` went from 53Gi available / 95% used to 115Gi available / 88% used).

## Expected behavior

Buzz should manage the lifecycle of agent-created worktrees, at minimum:

1. Detect worktrees whose backing PR/branch has merged or disappeared.
2. Safely prune or offer one-click cleanup for those worktrees.
3. Preserve unmerged work with an explicit breadcrumb/reference before deletion, or require user confirmation.
4. Surface disk pressure before the machine reaches ENOSPC.

## Scope suggestion

Start with conservative cleanup only:

- merged PR / deleted remote branch / detached scratch worktrees older than a safe threshold
- dry-run/reporting mode before deletion
- no deletion of active branches without explicit user approval

## Why this matters

A single Buzz repo worktree directory consumed 164 GB. This is large enough to make the desktop and relay fail in surprising ways, and the current mitigation is ad-hoc manual `git worktree remove --force` by whoever happens to have write access.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.