Add setting to disable automatic caffeinate/sleep prevention
Status Open
Maintainer reply None cached
Activity 8 comments · opened Jan 28, 2026
Summary
Claude Code spawns caffeinate -i -t 300 repeatedly during active sessions, preventing macOS sleep — including lid-close sleep. There is no setting to disable this behavior.
User Stories
Story 1: Disable sleep prevention
As a developer using Claude Code on a laptop, I want to disable the automatic caffeinate spawning so that my Mac sleeps when I close the lid, even during an active session.
Current Behavior
- Claude Code spawns
caffeinate -i -t 300as a child process during active sessions - The process respawns after each 300s expiry, so
killall caffeinateis ineffective - The source is shipped as a minified
cli.jsbundle so users cannot patch it - Community tools (cc-caffeine, cc-caffeinated) exist to add caffeinate support for headless/remote use cases, but none provide a way to disable the built-in behavior
Acceptance Criteria
- [ ] A user-configurable setting (e.g.
disableCaffeinatein~/.claude/settings.json) disables automaticcaffeinatespawning - [ ] When disabled, no
caffeinatechild processes are spawned during sessions - [ ] When enabled (default), current behavior is preserved
Edge Cases
- [ ] Setting should be respected across session restarts
- [ ] Existing community hooks that add their own caffeinate should not conflict
Showing cached comments. Read the full discussion on GitHub ↗
6 Comments
It seems Claude Code sometimes spawns these caffeinate processes even when idle (eg. stopped at a user question or finished the task). I just had a couple of sessions on, one completely idle one went rogue and kept my laptop awake. After exiting it the others seem to work as intended: spawn caffeinate while working, letting sleep when idle (I couldn't find any documentation around this behaviour so I just assume what is intended and what not). This happened multiple times in the past week or so.
I'm too facing the same issue.
Even if the claude session isn't doing anything (all prompts replied & nothing being processed), it still keeps running
caffeinate -i -t 300frequently preventing my macbook from going to sleep.We use a corporate oauth login that auto-refreshes every 8 hours by opening a new chrome tab. If this expires at night, it launches a new tab for oauth login every 5 minutes so I wake up to like 20+ tabs in the morning.
There needs to be an option to disable this, this is buggy and should not prevent sleep when the claude session isn't doing anything.
I am also facing the same issue. My mac always keeps awake after closing the lid, and the battery drops to zero fast
User story:
As a developer using Claude Desktop on a Mac, I should be able to sleep my computer while Claude Desktop is idle and not have the battery completely drain overnight.
If Electron has the ability to allow sleep (as all apps should), then this should be considered a BUG in Claude Desktop, not an enhancement. Actually, I would argue that even if Electron had no such ability, it's still a bug to choose Electron to build it on.
Adding a concrete data point and a suggested fix direction.
Lost a working session to this. A Claude Code session was running unattended on battery. Its
caffeinate -i -t 300child heldPreventUserIdleSystemSleepthe whole time, so as the charge ran low the laptop never idle-slept — and because macOS only writes the hibernation image at the moment of sleep, it never hibernated either. It drained to 0% and hard-shut-off, losing the session. (/var/vm/sleepimagehad a stale placeholder timestamp, confirming no recent hibernation occurred.) This matches the "battery drops to zero fast" reports above.Confirmed the source via the process tree:
And
pmset -gshowedsleep 0 (sleep prevented by caffeinate, powerd), withpmset -g assertionsattributingPreventUserIdleSystemSleepto thecaffeinateprocess.Suggested fix, in priority order:
caffeinateEnabled: falsein settings.json, or an env var / CLI flag likeCLAUDE_CODE_DISABLE_CAFFEINATE=1/--no-wakelock.Environment: Claude Code CLI on macOS (Darwin 25.5.0, Apple Silicon). Repro: start a session and run
pmset -g assertions | grep caffeinate.