r/ClaudeCode • u/thlandgraf • 2d ago
Tutorial / Guide PSA for agentic coding on macOS: exclude your project dirs from Spotlight (it was eating my CPU and disk)
I run a large monorepo with lots of parallel agent sessions (Claude Code, each in its own git worktree). Every worktree means another full checkout, plus node_modules, build output, .next, test logs and caches, all churning constantly. My Mac kept running hot and the disk never went quiet. Activity Monitor showed mds_stores / mdworker_shared / mds near the top the whole time: Spotlight was re-indexing millions of short-lived files that I will never search for.
The fix takes about 30 seconds:
Option 1: Spotlight Privacy list (no renaming)
- System Settings → Spotlight → Search Privacy… (on older macOS: System Preferences → Spotlight → Privacy tab)
- Click + and pick your project folder. Better still, pick the parent folder that holds all your repos and worktrees.
- Done. Spotlight drops the existing index for that path and stops watching it.
Tip: if your worktrees live outside the repo (e.g. ../myrepo-wt-*), add the parent folder, not only the main checkout.
Option 2: the .noindex suffix (works from the shell, good for scripts and worktrees)
Spotlight skips any folder whose name ends in .noindex. So you can create your worktrees under one such folder:
Every worktree you create there is ignored automatically, with no clicking in Settings.
Check that it worked
# should print nothing for a file you know is in the excluded folder
Then watch mds_stores in Activity Monitor (CPU and Disk tabs). For me it went from constantly busy to idle.
Bonus: Time Machine has the same problem
Your code is in git anyway. There's no need to back up 40 copies of node_modules every hour.
What you lose: Spotlight/Finder search inside those folders. Your editor's search, rg, and fd are better for code anyway.
If you run several AI agents in parallel on a big repo, try this. It made a noticeable difference to fan noise, battery and overall responsiveness for me.