For Claude Code
How do I keep my Mac awake while Claude Code works?
Short answer
Claude Code's CLI holds off idle sleep while it works, using macOS's caffeinate. In our test the VS Code extension held no sleep lock, and nothing in Claude Code stops the sleep that closing the lid forces. Night Crew watches Claude Code in the terminal and VS Code with no setup, and keeps the Mac awake only while it works.
What Claude Code already does about sleep
Claude Code runs in a few places on a Mac, and each one handles sleep differently.
| Where you run it | What it does about sleep | Lid closed |
|---|---|---|
| Terminal (CLI) | Runs caffeinate -i -t 300 while it works, replaced every 4 min |
Mac sleeps |
| VS Code extension | Nothing we could find (our test, v2.1.311) | Mac sleeps |
| Claude desktop app | A Keep computer awake setting you turn on | Mac sleeps |
| Remote Control (from phone) | Runs on your Mac, so your Mac has to stay awake | Mac sleeps |
In the terminal. On macOS the CLI starts Apple’s caffeinate -i -t 300. The -i flag stops idle sleep, the kind
that happens when nobody touches the Mac. People who traced the code report that it replaces that process every 240
seconds, and kills the old one before starting the new one, so for a moment nothing holds the Mac awake
(#81832, seen on versions 2.1.207 to 2.1.280). There is no
setting to turn it off. An open issue with 38 thumbs-up asks for one
(#21432).
In VS Code. We checked while a Claude Code session in the VS Code extension (v2.1.311) was working, on macOS
26.4.1 on Apple silicon. pgrep -lf caffeinate found nothing, and pmset -g assertions listed no sleep lock from
Claude or caffeinate. So the Mac’s normal idle timer could put it to sleep mid-task. This is one version on one Mac,
and it may change.
In the desktop app. Anthropic’s docs say to turn on Keep computer awake in Settings › Desktop app or Settings › This computer › System, and add: “Closing the laptop lid still puts it to sleep.”
With Remote Control. The session runs on your Mac while you drive it from your phone or browser. Anthropic’s docs:
“your computer has to stay on and the claude process has to keep running.”
Where that falls short
- The lid. Apple calls closing the lid “forced sleep”, and says “it is not possible to prevent forced sleep, only
delay it” (QA1340).
caffeinate -ionly covers idle sleep. More in Can I close my laptop while an agent runs? - VS Code. If you work in the extension, nothing from Claude Code held the Mac awake in our test.
- The gap. The 4-minute replacement leaves a moment with no lock. The issue above reports the Mac idle-sleeping mid-task once the display is off.
- Battery. The CLI’s caffeinate keeps holding on battery. One user reported an unattended session ran a laptop down to 0% until it shut off (#21432).
- The opposite problem. Other users report the Mac staying awake when Claude Code is idle (#64522).
We counted this on our own development Mac for one week (20 to 27 October 2026). Sleep cut off 15 to 23 Claude Code runs, about two or three a day. Seven to twelve of them happened on the charger, where the free macOS setting “Prevent automatic sleeping on power adapter when the display is off” fixes it. Most of the rest were idle sleep on battery. When it happens mid-reply, Claude Code says so: “Your computer went to sleep mid-response”.
What Night Crew adds
- No setup for Claude Code. Night Crew reads Claude Code’s own session status, so it works in the terminal and in the VS Code extension from the first launch.
- Awake only while it works. One steady sleep lock while any session is working, with no 4-minute gap. When the last one finishes, Night Crew waits 60 seconds (you can set up to 10 minutes), then lets the Mac sleep. A build Claude leaves running keeps the Mac up for at most 2 hours.
- Your screen still locks. By default only the Mac stays awake. The display still sleeps on its normal timer, so your screen locks as usual.
- Lid mode. Close the lid and Claude keeps working. It’s on the charger only by default. You approve a small helper once in System Settings. It can only turn sleep off and back on, and it turns sleep back on if Night Crew quits.
- Battery and heat guards. Night Crew lets go at 15% battery, or at the higher floor of 30% in lid mode on battery. If another app, such as Claude Code’s caffeinate, still holds the Mac awake at that point, you get a one-minute notice you can cancel, then the Mac sleeps. The heat guard is on by default and always on in lid mode. By default Night Crew stops holding after 24 hours.
- A sleep journal. When the Mac slept or stayed awake, and why, kept for 14 days.
How to set it up
- Download Night Crew and open it.
- That’s it for Claude Code. Start a session in the terminal or in VS Code and Night Crew picks it up.
- Optional: for exact start and stop times, open Settings › Agents and set up the Claude Code hook. Night Crew
backs up
~/.claude/settings.jsonfirst, adds its entries next to any hooks you already have, and keeps the three newest backups. Removing it is one click and a confirm.
Everything works free for 14 days. See how it works, or how it compares with caffeinate, Amphetamine and other apps on /compare. Using Codex too? See Night Crew for Codex.
Questions
Does Night Crew work with the Claude Code extension in VS Code?
Yes, with no setup. Night Crew reads Claude Code's own session status, so it sees sessions in the VS Code extension and in the terminal. That matters most in VS Code, where our test found no sleep lock from Claude Code at all. An optional hook adds exact start and stop times.
Will Night Crew stop Claude Code's own caffeinate?
No, it leaves Claude Code alone. It holds its own lock next to it. If your battery reaches 15% while another app, such as Claude Code's caffeinate, still keeps the Mac awake, Night Crew shows a one-minute notice you can cancel, then puts the Mac to sleep.
Does Claude Code keep running when I close the lid?
Not on its own. Closing the lid forces sleep, and Apple says apps can't prevent that. Claude Code's caffeinate only stops idle sleep. Night Crew's lid mode keeps a closed Mac running while Claude works, on the charger by default, and turns sleep back on when it's done.
What happens after the trial?
After the 14-day trial, Night Crew needs a licence to keep working: $9, paid once, for up to 2 Macs. Without one, your Mac sleeps on its normal schedule, as it did before.
Sources
- Claude Code docs: error reference (sleep errors)
- Claude Code docs: desktop scheduled tasks ("Keep computer awake")
- Claude Code docs: Remote Control
- claude-code #81832: caffeinate respawn leaves a gap
- claude-code #21432: request to turn off caffeinate
- claude-code #64522: caffeinate keeps respawning
- Apple QA1340: idle sleep vs forced sleep
- caffeinate man page (ss64)
Checked 5 November 2026.