Mac YOLO Safeguards

Where AI coding agents fill your Mac's disk, and how to clear it

Claude Code, Codex and Cursor all keep things on disk: session transcripts, logs, caches, scratch folders, and a git worktree for each task. None of it shows up as one obvious item in Storage settings, and it adds up. Measure first.

See what is big

This prints the size of each common location. A missing folder just prints an error; ignore it.

du -sh /private/tmp/claude-$(id -u) \
  ~/.claude/projects ~/.claude/file-history ~/.claude/shell-snapshots \
  ~/.codex/sessions ~/.codex/archived_sessions ~/.codex/worktrees \
  ~/Library/Application\ Support/Cursor/logs \
  ~/Library/Application\ Support/Cursor/CachedData \
  ~/Library/Application\ Support/Cursor/User/workspaceStorage \
  ~/Library/Caches/ms-playwright 2>/dev/null

For anything else, list the biggest folders inside a directory:

du -hd1 ~/.codex 2>/dev/null | sort -h | tail -8

Quit your agents before you delete anything, so a running session doesn't lose a file it is using.

Claude Code

Scratch folders: /private/tmp/claude-<your user id>. Claude Code writes temporary session files and task output here. A folder's own date does not change when a file inside it changes, so check every file. Quit all Claude Code sessions first, then list the sub-folders with no file changed in the last day:

for d in /private/tmp/claude-$(id -u)/*/; do [ -z "$(find "$d" -type f -mtime -1 -print -quit)" ] && du -sh "$d"; done

If the list looks right, and no Claude Code session is open, remove those:

for d in /private/tmp/claude-$(id -u)/*/; do [ -z "$(find "$d" -type f -mtime -1 -print -quit)" ] && rm -rf "$d"; done

Keep the top folder itself. macOS also clears /private/tmp on its own schedule, but a busy machine can fill it long before that.

Transcripts: ~/.claude/projects. One .jsonl file per session. This is what lets you resume an old conversation, so deleting a file means you can't resume that session. Preview files older than 30 days, then delete them:

find ~/.claude/projects -name '*.jsonl' -mtime +30 -print
find ~/.claude/projects -name '*.jsonl' -mtime +30 -delete

These files can also contain API keys that the agent printed or read. See how to find and blank them out if you want to keep the transcripts.

Worktrees: .claude/worktrees inside a repo. Each task or subagent can get its own checkout, with its own node_modules. See "Worktrees" below.

Codex

Codex keeps session history in ~/.codex/sessions, finished sessions in ~/.codex/archived_sessions, and task checkouts in ~/.codex/worktrees. As with Claude Code, history is what lets you look back at a session, so delete by age:

find ~/.codex/sessions ~/.codex/archived_sessions -type f -mtime +30 -print
find ~/.codex/sessions ~/.codex/archived_sessions -type f -mtime +30 -delete

Leave the rest of ~/.codex alone: it also holds your login, settings, skills and plugins.

Cursor

Quit Cursor first. Logs and compiled-code caches are rebuilt when it starts, so these are safe to remove:

rm -rf ~/Library/Application\ Support/Cursor/logs
rm -rf ~/Library/Application\ Support/Cursor/CachedData

User/workspaceStorage in the same folder keeps per-project state, one folder per workspace you have opened. It is larger for projects you opened long ago. Deleting a folder there resets that project's editor state, so only remove folders for projects you no longer use. Leave User/globalStorage alone unless you know what you are removing: it holds app-wide state.

Worktrees

Agents that work on several tasks at once often use git worktrees: extra checkouts of the same repo. Each can hold a full copy of node_modules or build output. From the main repo, list them:

git worktree list

Before removing one, check that it has nothing uncommitted and no unmerged branch you care about:

git -C /path/to/worktree status --short
git -C /path/to/worktree branch -vv

If status prints nothing and branch -vv shows the branch tracking a remote with no "ahead" count (or the branch is merged), remove it:

git worktree remove /path/to/worktree
git worktree prune

git worktree remove refuses to delete a worktree with uncommitted changes. Don't add --force unless you have looked at what you would lose. The branch stays in the repo either way.

If you only want space back and plan to keep the worktree, delete its node_modules. npm install brings it back.

Other things agents leave behind

Let the Mac do it

The free Mac YOLO Safeguards menu bar app shows disk use and has a one-click clean for the safest part of this list: the files and folders inside Claude Code's scratch folders in /private/tmp that nothing has changed in for 24 hours, the Swift and Node compile caches kept there and stale developer caches. It does not delete your Codex or Cursor history, your Claude Code transcripts, or your worktrees. Those depend on what you want to keep, so use the commands above for them.

Pro Guard, $29 once, runs that clean automatically when free disk space runs low. Full refund within 30 days.

Download for Mac (free)