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.
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
| State | How you get there | Local Claude Code session | What 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 |
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:
- Permission prompts still wait for you. Locking does not approve anything. If Claude asks to run a command while you are away, it waits. With Remote Control connected you can answer from your phone, and the docs describe a
/configtoggle, Push when actions required, that notifies you about permission prompts and questions. - Tasks that drive the screen are a separate question. I have not verified how computer use or GUI tests behave behind the lock screen, so test those yourself before relying on them.
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:
- An external display setup. Apple says a Mac laptop with a closed lid needs to be connected to power and using an external keyboard and mouse to drive an external display.
sudo pmset -a disablesleep 1. It works, needs admin rights, and stays on system-wide until you undo it. See what it changes and its risks.- A lid-closed app. Clamshell for Mac keeps an Apple Silicon MacBook awake with the lid closed while armed, with no sudo and no external display.
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.
- 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 - Lock the Mac. Press Control-Command-Q. Leave the lid open and wait three or four minutes.
- 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. - 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.
- 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.
- Clean up. Run
rm ~/lock-test.txt.
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 trialApple 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
- Arm Clamshell from Claude Code hooks
- What Claude Code's built-in keep-awake covers, and what it misses
- Keep Claude Code running with the lid closed
- How to keep a MacBook awake with the lid closed
- Claude Code Remote Control keeps disconnecting? Check sleep first
- Claude Code cloud sessions vs running locally on your Mac
- Why caffeinate does not work with the lid closed
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.