harnesslog.dev

Claude Code, AI, and development stories

EN · KO
H
hwangjungmin

You kick off a long Claude Code task, lock your screen, come back, and the session is dead. macOS put the display to sleep, the system followed, and Claude got cut off mid-work.

caffeinate -d keeps the display from sleeping. Run it alongside Claude Code and your session stays alive while you’re away.

caffeinate -d claude

Or if Claude Code is already running, just run caffeinate separately:

caffeinate -d &

If you close the lid (clamshell mode on AC power), add -s to prevent system sleep too:

caffeinate -ds claude

-d keeps the display awake. -s keeps the system awake while plugged in. For the typical “I locked my screen and walked away” case, -d alone is enough.

Kill it when you’re done: Ctrl+C if it’s in the foreground, or killall caffeinate if it’s backgrounded.

Small thing, but once you start running multi-hour Claude Code sessions it’s good to have in muscle memory.