Why Claude Code stops when your laptop sleeps
Short answer: Claude Code runs on your computer, not somewhere else. When your laptop sleeps, everything on it pauses, including a build that was halfway done. Nothing is lost. Nothing moves either, until you open the lid again.
People are often surprised by this, because a lot of AI tools live on a website. You close the tab, you open it later, and your work is still there waiting. Claude Code is a different kind of tool. It runs on your machine, reads your files and runs real commands. That is exactly why it is good. It is also why it shares the fate of your laptop.
What actually happens when the lid closes
Your laptop goes into sleep to save battery. It freezes everything that is running and stops giving it any processing time. From the program's point of view, time stops. A long task that was three minutes from finishing will still be three minutes from finishing tomorrow morning.
If you have ever started something at 11pm, closed the laptop, and found the exact same half finished screen in the morning, that is this.
Does keeping the laptop open fix it?
It works, but it is a bad deal. You need the lid open, the power plugged in, and the sleep settings turned off. Then you need to leave it like that all night, warm and awake, and hope nothing restarts it. Plenty of people do this. Very few of them enjoy it.
There is also a quieter cost. Because the work only happens while you are watching, you end up planning around your laptop instead of around your day.
What actually fixes it
Move the work off your laptop and onto a computer that never sleeps. A small server in a data centre costs a few dollars a month and stays awake by default. Claude Code runs on it, keeps going when you close your laptop, and you talk to it from your phone.
Two things make this less simple than it sounds:
- Claude Code needs a real terminal to run in. If you start it in the background the obvious way, it will crash on its own.
- Servers reboot. If nothing is set up to start your session again afterwards, you wake up to a machine that is on but doing nothing.
Both are solvable. We wrote up exactly what doing it yourself involves, honestly, including the parts that catch people out.
The short version
Your laptop sleeping is not a bug in Claude Code. It is just where the tool lives. Move it somewhere that stays awake and the problem disappears. Either set that up yourself, or get a machine that already works that way.