Hibernot Buy €9

Guides

Run Codex or Claude Code overnight on a MacBook: a checklist

You give the agent a big task and go to bed. In the morning it has done step 3 of 20. Long runs on a laptop fail for a handful of boring reasons; here they are, with the fix for each.

Updated 16 November 2026 · 3 min read

Short answer. Plug it in, leave the lid open and run caffeinate -i -w <pid>: that’s free and solves most overnight runs. Closing the lid, or running on battery, needs more care: sleep, network, permissions and heat.

The five things that stop a run

  1. Sleep. Agents like Codex and Claude Code run on your Mac but call models in the cloud. When the Mac sleeps, the connection drops and the run stalls or fails.
  2. Network. Wi-Fi that drops at night, or a laptop that leaves home and loses it.
  3. A question nobody answers. The agent asks permission to run a command and waits. All night.
  4. Battery. A Mac kept awake on battery runs out, then sleeps anyway.
  5. Heat. Lid closed, in a bag, doing heavy builds: the Mac slows down to protect itself, and the battery ages.

The checklist

At a desk, overnight

  • Plug it in.
  • Leave the lid open (dim the screen to zero if the light bothers you), or use Apple’s closed-display mode with an external display.
  • Keep it awake for exactly as long as the agent runs:
    caffeinate -i -w $(pgrep -n codex)    # or: pgrep -n claude
    It ends by itself when the agent exits, so the Mac sleeps normally afterwards.
  • Pre-approve the routine commands your agent needs (tests, builds, git status), and keep anything destructive on “ask”. Codex and Claude Code both have approval settings; check their documentation, and never hand an agent blanket permission on a machine with your real files just to get through the night.
  • Log to a file so you can see in the morning where it stopped.

On the move, lid closed

In the morning: what happened?

If the run stopped early, find out whether the Mac slept before blaming the agent. Terminal keeps a log of every sleep and wake, with the reason: see did my Mac sleep with the lid closed?

Where Hibernot fits

Hibernot covers the lid-closed case for Claude and Codex: it keeps the Mac awake without a password, sees Claude Code (through its hooks), the Claude desktop app and Codex, command line or app (from their network activity), goes back to sleep 5 minutes after the agent stops, stops at the battery temperature you choose, and notifies your phone on iPhone or Android. For other agents, caffeinate -w on a desk or one of the apps in the comparison will do.