Keep a MacBook awake with the lid closed: guides and comparisons

Answers for running AI agents and long jobs on a MacBook with the lid closed: why it sleeps, what each agent needs, how to steer it from your phone, and how the keep-awake apps compare. Every post answers its question first, then gives the steps, the commands and the sources.

Keep Mac Awake, which we make, keeps a MacBook with Apple silicon awake with the lid closed for a session you or your agent start, on AC power or on battery (20% floor by default), with a separate watchdog that restores normal sleep if a service stops or hangs. The guides below say what each setting and command does, where it stops, and when to start a session.

Start here

Keep an AI agent running with the lid closed

Per tool: what stops Claude Code, Codex, Cursor and the other agents when a MacBook sleeps, and the setup that keeps each one working. The overview is run AI agents overnight on a MacBook.

Control agents from your phone or another computer

Remote Control, SSH, Screen Sharing and Tailscale on a closed MacBook: what keeps the connection and what drops it. The hub is control AI coding agents from your phone.

The closed lid, explained

What macOS does when the lid closes, the settings that change it, and what heat, battery and security mean for a closed MacBook. Start with keep a MacBook from sleeping when the lid is closed.

When a Mac sleeps too soon, or will not sleep

Idle sleep, the display, and the reasons a Mac stays awake or wakes up. To read your own Mac's sleep settings and wake reasons, use the free tools.

Terminal commands: caffeinate and pmset

One command per page: what it does with the lid closed, on AC power and on battery, and where it stops. How the commands and Keep Mac Awake differ is in keep a Mac awake without an app.

Close the lid while something runs

Downloads, backups, uploads, renders, servers and music: what keeps going on a closed MacBook and what stops.

Compare keep-awake apps

Keep Mac Awake next to the other apps that say they work with the lid closed, each maker's claims dated and linked, plus a note on each app people ask about by name: which keep-awake app to use for AI agents.

More guides

Free tools