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:

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.)

Try DevFob free — 14 days $15 until Aug 14, then $29 · no account · macOS 14+

Tool details accurate as of July 2026; macOS power management changes across versions. Something wrong here? Tell us.