caffeinate, flag by flag
Every Mac ships with a one-word fix for most sleep problems. Here's what each flag does, and where it stops being enough.
The useful form: wrap the command
Put caffeinate in front of the thing you're running. The Mac stays awake until that command exits, then goes back to normal on its own.
caffeinate -i claude
The flags
The three things it can't do
It can't survive the lid. None of these flags hold off sleep when you close the lid on battery. That sleep isn't an idle decision, so the request caffeinate makes doesn't apply. If you need the lid shut, read the 23:52 problem.
It can't tell working from waiting. caffeinate -i claude holds the Mac awake for as long as the session is open — including the hours an agent sits idle at its prompt, waiting for you. Your battery pays for a run that already finished.
It can't tell you anything. If the agent stops to ask for permission at 23:52, caffeinate keeps the Mac awake while the run sits blocked until morning.
UnIdle does what caffeinate -i does, without the wrapper — and closes the other two gaps. Free:
- Detects Claude Code, Codex, Aider, Gemini, Cursor and opencode on its own. Nothing to type before each run.
- Holds sleep off only while an agent is actually working, and lets go the moment it's done.
- Notifies you when a run finishes — and, for Claude Code, the moment it stops to ask for a yes.
Pro adds the lid: it keeps running with the lid shut on battery.