Disclosure: I'm Dawon Lee, the solo developer of Lidnight, a paid macOS menu bar app mentioned below.
If you start a long Claude Code or Codex task on a MacBook and shut the lid, macOS puts the machine to sleep and drops the session. I wrote about the caffeinate and pmset mechanics in an earlier post. If you want to check whether past runs overlapped with sleep or DarkWake, I also maintain a read-only MIT CLI called lid-check that cross-checks local Claude Code, Codex, Antigravity, and Gemini CLI logs against pmset history.
Keeping the Mac awake with the lid closed is only part of it. Three other things can still leave a run unfinished by morning.
1. Permission prompts and questions at 2 AM
Long runs often stop to ask for input. Claude Code pauses on shell permission prompts and AskUserQuestion turns, and Codex pauses on approval prompts unless configured for unattended mode. With the lid shut, the Mac stays powered on all night waiting for a single keypress.
In Lidnight (v1.11.87, native Swift AppKit/SwiftUI, Apple Silicon, macOS 13+, Apple Developer ID notarized), short status alerts go to your phone (no code or prompt body in push text), and the remote status board uses an end-to-end encrypted relay so you can approve, deny, or reply away from your desk. Commands Lidnight flags as risky can only be approved on the Mac.
2. Hitting a 5-hour or weekly quota window at 3 AM
Even without prompts, an overnight run can hit a usage limit halfway through. Claude Code can often continue on its own after a 5-hour reset, but a weekly limit, a long sleep, or a Codex session can still leave the work waiting for you.
Lidnight's free tier tracks open-lid sessions, local token and API-cost estimates across 13 tools, and live 5h/weekly usage limits for Claude Code, Codex, Antigravity, and Kiro inside the menu bar popover. The Pro tier adds opt-in auto-continue for Claude Code and Codex after a usage limit resets, along with a wake-up recap showing run duration, completed runs, token spend, and start-to-end battery percentage.
3. Forgetting that sleep is disabled
Running pmset disablesleep 1 manually is easy to forget. If a script crashes or you close the lid and walk away, the Mac can drain flat or run hot.
These are the limits I built in:
- Battery, idle, and time cutoffs: Auto-sleeps ~10 minutes after agents go quiet, stops at a configurable battery floor (default 10%), and caps auto sessions at 8 hours by default.
- Thermal guard: On lid-closed battery runs, reads SMC battery temperature sensors, alerts at 42°C, and by default sleeps the Mac at 45°C. On AC power, stops when macOS reports a critical thermal state.
- Crash and reboot recovery: A watchdog process restores sleep if the app terminates unexpectedly, and a LaunchDaemon restores normal sleep settings on boot so the machine does not stay stuck awake.
- Never in a closed bag: Software thermal cutoffs do not make a backpack safe. Never run a lid-closed laptop inside a bag.
If you only need keep-awake, use a free tool
If stopping macOS from sleeping on lid close is your entire problem, you don't need to pay for anything. As of December 5, 2026, open-source MIT projects already handle basic lid-closed keep-awake for $0:
- Adrafinil (MIT, 537 GitHub stars, requires macOS 26.4+; unofficial macOS 15 backport exists)
- StayAwake (MIT, 76 GitHub stars, unsigned ad-hoc build, requires macOS 26.0+)
If you're fine running your own Telegram bot, open-source projects like Agent Session Pilot also handle remote approvals for free.
The downsides: Lidnight is closed source and costs $9.99 USD for 1 Mac (or $14.99 USD for 3 Macs with the same key, one-time purchase, plus regional tax at checkout). Like Adrafinil and StayAwake, its pmset helper asks for a one-time admin password on setup (open-lid monitoring needs no password). It supports Apple Silicon only, has no AC-only keep-awake toggle or lid-close chime yet, and currently has no public user reviews.
Paying $9.99 (14-day or 5-lid-closed-run free trial, whichever comes first; 14-day no-questions-asked refund) only makes sense if you want a notarized build that runs on macOS 13+ (Ventura through Tahoe), phone approvals without setting up your own bot, opt-in quota auto-continue, and local battery/thermal/token recaps in one menu bar app.
You can check Lidnight or audit your past overnight sessions first with lid-check.
