No, not by default. Claude Code runs on your computer, so when you close the lid and the laptop goes to sleep, Claude Code pauses with it and carries on only when the computer wakes. To keep a local session working, stop the computer from sleeping (keep it plugged in and use the settings or commands below for Mac, Windows or Linux). If you want work to continue with the computer completely off, use an Anthropic cloud session instead, which runs on Anthropic's servers.
01Why closing the lid stops Claude Code
The Claude Code CLI is a program on your machine. It reads your files, runs your commands and calls the model from there. A sleeping computer runs no programs, so a task in progress simply stops where it was. Nothing is lost: when the computer wakes, the session is still open and continues.
The same is true of everything that drives a local session, including Anthropic's Remote Control. Its documentation says your computer has to stay on and the claude process has to keep running. After a sleep, Remote Control reconnects on its own when the computer is back online.
02Keep a laptop awake on Mac
On macOS, caffeinate keeps the Mac awake for as long as a command runs:
caffeinate -i claude
-i stops idle sleep while Claude Code is running. To keep working with the lid closed, a MacBook also needs to be on power with an external display connected (clamshell mode); with no display attached, closing the lid still sleeps it. If you want to walk away with the lid open, set the display to turn off in System Settings > Lock Screen and leave the Mac plugged in.
03Keep a laptop awake on Windows
In Control Panel > Power Options > Choose what closing the lid does, set "When I close the lid" to Do nothing for "Plugged in". Then set sleep to Never while plugged in, under Settings > System > Power. Microsoft PowerToys also has an Awake tool that keeps the computer awake on demand.
04Keep a laptop awake on Linux
On distributions with systemd, run Claude Code under an inhibitor so the system does not sleep while it runs:
systemd-inhibit --what=idle:sleep:handle-lid-switch claude
Your desktop environment's power settings may also have a "when the lid is closed" option.
05When you want it to run with the computer off
Use a cloud session. Anthropic runs Claude Code on its own infrastructure, so it keeps going after you close your laptop and you can check on it from any device, including the Code tab in the Claude app. Start one from claude.ai/code, from the app, or from your terminal:
claude --cloud "Fix the flaky test in auth.spec.ts"
Cloud sessions clone your code from GitHub and do not have your computer's local tools, files or MCP servers. They are available on Pro, Max, Ultra and Team plans, and for some Enterprise seats. Later you can bring the work back to your terminal with claude --teleport.
06Leaving a long task on a laptop that stays on
If the work needs your machine, the routine is: keep it awake, allow the routine commands so it does not stop at every prompt, and make sure you hear when it needs you. Claude Code still waits for you at permission prompts, questions and the end of each turn.
A notification tool closes that gap. Claude Code Notifier is an independent tool (not made by Anthropic) with a free command line tool, ccn, for Mac, Windows and Linux, and apps for iPhone and Android. It sends a push when Claude finishes, needs a permission or asks a question, and you can allow, deny, answer or send the next instruction from your phone. It does not keep a computer awake, so use it with the settings above. The full routine is in Leave Claude Code running and walk away.
07FAQ
If I close my laptop, does Claude Code lose my session?
No. The session pauses while the computer sleeps and continues when it wakes. Only quitting the terminal or stopping the claude process ends it.
Can I close the lid on a MacBook and keep Claude Code running?
Only in clamshell mode, with power and an external display connected. Otherwise keep the lid open, let the display turn off, and run caffeinate -i claude.
Does Claude Code run in the cloud?
It can. Cloud sessions run on Anthropic's infrastructure and keep going with your laptop closed. A normal claude session in your terminal runs on your computer.
Does Remote Control keep running when the laptop sleeps?
No. Remote Control connects to a session on your computer, so it pauses while the computer sleeps and reconnects when it wakes.
Use OpenAI's Codex CLI? Notifier for Codex does the same for Codex.