Running into this?

My Mac runs hot while agents work, and mds_stores and mdworker_shared are using a lot of CPU

I kept the agent’s scratch folder out of Spotlight with .noindex, then added ~/Library and the Git repositories my agents work in to Search Privacy.

beforeSpotlight at about 430% CPU · load average 31.32
after4 minutes later: 0.2% CPU · load average 12.98
check Spotlight’s indexing load and exclude folders where agents write lots of files, without turning off search
Text for your agent · 15 lines
Situation: your Mac runs hot while agents work. In Activity Monitor’s CPU tab, `mds_stores` and many `mdworker_shared` processes are near the top.

Why: Spotlight indexes new files. Agents can create thousands of them out of sight: Git worktrees, `node_modules`, build output, and test copies. On a Mac mini on November 28, 2026, Claude Code wrote 330,735 test files (8.2 GB) to a scratch folder under `~/Library/Application Support` in five minutes. `mds_stores` was using 109% CPU, and 33 `mdworker_shared` processes were using 289% combined. The scratch folder was excluded with `.noindex`. Two readings four minutes apart showed total Spotlight CPU at about 430% and 0.2%, and the Mac’s load average at 31.32 and 12.98. Later, after the Search Privacy exclusions were added, an unscoped Spotlight query found 31 indexed items changed in the past 24 hours.

Do:
1. Sort Activity Monitor by CPU. If `mds_stores` and `mdworker_shared` are near the top, find the folders where your agent is writing lots of files.
2. In System Settings › Spotlight › Search Privacy, click `+`. Press `⌘⇧G` to go to a scratch or output folder and add it. Excluded folders also disappear from search results. If you don’t need search in these locations, you can do what I did: add `~/Library` and each Git repository your agents work in.
3. If you control the code that writes temporary files, give new scratch folders names ending in `.noindex`, such as `scratch.noindex`. The Search Privacy list is stored on this Mac. Add the folders again on a new Mac or after a clean install.

Verify:
- `mdutil -s /` → `Indexing enabled.`; indexing is still on for the startup disk. Turning off search result categories doesn’t stop indexing.
- `mdfind -onlyin ~/Library -count 'kMDItemContentTypeTree == "public.item"'` → `0` once `~/Library` drops out of the index. If you excluded a different folder, use its path instead of `~/Library`. Run the same query in a folder containing a file you know Spotlight can find: that count should be above zero. A zero from `kMDItemFSName == "*"` is not proof.
- `mdfind -onlyin ~ -count 'kMDItemFSContentChangeDate >= $time.now(-86400)'` → number of indexed items in your home folder that changed in the last 24 hours. Check Spotlight’s CPU use again in Activity Monitor after a few minutes.

Don't: turn off indexing everywhere with `sudo mdutil -a -i off`. Spotlight file searches and app launchers that rely on the index can silently return no results. Excluding the folders causing the problem is enough.