Tuesday, November 24, 2026SubscribeMastheadAbout
Cali ReporterCalifornia · National · West Coast · Good News

Advertisement

Technology

Git Worktrees and Their Impact on Disk Space

AI coding assistants like Claude Code, Cursor, and Codex use git worktrees, which can accumulate and consume significant disk space if not managed properly.

Portrait of Benjamin Boyce
Artificial Intelligence & Technology · November 23, 2026
Share

AI-generated editorial illustration from an imagined camera angle.
AI-generated editorial illustration from an imagined camera angle. Source image: dev.to.

AI coding assistants such as Claude Code, Cursor, and Codex utilize git worktrees to enable multiple agents to work simultaneously on a project (Dev.to, 2023). Each worktree functions as a complete checkout, complete with its own node_modules and build output, and they can accumulate over time without being noticed. For example, one user discovered 27 forgotten worktrees that consumed approximately 80 GB of disk space (Dev.to, 2023). [1]

The location of these worktrees varies depending on the tool used. Claude Code stores them in .claude/worktrees/ within each repository, while Cursor stores them in ~/.cursor/worktrees/ and Codex stores them in ~/.codex/worktrees/ (Dev.to, 2023). These worktrees can be identified using commands such as 'git worktree list' and 'du -sh' to assess their size (Dev.to, 2023). [1]

Before removing a worktree, users should check its status using 'git -C <path> status --short' to ensure no uncommitted changes are present (Dev.to, 2023). Additionally, users should verify if a branch has been merged using 'git log --oneline main..<branch>' or by querying GitHub with 'gh pr list --head <branch> --state merged --json headRefOid' (Dev.to, 2023). [1]

AI coding assistants such as Claude Code, Cursor, and Codex utilize git worktrees to enable multiple agents to work simultaneously on a project (Dev.to, 2023). Each worktree is a full checkout with its own node_modules and build output, and they can accumulate over time, consuming significant disk space (Dev.to, 2023). [1]

Advertisement

The location of these worktrees varies depending on the tool used. For example, Claude Code stores its worktrees in .claude/worktrees/ inside each repository, while Cursor and Codex use ~/.cursor/worktrees/ and ~/.codex/worktrees/, respectively (Dev.to, 2023). [1]

Before removing a worktree, users should check its status using 'git -C <path> status --short' to ensure no uncommitted changes are present. This command prints nothing if there are no uncommitted changes, helping users avoid losing data during cleanup (Dev.to, 2023). [1]

AI coding assistants such as Claude Code, Cursor, and Codex utilize git worktrees to enable multiple agents to work simultaneously on a project (Dev.to, 2023). These worktrees are full checkouts with their own node_modules and build output, and they can accumulate over time, consuming significant disk space (Dev.to, 2023). For example, one user reported finding 27 forgotten worktrees using 80 GB of storage, and 61 Codex worktrees for a Rails app consumed approximately 100 GB (Dev.to, 2023). [1]

The location of these worktrees depends on the specific tool used. Claude Code stores worktrees in .claude/worktrees/ within each repository, while Cursor stores them in ~/.cursor/worktrees/ and Codex stores them in ~/.codex/worktrees/ (Dev.to, 2023). Users can check the disk usage of these worktrees using commands such as 'du -sh .claude/worktrees/*' or 'du -sh ~/.cursor/worktrees/*/*' to assess the storage impact (Dev.to, 2023). [1]

Advertisement

Before removing a worktree, users should check its status using 'git -C <path> status --short' to ensure no uncommitted changes are present (Dev.to, 2023). This command helps users avoid losing uncommitted work if the worktree is removed prematurely (Dev.to, 2023). Additionally, users can use 'git log --oneline main..<branch>' to confirm whether a branch has been merged into main before removing the worktree (Dev.to, 2023). [1]

AI coding assistants such as Claude Code, Cursor, and Codex utilize git worktrees to enable multiple agents to work simultaneously on a project (Dev.to, 2023). These worktrees are full checkouts with their own node_modules and build output, which can accumulate over time and consume significant disk space (Dev.to, 2023). For example, one user reported finding 27 forgotten worktrees using 80 GB of storage, and 61 Codex worktrees in a Rails app consuming about 100 GB (Dev.to, 2023). [1]

The location of these worktrees depends on the specific tool used. Claude Code stores worktrees in '.claude/worktrees/' inside each repository, while Cursor uses '~/.cursor/worktrees/' and Codex uses '~/.codex/worktrees/' (Dev.to, 2023). Users are advised to check the status of a worktree before attempting to remove it using the command 'git -C <path> status --short' to ensure there are no uncommitted changes (Dev.to, 2023). [1]

To manage disk usage, users can adjust settings for each tool to reduce the number of worktrees retained. For instance, Claude Code users can lower the 'cleanupPeriodDays' setting, while Cursor users can adjust 'cursor.worktreeMaxCount' (Dev.to, 2023). Codex users can also lower the limit of 15 kept worktrees in its settings to prevent excessive accumulation (Dev.to, 2023). [1]

Advertisement

Sources

Dev.to

Prepared with AI assistance from the cited sources.

The Cali Reporter newsletter

The stories worth your time.

California, the country, and what comes next. Join our free newsletter for reporting that keeps you informed.

By joining, you agree to receive the Cali Reporter newsletter. Unsubscribe at any time. Privacy policy.

More in Technology

  • Modern Web Guidance 1.0 and Browser Compatibility

    Modern Web Guidance 1.0, announced by Chrome for Developers on November 10, introduces browser compatibility data to assist coding agents in building web features. The initiative emphasizes the importance of fallback…

  • Apache mod_http2 Vulnerability Detection with Nmap

    A new Nmap scripting module has been developed to detect the Apache mod_http2 vulnerability (CVE-2026-119618), addressing the challenges of identifying affected systems accurately.

  • Securing Remote Vendor Access in Industrial Networks

    Best practices for managing remote vendor access in operational technology (OT) networks emphasize controlled access points, multifactor authentication, and time-bound sessions to reduce cybersecurity risks.

Advertisement