Does Claude keep running if you lock your laptop?

By Matyas Rathonyi. Updated November 15, 2026. Guides

Yes. A locked screen or a dark display leaves Claude Code running, free and with no app. Sleep stops it, and closing the lid puts the Mac to sleep.

Buy once$9.99 Download free trial

Only needed if the lid has to close.

  1. 10:00:05
  2. 10:00:10
  3. 10:00:15
  4. 10:00:20
  5. 10:00:25
  6. 10:00:30

Local Claude Code session: keeps running

Pick a state. A test file gets a line every five seconds. Locked or dark, the lines keep coming. Asleep, they stop. Lid closed, they stop too, unless Clamshell is armed.

Only locking? You are done

Lock with Control-Command-Q or the Touch ID button, leave the lid open and walk away. Permission prompts still wait for you. Once the display turns off the Mac may idle-sleep: Claude Code runs caffeinate while it is busy, and on power you can turn on Prevent automatic sleeping on power adapter when the display is off. Details in what Claude Code's keep-awake covers.

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

Prove it in two minutes

Run this in Terminal, lock the Mac for three minutes, then unlock and run cat ~/lock-test.txt.

for i in {1..120}; do date '+%H:%M:%S' >> ~/lock-test.txt; sleep 5; done

Even five-second steps mean it ran. Repeat with Apple menu, Sleep, or a closed lid and you get a gap of minutes. Clean up with rm ~/lock-test.txt.

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.

Lid closed: keep the agent working

  • Close the lid, the work goes on. Hold Option as you close it or press both Option keys to arm the next close, or right-click the menu bar icon to stay armed until you turn it off.
  • Screen dark, Mac on the network. No sudo or admin rights, no monitor needed.
  • Safe on battery. It disarms at 20% battery or if the Mac gets too hot.
  • Back to normal after. Open the lid to a locked Mac; the next close sleeps as usual.

Locking is all most people need. If the lid has to close, the full walkthrough, with a phone setup and a test that proves the session kept running, is in does Claude Code keep running when you close your laptop.

Close the lid. Claude keeps going.

Free for 7 days, then $9.99 once. Apple Silicon, macOS 14 or later.

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. To keep a local session running with the lid shut, the Mac has to stay awake after the lid closes; the Claude Code lid-closed guide has the steps and a two-minute test.

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, sleep and sleep settings; the macOS caffeinate and pmset manual pages; Anthropic's Claude Code docs. Clamshell is an independent app, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.