Claude Code never cleans up /tmp/claude-{UID}/ — can grow to 100GB+

Resolved 💬 5 comments Opened Mar 17, 2026 by Morriz Closed May 3, 2026

Problem

Claude Code writes background task outputs and tool results to /private/tmp/claude-{UID}/ on macOS (or /tmp/claude-{UID}/ on Linux). These files are never cleaned up — not on session end, not on CLI exit, not on any lifecycle event.

Why this matters

  • macOS does not auto-clean /tmp while the system is running. The periodic cleanup only runs on reboot, and desktop machines rarely reboot. Linux systemd-tmpfiles may help eventually, but default retention is 10 days — still too long for high-throughput use.
  • In environments with many concurrent sessions (e.g. multi-agent orchestration, CI pipelines, or power users running several conversations), the accumulation is rapid.

Observed impact

  • 107 GB accumulated across ~50+ session directories in /private/tmp/claude-502/ over a few days of multi-session use.
  • Disk pressure caused other tools to fail and required manual intervention to recover.

Expected behavior

Claude Code should clean up task output files when sessions end, or implement a periodic reaper for stale files (e.g. files older than N minutes with no active session referencing them).

Workaround

Manual cron job:

# Clean up files older than 60 minutes
find /tmp/claude-$(id -u)/ -type f -mmin +60 -delete

Or a launchd plist / systemd timer equivalent for continuous cleanup.

Environment

  • macOS (but applicable to any OS)
  • Claude Code CLI (latest)
  • High-session-count usage pattern (multi-agent orchestration)

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗