Does Claude Code keep running when you lock your Mac?

By Matyas Rathonyi. Updated October 11, 2026. Guides

Yes. Locking your Mac only puts a password in front of your session; the Mac stays awake and Claude Code keeps working. It costs nothing and needs no app. A display that has turned off is also fine. What stops a local session is system sleep, and closing a MacBook lid normally means sleep.

Screen lockedKeeps running
Display offKeeps running until idle sleep
System sleepStops until wake
Lid closedSleeps, unless kept awake
An open laptop with a padlock on its screen. Lines of terminal output keep appearing behind the padlock and activity dots keep pulsing under the laptop: the screen is locked and the work continues. Screen locked work continues
A lock is a password, not a pause.The lid is open and the Mac is awake, so the session behind the lock screen keeps running its tools and talking to the network.

People ask this as "does Claude Code keep running if I lock my laptop" and "will Claude stop if I close my laptop" as though they were one question. They are two. Locking and closing the lid look alike from across the room, but macOS treats them very differently, and only one of them stops your session. This page separates the states, shows what Apple's documentation says about each, and gives you a two-minute test so you do not have to take it on trust.

Four states, two outcomes

StateHow you get thereLocal Claude Code sessionWhat it costs to keep going
Screen locked Control-Command-Q, or the Touch ID button Keeps running Nothing
Display off The inactivity timer in Lock Screen settings Keeps running, until the Mac idle-sleeps Nothing; a built-in setting or caffeinate if idle sleep follows
System sleep Apple menu, Sleep, or idle sleep after the display is off Stops until the Mac wakes Do not sleep the Mac
Lid closed Closing a MacBook Stops: the lid puts the Mac to sleep An external display setup, pmset, or a lid-closed app
Four progress bars for the same task. With the screen locked and with the display off, progress continues to the end. With the Mac asleep and with the lid closed, progress stops at the moment that state begins. Locked Display off Asleep z Lid closed z state begins
The line that matters is between awake and asleep. Locking and a dark display sit on the awake side. Sleep, and a lid close that leads to sleep, sit on the other. The lock screen itself changes nothing about what runs.

Locked screen: the work continues

Locking is a security feature. Apple's keyboard shortcuts page lists Control-Command-Q as "Lock your screen", and says that on keyboards with Touch ID, pressing the Touch ID button locks the screen too. Apple's page on requiring a password describes the related setting, Require password after screen saver begins or display is turned off, as a way to keep your information secure while you are away. Nothing on either page says locking suspends anything.

Compare that with Apple's page on putting a Mac to sleep. It lists the ways to do it: choose Apple menu, Sleep, or "On a Mac laptop, close the display." Locking the screen is not on the list.

To be straight about the evidence: I did not find an Apple page that says "apps keep running while the screen is locked" in one sentence. The behaviour follows from the pages above, and it is easy to confirm, which is why the test below exists. Anthropic's documentation points the same way. Its Remote Control docs suggest a screen-lock listener so that Claude Code sends push notifications to your phone once your screen locks, which only makes sense if the session is still working at that point.

Two practical notes for a locked Mac:

Display asleep: still running, with one catch

A display that has gone dark is not a sleeping Mac. macOS keeps separate timers for the two: the pmset manual lists displaysleep as the "display sleep timer" and sleep as the "system sleep timer", and caffeinate has separate flags for them, -d for the display and -i for idle system sleep. In System Settings the display timers live under Lock Screen as Turn display off on battery when inactive and Turn display off on power adapter when inactive, per Apple's sleep settings guide.

The catch is what can happen next. Once the display is off, the Mac is allowed to idle-sleep unless something holds it awake. The same Apple guide has a setting for exactly this under Battery, Options: Prevent automatic sleeping on power adapter when the display is off. A setting to prevent it implies that, without it, the Mac may sleep once the display is off.

So "display off" keeps your session running for as long as the Mac does not slide into idle sleep. For Claude Code that depends on its own keep-awake, covered next.

What Claude Code's own sleep prevention covers

On macOS, Claude Code starts caffeinate while a session is busy. Anthropic's changelog confirms the process exists: version 2.1.83 fixed a caffeinate process that kept running after Claude Code exited. The details come from a user report, issue #81832, which is open as of October 11, 2026: the command is caffeinate -i, so it covers idle sleep only; it is restarted every four minutes with a brief gap that the report says can let the Mac sleep once the display is off; and it ends about 30 seconds after the session stops being busy.

In terms of the four states: it is irrelevant while the screen is merely locked, it mostly covers a busy session with the display off, it does not cover a session that is waiting for your answer, and it does nothing at all for a closed lid. If you want a firmer hold with the lid open, start the session as caffeinate -i claude, or use the power adapter setting above. Both are free. The full breakdown is in what Claude Code's keep-awake covers and misses.

System sleep: everything stops

Apple describes sleep as a state where the Mac is "turned on but consumes much less power." For a local session that means nothing runs: no tool calls, no tests, no network. The claude process is not killed, so when the Mac wakes the session is still there, and Anthropic's docs say a Remote Control connection "reconnects automatically when your machine comes back online." What you lose is the time, plus anything that timed out while the Mac was asleep.

A session that runs in the cloud is not affected by any of this. Anthropic's cloud docs say it "keeps running after you close your laptop", because it is not running on your Mac. See cloud vs local for when that fits.

Where a closed lid falls

On the sleep side. Apple lists closing the display as a way to put a Mac laptop to sleep, and an idle-sleep assertion such as caffeinate -i does not stop it. A closed MacBook stays awake in three cases:

If you do not need the lid closed, you do not need any of these. Lock the screen, leave the lid open, and walk away. The step-by-step for the closed-lid case is in keep Claude Code running with the lid closed, and the general options are in how to keep a MacBook awake with the lid closed.

Prove it on your own Mac

You can check all of this in a few minutes with a loop that writes the time to a file. A process that keeps running leaves evenly spaced lines. A Mac that slept leaves a hole.

  1. Start the loop. Open Terminal and run this. It writes one line every five seconds for ten minutes.
    for i in {1..120}; do date '+%H:%M:%S' >> ~/lock-test.txt; sleep 5; done
  2. Lock the Mac. Press Control-Command-Q. Leave the lid open and wait three or four minutes.
  3. Unlock and read the file. Run cat ~/lock-test.txt. If every line is five seconds after the one before, the Mac ran straight through the lock.
  4. Repeat with sleep. Start the loop again, choose Apple menu, Sleep, wait three minutes, then wake the Mac and read the file. This time there is a jump of about three minutes between two lines.
  5. Optional: repeat with the lid. Start the loop, close the lid for three minutes, open it and compare. Without an external display or a lid-sleep fix, you will see the same hole as in step 4.
  6. Clean up. Run rm ~/lock-test.txt.
Test file after locking: four timestamps five seconds apart with no gap. The Mac kept running. 10:00:05 10:00:10 10:00:15 10:00:20 after locking No gap: it ran Test file after sleep: two timestamps five seconds apart, then a jump of about three minutes before the next line. The Mac slept. 10:00:05 10:00:10 10:03:22 10:03:27 z after sleep or lid Gap: it slept
The file does not lie. Five-second steps all the way down mean the Mac never stopped. A jump of minutes between two lines is the time the Mac spent asleep.

One thing to expect: a bare shell loop holds nothing awake. If you lock the Mac on battery and wait long enough for the display to turn off, the Mac may then idle-sleep and you will see a gap that the lock did not cause. To see the difference, run the loop as caffeinate -i zsh -c '...' with the same loop inside the quotes, or keep the wait shorter than your display timer. You can also read the system's own record afterwards with pmset -g log | grep -E "Entering Sleep|Wake from" | tail; the Remote Control troubleshooting guide shows how to read it.

Where Clamshell fits, and where it does not

For a locked screen or a dark display, it does not fit at all. Those states already keep your session running, and the built-in options cover idle sleep.

Clamshell for Mac is for the last row of the table: the lid has to close and there is no external display. While armed, it keeps the Mac awake and on the network with the lid shut and the built-in display black, without sudo or admin rights, and the Mac locks when you open the lid. It pauses while an external display is connected, and thermal safety is always on: at serious or critical thermal pressure it disarms toward normal lid sleep. It does not detect Claude Code, so you arm it yourself from the menu bar before you close the lid, and you should keep a closed, awake Mac on a hard surface and out of a bag.

Only need to lock the screen? You are done, no app needed. Clamshell is for when the lid has to close: it keeps the Mac awake lid-shut while armed. Free for 7 days, then $9.99 once.

Download free trial

Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or buy now, $9.99. Reading this on your phone? Send the Mac download link to yourself.

Frequently asked questions

Does Claude Code keep running if I lock my laptop?

Yes. Locking the screen only puts a password in front of your session. The Mac stays awake, so Claude Code, its tools and its network connection keep working. It is free and needs no extra app. The session stops only if the Mac later goes to sleep.

Will Claude stop if I close my laptop?

A local session will. Apple lists closing the display as a way to put a Mac laptop to sleep, and a sleeping Mac runs nothing. The session picks up when you open the lid. A cloud session is different: Anthropic's docs say it keeps running after you close your laptop.

Does Claude Code keep running when the display turns off?

Yes, as long as the Mac does not go on to idle sleep. A dark display is not sleep. While a session is busy, Claude Code runs caffeinate to hold off idle sleep, and on power you can also turn on Prevent automatic sleeping on power adapter when the display is off.

What is the shortcut to lock a Mac without sleeping it?

Control-Command-Q locks the screen, according to Apple's keyboard shortcuts page. On keyboards with Touch ID, pressing the Touch ID button also locks it. Neither one puts the Mac to sleep.

How can I check whether my Mac kept working while it was locked?

Run a loop that appends the time to a file every five seconds, lock the Mac for a few minutes, then unlock and read the file. Evenly spaced timestamps mean the Mac kept running. A jump of minutes means it slept.

Do I need an app to keep Claude Code running while my Mac is locked?

No. Locking needs nothing. A keep-awake app only matters when the lid is closed with no external display, because that is when macOS puts the Mac to sleep regardless of what is running.

Related guides

Sources checked October 11, 2026: Apple's pages on keyboard shortcuts, requiring a password after waking, putting a Mac to sleep, sleep and wake settings and closed-lid external displays; the macOS caffeinate and pmset manual pages; Anthropic's Claude Code docs for Remote Control, cloud sessions and the changelog; and GitHub issue #81832 in anthropics/claude-code, which is a user report. Apple's setting names can change between macOS versions. Clamshell is an independent app, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.