Keep your Mac awake while Claude Code runs — lid closed too
Nothing kills a two-hour agent run like macOS deciding it's nap time. Here's the honest toolbox — the free built-ins, the beloved menu bar apps, and where "lid closed, on battery, in a bag" gets genuinely hard.
Option 1 — caffeinate: free, built in, scriptable
macOS ships a keep-awake CLI. The pattern that fits agent work best ties the wake lock to a specific process, so the Mac can sleep the moment the run ends:
caffeinate -dimsu -w <pid> — stay awake while that pid lives. Or wrap the
whole run: caffeinate -dims claude.
The catch: nothing survives closing the lid on battery. Clamshell sleep is enforced by the OS unless you're on power with an external display, or you get into pmset territory below. And when it does stay awake, nothing tells you the agent is waiting on a question.
Option 2 — Amphetamine: the beloved menu bar classic
Amphetamine is free, excellent, and the default answer for "keep my Mac awake" — sessions, triggers, schedules. If your need is general-purpose wakefulness, use it and pay nothing.
The catch for agent work: it keeps the Mac awake, but it doesn't know or care what your agent is doing. The run still stalls silently on a permission prompt; closed-lid operation still fights macOS clamshell rules (their closed-display mode has real prerequisites); and there's no story for the Mac staying reachable from your phone once you walk away.
Option 3 — pmset disablesleep: the big hammer
sudo pmset -a disablesleep 1 makes the Mac ignore the lid switch entirely. It
works — and it's dangerous as a habit: forget to turn it back on and your laptop stays hot and
draining in the bag forever. If you go this route, script the revert, always.
The real problem is usually not sleep. It's that the run needs you and you're not there: a plan to approve, a permission gate, a multi-choice question. A perfectly awake Mac with a stalled agent is still a wasted afternoon.
Option 4 — DevFob Nomad: agent-aware keep-awake (disclosure: ours)
DevFob is our product, so weigh accordingly. Nomad mode was built for exactly the bag-and-coffee-shop scenario:
- Wake tied to the work: keeps the Mac awake and working lid-closed while sessions run — with honest battery warnings, and a scripted, guaranteed revert (the pmset hammer, wielded carefully: one admin grant, automatic cleanup, loud alerts if a revert ever fails).
- Reachable, not just awake: the Mac auto-joins your iPhone's hotspot when known Wi-Fi drops, so the phone link survives leaving the house.
- Answerable: the part the wake-lock tools can't do — the question that would have stalled the run arrives on your phone or watch as a real form. You answer; the run continues. All local, end to end encrypted, no cloud, no account.
If you just want the screen to stay on, Amphetamine is free and great. Nomad earns its place when the thing you actually want is the run to finish — awake, connected, and unblocked, with the lid shut. $15 once, 14-day trial. (Fair caveat: sustained lid-closed work on battery runs warm and drains fast — physics applies; Nomad tells you instead of pretending otherwise.)
Tool details accurate as of July 2026; macOS power management changes across versions. Something wrong here? Tell us.