A prompt that has a coding agent measure what fills a Mac’s disk, then clear it without losing work. Written for iOS development, where simulators and build output take most of the space.
Help me free disk space on this Mac without losing work. Measure first and delete nothing until I’ve chosen what goes. If you need something from me, such as where I keep my code, ask in one short message.
lsof +D <path>), and anything owned by an app that’s running. Quit Xcode and Simulator before clearing their files.git status in each repository you touched. No tracked file should show as deleted.Start with free space, then a ranked map. -x keeps du on the real volume. This takes about a minute:
df -h /System/Volumes/Data
du -xhd 2 ~ 2>/dev/null | sort -rh | head -40
Then the places iOS development fills:
du -xsh ~/Library/Developer/Xcode/{DerivedData,Archives,"iOS DeviceSupport"} \
~/Library/Developer/CoreSimulator/{Devices,Caches} ~/Library/Caches 2>/dev/null
xcrun simctl runtime list
Simulators by size and last use:
xcrun simctl list devices -j | python3 -c '
import json, sys
for runtime, devices in json.load(sys.stdin)["devices"].items():
for d in devices:
print("%5.1f GB %-9s %-10s %s %s" % (d.get("dataPathSize", 0) / 1e9, d["state"], d.get("lastUsedAt", "never")[:10], d["name"], d["udid"]))
' | sort -rn
In each folder where I keep code, list build output and dependencies: DerivedData folders inside projects, .build, node_modules, Pods, Python virtual environments, tmp folders, and Git worktrees (git worktree list), with each worktree’s last commit and whether its branch is merged.
~/Library/Developer/CoreDevice/DeviceFS takes no space. It’s a virtual mount showing booted simulators and attached iPhones. Plain du counts it and can double the size of ~/Library/Developer.df right away.Group what you found into three tiers, biggest first, each item with its size, why it’s in that tier, and the command that would clear it:
Then ask which items to clear, and stop.
These usually hold most of the space:
xcrun simctl delete unavailable.xcrun simctl erase <udid>. Something boots them, they grow, and nobody owns them.find ~/Library/Developer/CoreSimulator/Devices/<udid>/data/Library/Application\ Support/PRBPosterExtensionDataStore \
-type d -name SnapshotCache.cachedb -prune -exec rm -rf {} +
data/private/var/MobileAsset). They download again within minutes of the next boot.xcrun simctl runtime delete <id>, after deleting its simulators.~/Library/Developer/Xcode/iOS DeviceSupport is copied again the next time that device connects. Delete versions my devices no longer run.~/.npm, ~/Library/Caches/pip, the pnpm store) download again on demand. Clear them with the tool’s own command, such as npm cache clean --force or pnpm store prune, rather than deleting the folders.~/Library/Application Support/Google/Chrome/OptGuideOnDeviceModel and downloads it again if you only delete it. Its policy defaults write com.google.Chrome GenAILocalFoundationalModelSettings -int 1, then a Chrome restart, stops that. Ask me first, because it turns off Chrome’s built-in AI features.crx_cache, hold installers for updates already applied..xcresult) in project folders. Running the tests again makes new results, not the old ones.node_modules with no lockfile beside it. It can’t be reinstalled reliably..wrangler folders. They hold local database state for wrangler dev.Scan again a few minutes later, report what came back, and run git status in each repository you cleared from.
Offer to set these up, and add them to each project’s AGENTS.md or CLAUDE.md so other agents follow them:
xcodebuild … -derivedDataPath DerivedData.noindex. The .noindex suffix keeps Spotlight out.