Original Reddit post

If you keep Claude Code sessions running for days on a Mac, macOS will quietly delete their working files. Claude Code keeps each session’s scratchpad and background-task output under /private/tmp/claude-<uid>/ . Once a day macOS runs /etc/periodic/daily/110.clean-tmps , and with the default settings it deletes every file under /tmp whose access, modify and change times are all more than 3 days old. Two things make it worse than it sounds: Running a file doesn’t count as using it. On my machine, stat on a helper script the session had run every day for four days still showed the access time from the day it was written. Anything nobody has edited in 3 days is fair game, however often it runs. It hits running work. It deleted the .output file of a background dev server that was still running, so the session could no longer read that server’s logs. One run removed about 1,800 files across my long-running sessions: helper scripts, notes, tracker files. The next morning the agent tried to run a script that no longer existed. Check whether it happened to you: grep claude- /var/log/daily.out Every removed file is listed under “Removing old temporary files”. Fixes, from least to most invasive: Keep anything that has to survive in the project or under your home directory, not the scratchpad. If Claude likes to build tools in the scratchpad, say so in CLAUDE.md . For a session that has to keep its scratchpad, run a keep-alive that refreshes access times without touching modify times, scoped to that session’s folder: while true; do find /private/tmp/claude-$(id -u)/<project>/<session-id> -exec touch -a {} + 2>/dev/null; sleep 21600; done Raise the threshold system-wide: create /etc/periodic.conf.local containing daily_clean_tmps_days=“30” (needs sudo). The ignore list in that config only matches file names, so it can’t exempt a whole folder. A reboot clears /tmp too, so the scratchpad was never durable. But a silent cleanup after three days, run by a daily job you never see, is much easier to miss than a reboot. On Linux, systemd-tmpfiles often ages out /tmp as well (10 days is a common default), so the same thing applies there on a longer fuse. submitted by /u/2bluenucleus

Originally posted by u/2bluenucleus on r/ClaudeCode