MacBook lid closed guides.

Written and tested on Apple Silicon Macs by Matyas Rathonyi, creator of Clamshell.

Closing a MacBook lid triggers a different sleep path from ordinary idle sleep. These guides explain what macOS does, which workarounds actually affect the lid, and how to keep long-running work alive without pretending a monitor is attached. Clamshell, a Mac menu bar app, is one option: it keeps a MacBook awake with the lid closed, with no sudo and no external display.

Two closed MacBooks side by side: without help the Mac falls asleep, with Clamshell armed it keeps working with the screen dark. Asleep no help Working Clamshell armed
The lid is its own sleep trigger.Idle-sleep tools do not touch it. Each guide below covers one way around it, and what it costs.

Start here

Coding agents and long runs

Keep coding agents running with the lid closed

Claude Code, Codex, Cursor, terminal jobs, builds, downloads, and SSH sessions.

MacBook の蓋を閉じたまま Claude Code を動かし続ける方法

日本語版

Keep Codex running with the lid closed

Codex CLI, the desktop app, and Codex cloud tasks: which ones need the Mac awake.

Use Codex from your phone with the lid closed

Codex in the ChatGPT phone app, SSH and tmux: what a closed MacBook lid breaks, and how to keep Codex reachable.

Keep a Cursor agent running with the lid closed

Cursor editor agents, the Cursor CLI, and Cloud Agents: why Cursor's wake lock is not enough.

Run AI coding agents overnight on a MacBook

What stops overnight runs, a pre-flight checklist, and how to check progress in the morning.

Lid closed on battery

How each option behaves on battery, low-battery cutoffs, and heat.

Codex "Keep this Mac awake" not working with the lid closed

Why the Codex setting stops at a closed lid, and how to keep Codex running anyway.

Does Claude Code prevent sleep with the lid closed?

What Claude Code's built-in caffeinate covers, and what closing the lid still stops.

Claude Code cloud vs local on your Mac

When cloud sessions win, when your own Mac wins, and how to run both.

Claude Code Remote Control with the lid closed

What happens to your phone session when the MacBook sleeps, and every way to keep it working.

Computer use and iOS Simulator with the lid closed

Let agents use the screen with the lid shut: dummy plugs, virtual displays and Clamshell compared.

Everyday uses with the lid closed

Apps compared

How macOS sleep works