Does Claude Code keep running when you close your laptop?

By Matyas Rathonyi. Updated November 15, 2026. Guides · 日本語版

No. If you close your laptop, Claude Code stops: the lid sleeps the Mac and the local session pauses mid-task, in Terminal and in the Claude desktop app alike. Locking the screen with the lid open does not stop it. Clamshell keeps the closed MacBook awake while armed, so the session, Remote Control and every terminal job keep running. No sudo, no monitor, nothing to undo.

Buy once$9.99 Download free trial

Free for 7 days. Apple Silicon, macOS 14+. Or brew install --cask clamshell. On your phone? Send the Mac download link to yourself.

Clamshell
  1. migrate auth to the new session API, then fix the failing tests
  2. Read src/auth/session.ts
  3. Edit src/auth/session.ts +48 -31
  4. 23:41 lid closed
  5. Bash npm test 9 failed
  6. Edit src/auth/refresh.ts +12 -4
  7. Bash npm test 212 passed
  8. Done at 00:26. Ready for review.
  9. 07:12 lid opened
Finished 45 min after the lid closed
Same task, same night. Armed, the session finishes while you sleep. Not armed, it waits for you to open the lid in the morning.

If I close my laptop, will Claude still run?

It depends on where the work runs, not on which app you typed into. Anything that runs on your Mac stops when the lid closes, because a closed MacBook goes to sleep. Anything that runs on Anthropic's servers keeps going.

What you are usingLid closedWhy
Claude Code in Terminal or your editorPausesThe session, its tools and its tests run on your Mac
Remote Control from your phonePausesThe phone only steers; the work still runs on your Mac
Claude desktop app, local Code sessionPausesRuns on your Mac with direct access to your files
Dispatch and local scheduled tasksPausesNeed an awake Mac with the desktop app open
Cowork task in the cloudKeeps goingRuns on Anthropic's servers; local folders, browser and computer use wait for the Mac
Claude Code on the web, cloud sessionsKeeps goingRuns on Anthropic's infrastructure, not on your laptop

So for the case most people mean, a claude session on a MacBook: no, closing the lid stops it, unless something keeps the Mac awake after the lid closes. Locking the screen is different. A locked Mac with the lid open stays awake, so Claude keeps running when you lock your laptop. Apple's closed-display mode also keeps a closed Mac awake, but only with power, an external display, keyboard and mouse attached.

Hold Option and close the lid

The screen goes dark, the Mac stays awake and the agent keeps working. Open the lid and normal sleep is back. Pressing both Option keys arms the next close the same way. Right-click the menu bar icon to arm without the key; that stays on until you turn it off.

Steer it from your phone

Remote Control runs the session on your Mac, not in the cloud, so it only answers while the Mac is awake. Start /remote-control with the lid open, arm Clamshell, close the lid and keep going from your phone. Every option is in Remote Control with the lid closed.

Set up a lid-closed phone session

  1. Connect with the lid open In a Claude Code session, enter /remote-control and open its link or QR code on your phone. Send a small request and check that the Mac answers.
  2. Approve what you can now Permission prompts still need you. Answer the ones you can see coming while the screen is in front of you.
  3. Arm, check, close Arm Clamshell, open its menu and confirm it shows armed, then close the lid on a ventilated desk, ideally on power.
  4. Disarm when it is done Open the lid, let the task finish, disarm from the menu and confirm it is inactive before the Mac goes in a bag.

If the phone session stops, work out which case you are in before you change anything:

Why local work pauses when the lid closes

A Mac has two ways into sleep. Idle sleep is a timer that fires when nobody touches the Mac, and apps are allowed to hold it off. Lid-close sleep starts the moment the lid shuts, and a busy agent, build or download does not stop it.

Once the Mac sleeps, Claude Code, Codex, child processes, builds, downloads and SSH sessions all stop making progress, and the Mac drops off the network.

Claude Code picks up again on wake: Anthropic's agent view docs say background sessions resume, and Remote Control reconnects. The hours asleep are still lost, a reply cut off by sleep has to be asked for again, and an expired prompt cache means resending the whole context, which can cost usage.

What keeps Claude Code running with the lid closed

MethodLid closed, no monitorNeedsWhen you are done
sudo pmset -a disablesleep 1Keeps runningAdmin passwordStays on until you undo it, on battery too
External display or dummy plugNeeds the hardwareDisplay or plug, power, keyboard and mouseUnplug
caffeinate, Claude's own keep-awakeStops: idle sleep onlyNothingEnds with the command or session

What doesn't work, and why

For every method side by side, compare Clamshell, Amphetamine, pmset and caffeinate.

open "clamshell://arm"
trap 'open "clamshell://disarm"' EXIT

claude -p "run the test suite and fix the failures"

Arm it from the terminal

Wrap a long run in clamshell://arm and clamshell://disarm, or use the Arm, Disarm, Toggle and Status actions in Shortcuts. Armed this way, Clamshell stays on until you disarm. Check the menu shows armed before you close the lid.

open only delivers the request, so a clean exit does not prove Clamshell armed, and an EXIT trap does not run after a forced kill. To arm and disarm around every session automatically, use Claude Code hooks.

Prove it in two minutes

Ask the agent to run for i in {1..12}; do date; sleep 10; done, arm Clamshell and close the lid. Open it after two minutes: timestamps ten seconds apart with no gap mean the session never paused.

From your phone, ask for the output and one fresh timestamp before you open the lid. Some clients buffer terminal output, so a quiet phone screen alone is not a failure, and a connected badge alone is not a pass. If there is a long gap, open the lid and check Clamshell's state, the terminal and any pending permission request. Fix it with the lid open, then run the check again before you trust a long job to it.

Claude Code, Codex, Cursor, builds and SSH

The lid does not care which process is doing the work. Keep the Mac awake and the whole working environment keeps going:

Claude Code and Codex

Tool calls, edits and test runs continue instead of waiting for the lid. See keeping Codex running with the lid closed.

Cursor and other desktop agents

Their local terminals and background tasks stay alive. See Cursor agents with the lid closed.

Builds, tests, downloads

They keep the CPU and network they had with the lid open. See long Xcode and cargo builds.

SSH and screen sharing

The Mac stays on the network, so you can reach it from another machine or your phone. See SSH into a closed MacBook.

Keeping the Mac awake does not approve a permission prompt or fix a network outage. The optional Agent Status and Agent Notifications modules show what your Claude Code and Codex agents are doing and tell you when one needs you.

Using the Claude desktop app, Dispatch or Cowork?

The same rule applies. Claude Code sessions in the Claude desktop app run on your Mac, so they pause when the lid sleeps it. Dispatch works on your desktop computer too: Anthropic says the computer needs to be awake with the app open while Claude works. Local scheduled tasks only fire while the Mac is awake.

Cowork is the exception. Since October 6, 2026, new Cowork tasks on Pro and Max plans run in Anthropic's cloud and keep going with the lid shut. The parts that reach into your Mac, such as local folders, your browser or computer use, still wait for it to wake.

Arm Clamshell before you close the lid and desktop sessions, Dispatch and local scheduled tasks keep running. Computer use needs one more step: turn on the Agent Screen module, so agents can use the screen while the built-in display stays black. More in will Claude keep running if you close your laptop and Claude Dispatch and Cowork with the lid closed.

Safe to leave overnight, on battery too

  1. Thermal protection Always on. At serious or critical heat Clamshell disarms and the Mac sleeps normally.
  2. Low-battery cutoff On by default. At 20% on battery the Mac sleeps before the charge runs flat.
  3. Nothing to undo No sudo or admin rights. Disarm and normal lid sleep is back.

With the lid closed, Clamshell turns the built-in display off. Otherwise the Mac draws what it would with the lid open. Plugging in or unplugging mid-run does not end the session, and the cutoff never fires while plugged in. Keep the Mac on a hard surface with air around it, never in a bag. More in running AI agents overnight and running lid-closed on battery.

Compatibility

Clamshell for Mac runs on Apple Silicon MacBooks with macOS 14 or later. It is notarized by Apple and also on Setapp. Holding Option while you close the lid needs a lid angle sensor, which the 14-inch and 16-inch MacBook Pro (2021 and later) and some newer MacBook Air models have; the M1 MacBook Air and the 13-inch MacBook Pro don't. On a MacBook without one, press both Option keys, use the menu bar, or arm from a script or Shortcuts. An external display can stay connected: armed, Clamshell keeps the closed Mac awake with or without one.

Close the lid. The agent keeps going.

Try every feature free for 7 days, then $9.99 once for your Mac. Works with Claude Code, Codex, Cursor, builds and SSH.

Frequently asked questions

If I close my laptop, will Claude still run?

Only the part that runs in Anthropic's cloud. Closing a MacBook lid sleeps the Mac, so Claude Code in Terminal, local desktop app sessions, Remote Control, Dispatch and local scheduled tasks stop until it wakes. Cloud Cowork tasks and Claude Code cloud sessions keep going. To keep local work running, the Mac has to stay awake after the lid closes, for example with Clamshell for Mac armed.

Does Claude Code keep running when I close my MacBook lid?

Not by default. Closing the lid puts the Mac to sleep and local Claude Code work stops making progress until it wakes. It keeps running only with Apple's closed-display setup (power, an external display, keyboard and mouse), sudo pmset -a disablesleep 1, or a lid-closed app such as Clamshell for Mac.

Can I close my laptop while Claude is running?

You can, but the session stops as soon as the Mac sleeps and picks up again only when you open the lid. To have the work done while the lid is shut, arm Clamshell, check that it shows armed, then close the lid. Locking the screen with the lid open keeps Claude running without any app.

Will Claude Cowork keep running if I close my computer?

The cloud part does. As of October 2026, new Cowork tasks on Pro and Max plans run on Anthropic's servers and keep going when the computer sleeps. Anything a task needs from your Mac, such as local folders, your browser or computer use, waits until the Mac is awake with the Claude desktop app open.

Does Claude Code Remote Control keep working with the lid closed?

Remote Control lets your phone steer a session that runs on your Mac, so the Mac must stay awake. With the lid closed, it keeps working only if lid-close sleep is prevented, for example by arming Clamshell before you close the lid.

Why doesn't caffeinate or Keep computer awake work with the lid closed?

Both prevent idle sleep, the timer that sleeps a Mac nobody is touching. Closing the lid is a separate sleep trigger that they do not cover. Anthropic's own docs say that closing the laptop lid still puts the Mac to sleep with Keep computer awake on, and Claude Code's built-in keep-awake has the same limit.

Can I keep Claude Code running with the lid closed without sudo?

Yes. Clamshell for Mac is a menu bar app that needs no sudo, admin rights, kernel extension, or privileged helper. Arm it from the menu bar or with Option-close, confirm the armed state, then close the lid.

Does Claude Code resume after the Mac wakes up?

Mostly. Anthropic's agent view docs say background sessions are preserved when the Mac sleeps and their processes resume on wake, and Remote Control reconnects once the Mac is back online. The hours asleep are still lost, a reply cut off by sleep has to be asked for again, and a session whose prompt cache expired sends its context again, which can cost usage.

Does Clamshell detect Claude Code automatically?

Not by default. The core has no agent auto-detection; the optional Agent Status, Agent Notifications and Finish Work, Then Sleep modules show what Claude Code and Codex agents are doing, notify you, and let them finish before the Mac sleeps. Scripts can arm with clamshell://arm and disarm with clamshell://disarm, or use the Shortcuts actions.

Is it safe to leave a MacBook running Claude Code overnight with the lid closed?

Keep it on a ventilated desk, preferably on power. Clamshell's thermal safety is always on and disarms toward normal lid sleep at serious or critical thermal pressure, and a low-battery cutoff, on by default, lets the Mac sleep at 20% before the battery runs flat.

Does this work for Codex, Cursor, and other agents?

Yes. Keeping the Mac awake keeps every local process running, including Codex, Cursor, builds, test suites, and SSH sessions. It does not approve agent permission requests or fix network outages.

Which Macs does Clamshell work on?

Apple Silicon MacBooks on macOS 14 or later. Holding Option while you close the lid needs a MacBook with a lid angle sensor. On any supported MacBook you can also arm by pressing both Option keys, from the menu bar, with the clamshell://arm URL or with Shortcuts. An external display can stay connected.

Related guides

Clamshell is an independent app, not affiliated with or endorsed by Anthropic or OpenAI. Claude Code and Codex are trademarks of their respective owners.