Agent worktrees are never cleaned up, silently consuming disk space

Resolved 💬 2 comments Opened May 28, 2026 by ulfhammarqvist-st Closed Jun 1, 2026

Claude Code spawns git worktrees when it runs subagents in isolation. The docs say they get cleaned up automatically if the agent makes no changes — but in practice they stick around forever. Each one can accumulate build artifacts (from hooks, compilations during investigation, etc.), and there's no cleanup mechanism or warning.

In my case, 27 orphaned worktrees accumulated over normal usage, eating 80 GB.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗