How to clean up the worktrees Claude Code, Cursor and Codex leave behind Coding agents Claude Code, Cursor and Codex each leave behind git worktrees that accumulate to tens of gigabytes, according to a Mopup guide that cites measured cases including 61 Codex worktrees taking about 100 GB on a Rails app (Codex issue 35383) and a Claude Code user finding 27 forgotten worktrees using 80 GB (Claude Code issue 63087). Each tool cleans up only its own worktrees by count or age — Cursor keeps the newest 25, Codex keeps the 15 most recent, and Claude Code sweeps subagent and background-session worktrees after 30 days — so the guide recommends listing them with `git worktree list` and sizing them with `du -sh` before deleting. The guide warns that automatic cleanups have removed wanted work, including a git-ignored images folder (issue 98186) and unpushed submodule changes (issue 107997). Mopup https://mopup.online/ › Guides https://mopup.online/guides › Coding agent worktrees How to clean up the worktrees Claude Code, Cursor and Codex leave behind Coding agents work in git worktrees so several can run at once. Each worktree is a full checkout with its own node modules and build output, and each tool cleans up only its own, by count or by age. They add up quietly, often to tens of gigabytes. How much space they take A worktree costs what a fresh clone costs once its dependencies are installed. Some measured examples: - A Laravel project: about 530 MB of node modules and 350 MB of vendor per worktree, so ten worktrees took 9.9 GB Mattias Geniar https://ma.ttias.be/deduplicating-git-worktrees-ext4-jdupes . - A Rails app with about 1.3 GB of node modules per checkout: 61 Codex worktrees took about 100 GB Codex issue 35383 https://github.com/openai/codex/issues/35383 . - A Claude Code user found 27 forgotten worktrees using 80 GB Claude Code issue 63087 https://github.com/anthropics/claude-code/issues/63087 . Where each agent keeps them | Tool | Where its worktrees are | What it cleans up by itself | |---|---|---| | Claude Code | .claude/worktrees/