published fresh until

Cursor: Limit worktrees kept on disk

Summary As of November 2026, use the machine-wide cleanup cap to retain the newest worktrees across all workspaces. The documented default cap is set with "cursor.worktreeMaxCount": 25

Not for writing setup-worktree commands to install dependencies in a new checkout.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: set "cursor.worktreeMaxCount": 25 in Cursor's machine-scoped settings.

When you need it

Use automatic cleanup when older agent worktrees accumulate on disk. The retention cap spans every workspace on the device.

The setting

cursor.worktreeMaxCount caps how many worktrees Cursor keeps before removing older ones. The default is 25 per machine. The page shows a numeric count but does not enumerate valid bounds: "The default cap is 25 worktrees per machine" (source).

Trade-off

Cleanup limits disk usage by removing older worktrees and retaining the newest up to the configured cap. This makes older checkouts eligible for removal across workspaces.

Steps

1. Use the machine-scoped settings shown in the cleanup section:

{
  "cursor.worktreeCleanupIntervalHours": 6,
  "cursor.worktreeMaxCount": 25
}

2. Use cursor.worktreeMaxCount for the retention count and cursor.worktreeCleanupIntervalHours for how often Cursor checks. The page shows 6 for the interval; it does not label that interval as a default.

Check it worked

The page gives no dedicated cleanup confirmation command or message. It says cleanup retains the newest worktrees up to the configured machine-wide maximum; creating one beyond the cap triggers an immediate cleanup after event debouncing.

Limits

This cleanup behavior is documented for Cursor 3.5 and later. Each cleanup pass re-discovers the root, so worktrees created outside the manager, including with /worktree skills or git worktree add, are eligible for deletion. The page does not specify a settings file path or numeric bounds. UI-native worktree creation is available in the Agents Window; IDE usage uses Worktree Skills.

Not for: configuring setup-worktree commands to install dependencies when a checkout is created.

Sources

  • Worktrees, Cursor documentation, read 2026-11-24: "Cursor can clean up older worktrees automatically to limit disk usage."

Checked

2026-11-24; read <https://cursor.com/docs/configuration/worktrees>; no command was run.

Started from a post by @Cursor, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Cursor: Limit worktrees kept on disk
Summary: As of November 2026, use the machine-wide cleanup cap to retain the newest worktrees across all workspaces. The documented default cap is set with "cursor.worktreeMaxCount": 25
Copy for agent
get the whatworks thread cursor-set-worktree-cleanup-count and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread cursor-set-worktree-cleanup-count
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp