Codeman logocodeman Download for MacMac app GitHub →

Will Claude keep running if I lock or close my laptop?

Updated 2026-10-10

On this pageWhat actually stops a sessionThe Claude desktop app's "Keep computer awake" settingA caveat for Windows laptopsOption 1: keep the laptop awakeOption 2: run it on an always-on machine, inside tmuxHow Codeman handles it

Locking your screen does not stop Claude: a locked computer keeps running its programs, so Claude Code in a terminal and the Claude desktop app keep working as long as the machine stays awake. Sleep does stop it. Closing the lid, or the idle timer putting a locked machine to sleep, suspends every process until the machine wakes. To keep work going while you are away, keep the machine awake (option 1) or run Claude Code inside tmux on a machine that never sleeps and reattach from your laptop or phone (option 2).

What actually stops a session

Event What happens to claude started in a terminal on your laptop
You lock the screen Nothing stops. Processes keep running; the display may turn off, and the idle timer can later put the machine to sleep (next row).
The computer sleeps (idle timer, or you close the lid) Every process is suspended. Nothing runs until it wakes.
You close the terminal window The process usually ends with the terminal.
An SSH connection drops A claude started directly in that SSH shell usually ends with it.
The machine reboots Everything ends, tmux included.

Claude Code's own features follow the same physics. Its agent view preserves background sessions while the machine sleeps and resumes them on wake, which means no work happens in between. Its automatic continue after a usage limit waits for you to press Enter if the computer slept for more than about 30 minutes across the reset.

The Claude desktop app's "Keep computer awake" setting

The Claude desktop app has its own switch for this, described in the app as: "Prevent your computer from idle-sleeping while Claude is open so scheduled tasks can run. Your display can still turn off. Closing the laptop lid will still put it to sleep."

According to Anthropic's Desktop scheduled tasks docs, it lives in Settings > This computer > System, and it exists because local scheduled tasks only run while the desktop app is open and the computer is awake. Three things follow from that:

The setting changes nothing for a claude you started in a terminal; for that, use option 1 or 2.

A caveat for Windows laptops

On Windows, "locked with the screen off" is the case most likely to surprise you. Many current Windows laptops use Modern Standby, a low-power state they can enter soon after the screen turns off, and a request to keep a locked Windows host awake for Remote Control is tracked in anthropics/claude-code#71875. An open report, anthropics/claude-code#96679 (September 2026), says the CLI only holds the machine awake during a turn on macOS. Until that changes, on a Windows laptop set the power plan so the machine does not sleep while plugged in, or use option 2.

Option 1: keep the laptop awake

If the laptop stays open on your desk, preventing idle sleep while Claude works is enough.

On macOS, caffeinate holds a sleep assertion for as long as the command it runs:

caffeinate -i claude      # -i: prevent idle sleep while claude runs
caffeinate -s claude      # -s: prevent system sleep, only while on AC power

On a Linux desktop with systemd:

systemd-inhibit --what=idle:sleep --why="claude is working" claude

These cover idle sleep, not a closed lid in a bag. Closing the lid is handled separately by the operating system; on a Mac, running with the lid closed needs power, an external display and an external keyboard and mouse. And the session still dies with the terminal window or the SSH connection it was started from.

Option 2: run it on an always-on machine, inside tmux

tmux keeps a program running on the machine where it started, independent of any terminal or SSH connection. Put Claude Code on a machine that stays on and run it inside tmux:

ssh you@server
tmux new -s work          # start a named tmux session
cd ~/src/myapp && claude  # run Claude Code inside it
# press Ctrl-b then d to detach; claude keeps running

Close the laptop. The session keeps working on the server. When you are back, from the laptop or a phone SSH client:

ssh you@server -t tmux attach -t work

A few practical points:

If the work is a scheduled job rather than an interactive session, Anthropic also offers cloud routines that run with your computer off.

How Codeman handles it

Codeman is built around option 2. You install it on the always-on machine, and it runs each agent CLI (Claude Code, Codex, Gemini CLI and others) in its own tmux session, streaming the terminals to a browser. Closing the browser tab, losing the network, closing the laptop and even restarting the Codeman server leave the sessions running.

curl -fsSL https://getcodeman.com/install | bash
codeman service install     # systemd user unit on Linux, LaunchAgent on macOS
loginctl enable-linger $USER   # Linux: keep the service running while you are logged out

On macOS a LaunchAgent starts at login, not at boot, so a headless Mac needs a system LaunchDaemon instead; Running As A Service covers both.

Reaching it from the laptop or phone is covered in Remote Access; Tailscale is the recommended route, and codeman tui gives an SSH-friendly dashboard of the same sessions.

What Codeman adds after a reboot: tmux is gone, but a banner offers to rebuild the sessions the reboot destroyed, and their conversations come back (the terminal scrollback does not). Past Claude conversations are also listed under Resume Conversation on the home screen.

If Codeman runs on the laptop itself, it can still keep work going with remote SSH cases: point a case at another host and the agent runs in a tmux server on that host, fronted by a local SSH pane. The laptop can sleep or change networks, the remote session continues, and Codeman reattaches when the connection comes back. See Remote SSH Sessions.

For unattended nights, combine this with auto-resume after a usage limit and push notifications; Keeping Agents Running walks through that setup.