Does Claude prevent sleep? Keep computer awake vs closed lid

By Matyas Rathonyi. Updated October 17, 2026. Guides

Only while the lid is open. Claude Code in Terminal runs caffeinate -i while it works, and the Claude desktop app's Keep computer awake setting prevents idle sleep. Both cover idle sleep only; Anthropic's docs add that closing the laptop lid still puts the Mac to sleep. 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

An animated MacBook with a coding agent deploying a website from its terminal. The Option key is held and the lid closes: the display goes black, but the Mac stays awake, so a dimmed copy of the terminal keeps working above the closed laptop while its front edge fills with light. When the deploy is done, a pointer shows how to lift the lid. Opening it wakes the Mac to its lock screen, which unlocks to the finished run: deployed, with the live address. The lid can then be opened and closed freely.

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

Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or install with Homebrew: brew install --cask clamshell.

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.

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.

Cloud or local: which sessions survive a closed lid?

It depends on where the session runs. The full walkthrough, with a test you can run, is in does Claude Code keep running when you close your laptop.

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.

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. External displays can stay connected. Clamshell arms with or without one.
  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 with a lid angle sensor (the 14-inch and 16-inch MacBook Pro from 2021 on, and some newer MacBook Air models). Right-click and Shortcuts arming stay active across reopenings until you disarm. Look for the armed state before the lid goes down.
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's core does not know about Claude Code; its optional Agent Status, Agent Notifications and Finish Work, Then Sleep modules show what Claude Code and Codex agents are doing, notify you, and can let them finish before the Mac sleeps. It does not 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.

Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or install with Homebrew: brew install --cask clamshell. Also on Setapp.

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?

Not by default. Clamshell's core does not detect running agents; its optional Agent Status, Agent Notifications and Finish Work, Then Sleep modules show what Claude Code and Codex agents are doing, notify you, and can let them finish before the Mac sleeps. 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.