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