Take A Coffee

caffeinate and closed-lid MacBook

caffeinate helps idle sleep. Closed-lid work is a separate host mode.

For Claude Code, Codex, tmux, and local LLM jobs, separate open-lid idle sleep from lid-close sleep before trusting an unattended run.

Idle

Use caffeinate for open-lid idle

caffeinate can prevent idle sleep while the Mac is open or locked. Do not treat that as proof a closed lid will keep local work running.

Lid

Check the lid-close path

For a moving MacBook, test pmset, power source, network reachability, and whether timestamps keep changing after the lid closes.

Restore

Make it temporary

Closed-lid awake mode needs a clear off step. Restore defaults after the agent run and check heat before bag transport.

Receipt command

Prove the process kept moving after the lid closed.

Use this alongside any caffeinate and closed-lid MacBook script so you can tell whether the host actually stayed alive during the window.

while true; do date >> ~/caffeinate-closed-lid-test.log; sleep 30; done

The minimum closed-lid checklist.

Before

Record the baseline

Write battery percent, power source, temperature/heat feel, network status, and the exact awake mode you enabled before closing the lid.

During

Keep proof outside Claude

A timestamp loop outside the agent tells you whether the Mac stayed awake or only resumed later with the terminal still open.

After

Restore before transport

Recheck battery and heat, stop awake mode, restore normal sleep settings, then leave the receipt before putting the MacBook in a bag.

Agent prompt

Make the battery-lid test auditable.

Use this before trusting a MacBook to keep a local agent alive with the lid closed.

Run a closed-lid battery acceptance test for this Mac. Record start time, battery percent, power source, thermal state, Wi-Fi/SSH reachability, pmset assertions, and a heartbeat file outside the agent. Close the lid for a short window, reopen, confirm heartbeat timestamps kept moving, record end battery and heat, restore normal sleep settings, and leave a receipt. Stop if the machine gets hot, battery drops too fast, network dies, or restore is unclear.

Want Codex to handle the closed-lid mode?

Take A Coffee gives Codex a temporary awake mode, host checks, restore step, and receipt for local macOS and Windows agent work.

Run it with Codex

Does caffeinate work with the lid closed?

It prevents idle sleep in normal open-lid use. Lid-close behavior depends on macOS power settings, power source, thermal state, and hardware policy.

Why test with timestamps?

They prove the process kept moving during the closed-lid window, instead of only proving the session still exists after wake.

What should restore do?

Turn temporary awake settings off, report battery and heat state, and leave a short receipt so the next run starts from a known baseline.