caffeinate vs Latte for coding agents
macOS's built-in caffeinate command is great at one job. Where it fits for Claude Code and Codex, and where it runs out.
By Harsh Soni, maker of Latte · Updated
caffeinate is the right tool if your lid stays open and you're happy to start it yourself. Latte is for closing the lid and walking away: it knows when your agents are working, survives a closed lid, and lets the Mac sleep when the work is done.
What caffeinate does well
It ships with macOS, costs nothing and does one thing reliably. The most useful forms for coding agents:
caffeinate -i claude # hold off idle sleep until Claude Code exits
caffeinate -i codex # same for Codex
caffeinate -i -w <pid> # hold until an existing process exits
caffeinate -s -t 7200 # hold off system sleep for 2 hours (on power only)Tying it to the agent's process with caffeinate -i <command> or -w means it lets go on its own when the agent exits. That's already better than leaving a keep-awake app on.
Where it runs out
- Closing the lid still sleeps the Mac, unless you're plugged into power and an external display (clamshell mode).
-sonly applies on power, too. - It can't tell working from waiting. If the agent stops on a permission prompt at midnight, caffeinate holds the Mac awake all night for nothing.
- Nobody answers the prompt. The run sits there until you're back.
- No guards. Nothing watches the battery or the heat.
Side by side
| caffeinate | Latte | |
|---|---|---|
| Lid open, idle sleep | Held | Held while an agent works |
| Lid closed | Sleeps (unless clamshell mode) | Held, on battery too if you turn it on |
| Knows if the agent is working or waiting | No | Yes, through each agent's hooks |
| Lets go when the work is done | When the process exits | As soon as the agent finishes |
| Prompts on your phone | No | Claude Code, via Telegram or ntfy |
| Battery, heat and stuck-run guards | No | Yes |
| Setup | None, it's built in | Install the app, connect agents with one click |
| Price | Included with macOS | $2 a month after a 7-day trial |
Which should you use?
If you always keep the lid open, caffeinate -i in front of your agent command is a perfectly good answer. If you close the lid and leave, or you want the run to keep moving while you're away, that's what Latte is for. See also Amphetamine vs Latte and Claude Code's built-in keep-awake.
Common questions
- What does caffeinate -i do?
- It holds off idle sleep. Put a command after it, such as caffeinate -i claude, and the Mac stays awake until that command exits.
- Why does my Mac still sleep with caffeinate running?
- Because you closed the lid. caffeinate cannot override lid-close sleep unless the Mac is in clamshell mode, and its -s flag only works on power.
- Is Latte a replacement for caffeinate?
- For coding agents, yes. It holds the Mac awake only while an agent is working, including with the lid closed, and lets it sleep when the work is done. For everything else, caffeinate is still the right tool.
Latte keeps Claude Code, Codex and Grok working with your MacBook closed, sends approvals to your phone, and lets the Mac sleep the moment the work is done.