Short answer: run it on a server, not your laptop, and start it inside tmux so it survives SSH disconnects. For fire-and-forget tasks, use headless mode: claude -p "your task".
Why does Claude Code stop when the laptop sleeps?
Claude Code is a process on your machine. When the laptop sleeps, every process on it pauses. If you were running it over SSH on a server, the dropped connection kills the shell, and the agent with it.
Option 1: tmux on a server
tmux keeps a terminal session alive on the server whether or not you're connected:
tmux new -s agent # start a named session
claude # work as usual
# Ctrl-b then d: detach. Close the laptop. Go home.
tmux attach -t agent # reattach from any computer
tmux ls # list sessions
Run one session per agent and you can switch between them from anywhere, including your phone over SSH.
Option 2: headless jobs with claude -p
claude -p runs a single prompt without the interactive interface and exits when done, which fits scripts and scheduled jobs. Anthropic's docs show it for unattended runs together with --dangerously-skip-permissions, and say that must happen in a container or VM, as a non-root user. Read Is --dangerously-skip-permissions safe? first.
nohup claude -p "run the tests and fix what fails" > run.log 2>&1 &
tail -f run.log
Option 3: a VM that sleeps with its memory
Options 1 and 2 need a server that stays on, so you pay for every idle hour. A Yurt VM sleeps when the agent is idle, with RAM saved to disk, and wakes in about 0.04 seconds. The tmux session, the agent and its dev server are all still there:
yurt ssh me
root@me:~# tmux attach -t agent # exactly where you left it
How a VM sleeps in 3 seconds and wakes in 0.04.
How much does an always-on server cost?
A 4 vCPU / 8 GB machine left on all month costs from about $22 to over $240, depending on the provider. If the agent only works a few hours a day, most of that pays for idle time. Full price comparison and calculator.
Questions
Does Claude Code keep running if my laptop goes to sleep?
No. If it runs on your laptop, it pauses with everything else. Run it on a server inside tmux so it keeps going.
How do I reattach to Claude Code after disconnecting?
If you started it inside tmux, SSH back in and run tmux attach -t followed by the session name.
Can Claude Code run without an interactive terminal?
Yes. claude -p runs one prompt headlessly and exits, which suits scripts, cron and CI.
Can I check on my agent from my phone?
Yes. Any SSH app can connect to the server and attach to the tmux session.
Sources
- Claude Code permission modes, read 2026-11-29
- Claude Code authentication, read 2026-11-29
Give your agent its own computer. Full root, its own IPv6, and it sleeps with its memory when idle. Plans from $20/month, paid back as VM time.
curl -fsSL https://getyurt.dev/install | shKeep reading
Setup
How do you run Claude Code in the cloud?
Run Claude Code on a cloud VM instead of your laptop: what machine you need, the install command, logging in without a browser, and keeping it running after you disconnect.
Costs
How much does a cloud VM for an AI agent cost?
2026 prices for running AI coding agents on cloud VMs: per-hour rates for Boat, E2B, Daytona, exe.dev and Yurt, plan fees, what $20, $100 and $500 buy, and a cost calculator.
Engineering
How a VM sleeps in 3 seconds and wakes in 0.04
Firecracker snapshots let a Yurt VM go to sleep with its RAM saved to disk and wake in about 40 milliseconds with every process still running. Here is exactly how, including the mistakes.