Skip to main content

How cleanup works

Command examples

Commands use stim. If it is not installed globally, replace stim with npx stim.

Stim's background process, stimd, stops what is idle and deletes what can be rebuilt: build outputs, caches, the simulators and emulators it created, and worktrees whose work is merged. Your source, unpushed commits and anything in use stay. It is on by default and off in CI. Preview what it would do now:

stim gc --dry-run

The preview answers from the report stimd keeps fresh, the same one Stim Desktop shows, and says how old it is. Add --refresh to measure again now, for example right after adding or removing worktrees.

Phases​

A workspace moves through these as it sits unused:

PhaseStartsSetting (default)
Idle60 minutes without activityidle.minutes (60)
Dormant1 day without activityidle.dormantDays (1)
Finished2 hours after it last changed or finished, for a linked worktree that is merged or whose pull request has endedgc.worktreeGraceMinutes (120)

Activity is a Stim command, a build, a Metro request, an agent-device command or input to a device; for dormant, also a file or git write or a process in the checkout. App logs do not count. A clean linked worktree with no commits of its own counts as finished.

The machine has one level, set every minute from memory and the free disk of every volume Stim writes to:

LevelWhen
highfree disk under disk.minFreeGb (40 GB), a macOS memory warning for 10 minutes, or under 10% of RAM available
criticalfree disk under disk.criticalFreeGb (20 GB), or critical memory on macOS
refusefree disk under disk.hardFloorGb (5 GB) after cleanup ran

Above normal, cleanup works down a ladder, cheapest to rebuild first, on the short volume only, and stops once the level is normal. High cleanup also runs above 40 GB when a volume fills fast, and before a native build that may not fit. Memory pressure alone shuts down booted parked simulators, runs the idle stage and stops daemons. At refuse, start, ios and android fail with STIM_LOW_DISK: free space or run stim gc, then retry.

Deletion rules​

Caps are checked hourly, finished worktrees every 15 minutes, and unused things daily. High and critical add to the rows above them.

PhaseStopsDeletes
Idlethe dev server and workspace services, data kept; owned simulators and emulators shut down. With a device on another Mac, after maintenance.idleStopHours (6) insteadnothing; under disk pressure, its build outputs on the short volume, an Exact or tagged Cargo target/ included, and the app's Metro cache
Dormantbuild outputs, any root Cargo target/ included; owned simulators and emulators; a linked worktree's node_modules and Pods holding 256 MB of their own. Logs are archived
Main checkout, 7 daysits node_modules and Pods (idle.sourceDormantDays)
Finishedits dev server, devices and servicesthe worktree, and its branch when Stim created it and it has no unique commits, after archiving uncommitted changes for up to 30 days. One kept for its changes loses its owned devices
Any timeidle Gradle and Kotlin daemons; a restart of an unused Watchman over 2 GiB (1 GiB under memory pressure); a parked simulator left booted for 15 minutes; an idle workspace's booted device, when a run needs a slotover a cap: build outputs (20 GB), the build (10) and Metro (5) caches, stale Cargo target/ profiles, then other profiles' incremental data, of an idle target (25), parked devices (3 per platform). Unused for maintenance.olderThanDays (3): build outputs, cache entries, parked devices. Also unpinned Gradle versions (all at critical), TMPDIR leftovers, Jest's cache, unused iOS simulator runtimes (never one simctl does not mark deletable, one used in the last 7 days, one of the active Xcode's major version, the only one, the newest when none is used, or one ios.runtime pins), what removed projects left behind, logs at 8 MiB (one over 16 MiB is cut to its newest 8 MiB), recordings past the newest 15 minutes per device or 1 GiB per home, oldest first, and archives past archive.*
Highworkspaces idle 2 minutes, under memory pressure; booted parked simulatorsparked devices, oldest first; shared caches to half their caps; stale Cargo profiles and incremental data; build outputs of stopped workspaces; owned devices of workspaces idle 10 minutes
Criticalrunning workspaces idle at most 15 minutesevery parked device; shared caches and the fingerprint index, except entries in use; owned devices of workspaces idle 2 minutes; recordings, archived logs and archived agent actions. If still short: the npm, Yarn, pnpm, CocoaPods, Gradle and SwiftPM caches and Xcode's compilation cache, each while its tool is idle
A Mac hosting othersa hosted session without its client for 6 hours; idle Gradle daemons at low memorya stopped session's home after an hour; parked hosted devices; a build client's repository area unused for server.workerAreaMaxAgeDays (7), or sooner when its disk runs low

Only reported, by stim gc --dry-run: Android NDKs, unused system images, Exact's cache and Xcode device support.

Never touched:

  • Tracked files, untracked files git does not ignore, and unpushed commits.
  • Anything building, driven by an agent, leased, shared or hosted, except that a workspace with a device on another Mac still stops when idle and still loses build outputs.
  • A workspace pinned with maintenance.keep.
  • A worktree locked with git worktree lock, its dependencies and its build outputs.
  • Simulators and emulators you created, physical devices, ios/build, and Xcode DerivedData outside Stim, except its compilation cache at critical.
  • Checkouts no stim command ran in, unless discovery reaches them.

Exceptions:

  • A finished worktree goes with its uncommitted changes, once archived, and with all of its git-ignored files, such as a .env created there. Ignored files in a worktree are disposable state; keep what matters in the main checkout or outside the repository.
  • Removing a finished worktree tears down its workspace services, which deletes their data.
  • You reinstall the main checkout's dependencies yourself.
  • A pinned workspace still has its logs trimmed, its recordings expire, its hosted device stopped and its booted device shut down for a waiting run.
  • A locked worktree still goes idle and dormant; only the worktree, its dependencies and its build outputs stay.
  • daemon.mode off still stops an idle dev server that stimd runs, and its devices. In every mode logs rotate, recordings expire, and stim-server on a Mac hosting others deletes stopped sessions' homes; it stops abandoned sessions only in on.

Settings you might change​

ToSet
See what it would do, deleting nothingdaemon.mode report
Turn automatic cleanup offdaemon.mode off
Pin one workspace, from inside itmaintenance.keep true --scope workspace
Stop removing finished worktreesmaintenance.removeFinishedWorktrees false
Keep a finished worktree that has changesarchive.enabled false
Wait longer before idle (60 minutes)idle.minutes 120
Wait longer before dormant (1 day)idle.dormantDays 3
Never touch the main checkout's dependenciesidle.sourceDormantDays 0
Clean earlier or later (40, 20 and 5 GB)disk.minFreeGb, disk.criticalFreeGb, disk.hardFloorGb
Raise or lower a capcaches.buildCacheMaxGb, caches.ccacheMaxGb, maintenance.workspaceOutputsMaxGb, maintenance.cargoTargetMaxGb

Each is stim settings set <setting> <value> --scope machine, except maintenance.keep:

stim settings set daemon.mode report --scope machine

git worktree lock keeps one worktree from removal. maintenance.removeIdleWorktrees (off) also removes clean, pushed, unmerged worktrees unused for 3 days. idle.minutes 0 turns the idle and dormant stages off. The rest is in All settings.

Which checkouts it maintains​

  • Registered: a checkout where a project command ran, such as worktree warm, start, ios or android.
  • Named folders: the recognised projects directly inside each maintenance.managedFolders folder, and their linked worktrees inside it, under the same rules. A plain Node checkout there only has its finished linked worktrees removed. Stim 2.0.0 called this setting maintenance.discoverRoots; a config that still uses that name keeps working. Changing the setting stores it under the new name, which an older Stim sharing the same Stim home does not read, so update every copy in that home.
  • Automatic discovery (maintenance.autoDiscover, off): also the folders next to registered checkouts and the linked worktrees of every known repository. The node_modules and Pods of every checkout only automatic discovery found stay while the checkout does, unless maintenance.cleanAutoDiscoveredDependencies is also on.

A weekly scan of the home folder only reports, whatever maintenance.autoDiscover says: being found by it, or sitting in another tool's folder such as ~/.codex/worktrees, never brings a checkout under the rules above. stim doctor lists the checkouts no rule above reaches, with the command that adds their folder to maintenance.managedFolders.

A discovered worktree is removed by the rules of a registered one, finished and clean, and only when nothing runs from it and no agent session is in it. That includes one another tool keeps inside the repository, such as .claude/worktrees. Its git-ignored files go with it, as for any finished worktree. Nothing is archived, and no git fetch runs.

To exclude a checkout, run stim settings set maintenance.keep true --scope committed in it, or drop its folder from the list.

stim settings set maintenance.managedFolders '["~/Developer"]' --scope machine
stim gc --dry-run

What commands delete​

This page leaves out what a command does to its own target:

Command or actionWhere
stim stopCommands, web
stim worktree removeRemove a worktree
stim gc and its flagsCommands
Reusing a parked deviceWhat Stim deletes
A device hosted on another MacHosted parking and restart
stim-ci runWhat a run deletes

See what it did​

stim logs --source gc lists what stim gc and the maintenance passes removed; the pressure ladder logs to daemon.ndjson in the Stim home. stim status shows the level and each workspace's stage.

Explain cleanup on this machine

Read stim guide cleanup, then run stim gc --dry-run and stim worktree list --all. Explain what Stim would delete or stop on this machine and why. Do not run stim gc without asking me.