Does Claude Code keep your Mac awake with the lid closed?

By Matyas Rathonyi. Updated October 5, 2026. Guides

Not with the lid closed. Claude Code's built-in keep-awake runs caffeinate -i, which holds off idle sleep while the lid is open. Closing the lid is a separate sleep path. To keep a local session running lid-closed without a monitor, arm Clamshell for Mac before you close it.

Lid openBuilt-in caffeinate mostly covers it
Lid closedThe Mac sleeps anyway
No sudoNo monitor or admin rights
$9.99 onceAfter a 7-day free trial

Clamshell for Mac keeps the Mac awake with the lid closed while armed, so Claude Code keeps working. Free for 7 days.

Download free trial

Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or buy now, $9.99

Claude Code output keeps arriving in a terminal while a MacBook lid closes. With Clamshell armed, the Mac keeps working with the lid shut. Claude Code
Idle sleep and lid sleep are different.Claude Code's caffeinate covers a Mac left open. Closing the lid takes another path, so the session keeps going only if something like Clamshell is armed.

People search for "Claude Code caffeinate" and "Claude Code sleep mode Mac" for two opposite reasons. Some notice a caffeinate process they never started and wonder why their Mac stays up. Others close the lid on a long task and come back to find it stopped hours ago. Both come from the same built-in keep-awake, and both make sense once you split Mac sleep into its two causes.

What Claude Code does to prevent sleep

On macOS, the Claude Code CLI starts caffeinate while a session is working. Anthropic does not document the details on a docs page, but its changelog confirms the process: version 2.1.83 (March 25, 2026) fixed a caffeinate process that kept running after Claude Code exited and stopped the Mac from sleeping. The finer details come from users who read the shipped code, as of October 2026:

The Claude desktop app has a separate control. Anthropic's scheduled tasks docs say Keep computer awake in Settings, This computer, System prevents idle sleep, and add plainly: "Closing the laptop lid still puts it to sleep."

Idle sleep vs lid sleep: why closing the laptop stops Claude Code

macOS puts a MacBook to sleep for two different reasons. Idle sleep happens after a period without input. Apps can veto it with an assertion, and that is all caffeinate -i does. Lid sleep happens when you close the lid, and an idle assertion does not stop it. Apple's closed-display mode keeps a closed laptop running only with power, an external display, and an external keyboard and mouse.

Top: with the lid open and the display off, the caffeinate relay runs in four-minute segments with a short gap at each handoff. Bottom: with the lid closed and only the built-in keep-awake, the session stops at the close. Lid open, display off 4 min 4 min 4 min Lid closed, built-in only z stops at the close
Two ways a session stalls. With the lid open, the relay's handoff gaps can let an idle Mac sleep once the display is off, as issue #81832 reports. With the lid closed, the idle assertion never applied in the first place.

When the Mac sleeps, the whole claude process tree is suspended. Nothing is lost on disk, but nothing runs either: tests stop mid-way, in-flight API responses fail, and Claude Code may later report that your computer went to sleep mid-response.

When the built-in keep-awake is enough

If you leave the lid open, you do not need anything extra for most sessions. To close the handoff gap from issue #81832 for a long unattended run, use one of these free options:

None of these survive a closed lid. If the job has to keep going on a sofa, on a train, or overnight with the lid shut, you need a lid-sleep fix.

Does Claude Code keep running when the laptop is closed?

It depends on where the session runs:

Cloud session: yes

Anthropic's cloud docs say a cloud session runs on cloud infrastructure and "keeps running after you close your laptop". It clones from GitHub into a Linux VM, so it cannot use files or apps that only exist on your Mac. See cloud vs local.

Local CLI or desktop session: no

It runs on your Mac, so it stops when a closed lid puts the Mac to sleep. It picks up again when the Mac wakes, minus anything that timed out.

Remote Control from your phone: only if the Mac stays awake

Anthropic's Remote Control docs say the phone is a window into the local session, so "your computer has to stay on and the claude process has to keep running".

Local session with Clamshell armed: yes

The Mac stays awake and on the network with the lid closed and the built-in display black, so the local session and Remote Control keep working.

Without a lid-sleep fix, the closed MacBook sleeps and the phone's Remote Control link is cut. z Lid closed phone loses it With Clamshell armed, the closed MacBook keeps working and the phone stays connected. Clamshell armed still reachable
Remote Control needs a Mac that is awake. Anthropic's docs say Claude Code reconnects when a sleeping machine comes back online, but nothing runs while it sleeps.

Keep Claude Code running with the lid closed

Use an Apple Silicon MacBook on macOS 14 or later, on a ventilated surface, preferably on power. Leave Claude Code's own keep-awake alone; it does not conflict.

  1. Install Clamshell and open it once. It sits in the menu bar. No sudo, admin password, kernel extension or privileged helper is involved.
  2. Disconnect external displays. With a display connected, Clamshell pauses (yellow menu bar icon) instead of arming, and arms automatically once displays disconnect.
  3. Start the Claude Code task. If you want to follow along from your phone, start Remote Control with /remote-control first.
  4. Arm, check, then close. Arm from the menu bar menu, which covers the next close only, or hold Option while you close the lid on a MacBook Air M2 (2022) or later or a 14-inch or 16-inch MacBook Pro (2021) or later. Shortcuts and right-click arming stay active across reopenings until you disarm. Look for the armed state before the lid goes down.
Clamshell switches on and its status turns blue: armed for the next close. Armed for the next close
Arm, look, then close. A paused state is not armed. Requests from scripts arrive asynchronously, so check the menu bar before the lid goes down.

To arm from a script before a long run, open "clamshell://arm" requests arming and open "clamshell://disarm" ends it. The Claude Code lid-closed guide covers a full phone setup and a timestamp check that proves work continued.

Clamshell does not know about Claude Code. It does not detect when a task ends, answer permission prompts, or keep a flaky network alive.

Clamshell keeps your Mac awake with the lid closed. Free for 7 days, then $9.99 once for one Mac. 14-day money-back guarantee.

Download free trial

Other ways to keep Claude Code running lid-closed

Send the task to a cloud session

The best fit when the job only needs a GitHub repo and common Linux tooling. Start one with claude --cloud "task", per Anthropic's docs.

Use an external display

Apple's supported closed-display setup, with power, a display, and a keyboard and mouse. Ideal if you work at a desk with that hardware anyway.

Leave the lid open

Free and reliable with one of the idle-sleep fixes above. Fine on a desk at home.

Run sudo pmset -a disablesleep 1

Keeps a closed Mac awake, but it is a global admin switch with no timer, on battery too. See what pmset disablesleep does and how to undo it.

Frequently asked questions

Does Claude Code use caffeinate on a Mac?

Yes. Anthropic's changelog refers to the caffeinate process Claude Code starts on macOS, and GitHub reports describe it as caffeinate -i -t 300, restarted every four minutes while a session is busy. The -i flag holds off idle sleep only. It does not stop the sleep that happens when you close a MacBook lid.

Does Claude Code keep running when the laptop is closed?

A local session does not, unless something keeps the Mac awake with the lid shut, such as an external display setup, sudo pmset -a disablesleep 1, or a lid-sleep app like Clamshell for Mac. Claude Code cloud sessions do keep running, because they run on Anthropic's infrastructure instead of your Mac.

Why did my Mac sleep mid-task with Claude Code running and the lid open?

An open GitHub issue, anthropics/claude-code #81832, reports that the built-in caffeinate relay briefly drops its sleep assertion every four minutes. Once the display has been off long enough, macOS can idle-sleep in that gap. Starting Claude Code as caffeinate -i claude, or turning on Prevent automatic sleeping on power adapter when the display is off, holds the Mac awake for the whole run.

Does Claude Code Remote Control work with the MacBook lid closed?

Only while the Mac stays awake. Anthropic's docs say a Remote Control session runs on your machine, so the computer has to stay on and the claude process has to keep running. With the lid closed and nothing keeping the Mac awake, the phone loses the session until the Mac wakes.

Does Clamshell detect Claude Code or start automatically?

No. Clamshell has no Claude Code integration and does not detect running agents. You arm it from the menu bar, by holding Option while closing the lid on supported models, with Shortcuts actions, or with the clamshell://arm URL.

Related guides

Sources checked October 5, 2026: Anthropic's Claude Code changelog, cloud sessions, Remote Control and desktop scheduled tasks docs; anthropics/claude-code issues #81832 and #21432; Apple's closed-display and sleep settings guides. Clamshell behavior is described from its changelog and FAQ. Clamshell is an independent app, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.