Skip to content

Instantly share code, notes, and snippets.

@yowmamasita
yowmamasita / claude-cleanup.md
Last active January 21, 2026 07:07
Claude Code CLI leaves orphaned background processes that consume CPU/memory. This launchd daemon auto-kills processes not attached to a terminal (TTY) every hour, keeping only your active sessions.

Auto-cleanup Orphaned Claude Code CLI Processes on macOS

Claude Code CLI can leave orphaned background processes that consume CPU and memory. This solution automatically kills Claude processes that are no longer attached to a terminal.

How it works

Active Claude sessions are attached to a TTY (e.g., s001, s002). Orphaned processes show ?? in the TTY column. This script kills only the orphaned ones.