{
  "id": 21700423,
  "title": "Claude Code Worktrees Filling Your Disk? How to Find and Remove Leftover Git Worktrees",
  "url": "https://urgent.news/2026/11/25/claude-code-worktrees-filling-your-disk-how-to-find-and-remove",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-25T00:18:03.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/fastlog/claude-code-worktrees-filling-your-disk-how-to-find-and-remove-leftover-git-worktrees-454d"
  },
  "original_language": "en",
  "account": "Claude Code and Codex worktrees can consume large amounts of disk space on your Mac. This occurs because each worktree maintains its own copy of dependencies and build directories, leading to multiple gigabytes of data being stored even after merging a pull request. The report measured significant disk usage from worktrees, including 66.3 GB across multiple node_modules, .venv, and .build folders.\n\nTo locate and remove these leftover worktrees safely, start by conducting a read-only audit of your system. Use the following commands to identify the location and size of worktrees:\n\n1. Run a read-only audit of worktree directories:\n```bash\ndu -sh ~/.claude/worktrees ~/.codex/worktrees ~/.cursor/worktrees\n```\n2. Identify the largest individual worktree folders:\n```bash\ndu -sh ~/.claude/worktrees/* ~/.codex/worktrees/* | sort -h | tail -20\n```\n3. List all registered Git worktrees:\n```bash\ngit worktree list\n```\n4. Find prunable worktrees (locked, detached, or already missing):\n```bash\ngit worktree list --porcelain\n```\n5. Determine the largest node_modules, target, and .build folders within worktrees:\n```bash\nfind ~/.claude/worktrees ~/.codex/worktrees ~/.cursor/worktrees \\\n\\( -name node_modules -o -name target -o -name .build -o -name .venv \\) \\\n-type d -prune -exec du -sh {} + | sort -h | tail -25\n```\nNote that `du` provides the total directory size, not the amount of data safe to delete. Always verify the Git status before removing a worktree to ensure no uncommitted changes exist.\n\nDifferent AI coding tools store worktrees in various locations, each requiring specific cleanup methods. Claude Code typically uses `~/.claude/worktrees`, while Codex employs `~/.codex/worktrees`. Cursor and other tools may create worktrees in hidden or sibling directories of the repository. Manual removal is recommended using `git worktree remove` to prevent data loss due to untracked or modified files. Always commit changes or create patches before deleting worktrees to preserve valuable work.",
  "summary": "Note: Originally published at getcleanbit.app . Written by the CleanBit developer with AI assistance. All measurements were taken on a real developer Mac. Claude Code and Codex worktrees fill up your Mac because Git shares commit history across worktrees, but never shares untracked build directories like node_modules , Rust target/ , Swift .build/ , or Python .venv/ . Every parallel agent task…",
  "key_points": [
    "Claude Code worktrees can consume large disk space",
    "Identify worktree directories with du command",
    "Remove prunable worktrees with git worktree remove"
  ],
  "editors_take": "The accumulation of redundant dependencies and build directories across multiple AI coding environments forces developers to manually audit and prune their systems to reclaim significant amounts of local disk space.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}