{
  "id": 20025075,
  "title": "The git worktrees your coding agents leave behind, and how to clean them up",
  "url": "https://urgent.news/2026/11/14/the-git-worktrees-your-coding-agents-leave-behind-and-how-to-clean",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-14T18:29:48.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/suman_maharjan_ee09fcd9b8/the-git-worktrees-your-coding-agents-leave-behind-and-how-to-clean-them-up-3pji"
  },
  "original_language": "en",
  "account": "Multiple coding agents, such as Claude Code, Cursor, and Codex, operate within git worktrees, allowing simultaneous work. However, these worktrees can accumulate, consuming considerable disk space. A Claude Code user discovered 27 worktrees consuming 80 GB, while 61 Codex worktrees for a Rails app occupied about 100 GB (issue 63087, 35383).\n\nThese worktrees reside in specific directories: .claude/worktrees/ within each repository (earlier versions utilized ~/.claude-worktrees), ~/.cursor/worktrees/ for Cursor, and ~/.codex/worktrees/ for Codex, operating on detached HEADs rather than branches.\n\nTo inspect the space they occupy, use git worktree list in a repository and du -sh .claude/worktrees/* 2 /dev/null | sort -h. For Cursor and Codex, apply du -sh ~/.cursor/worktrees/*/* ~/.codex/worktrees/* 2 /dev/null | sort -h.\n\nBefore removing a worktree, verify its status with git -C path status --short. If no uncommitted changes exist, use git -C path status --short --ignored to check for ignored files like .env. For squash merges, confirm their absence by checking if the branch has been merged into main using gh pr list --head branch --state merged --json headRefOid and comparing it with git rev-parse branch.\n\nTo prevent the buildup of worktrees, adjust the settings: Claude Code allows lowering cleanupPeriodDays (default 30), Cursor enables lowering cursor.worktreeMaxCount (default 25), and Codex can reduce the limit of 15 kept worktrees in its settings. For a practical solution, Mopup, a Mac application, automates these checks and only removes finished worktrees, never using --force, ensuring no committed data is lost. Mopup is free to scan repositories.",
  "summary": "Claude Code, Cursor and Codex run in git worktrees so several agents can work at once. Each worktree is a full checkout with its own node_modules and build output, and they pile up quietly. One Claude Code user found 27 forgotten worktrees using 80 GB ( issue 63087 ). 61 Codex worktrees of a Rails app took about 100 GB ( issue 35383 ). Where they live Claude Code: .claude/worktrees/ inside each…",
  "key_points": [
    "Coding agents create git worktrees for simultaneous work",
    "Worktrees accumulate, consuming large disk space",
    "Mopup removes finished worktrees without losing committed data"
  ],
  "editors_take": null,
  "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."
}