SleepSwitch: macOS menu bar app to keep AI agents running
SleepSwitch is a macOS menu bar utility that prevents your MacBook from sleeping when the lid is closed, solving interrupted AI coding agent tasks.

Stock photo for illustration only, not from the actual event
- SleepSwitch prevents your Mac from sleeping even when the lid is closed.
- It bypasses standard caffeinate limitations regarding lid-closed sleep.
- Includes a Battery Guard feature to prevent overheating inside bags.
- Created by Dmitry Ganin to handle long-running AI coding agent tasks.
Running background tasks like Claude Code refactoring a service or Codex running a test suite often requires walking away and closing the laptop lid. However, closing the lid causes macOS to sleep instantly, killing active sessions, wiping out the AI's context, and ruining uncommitted work.
Standard commands like caffeinate -dimsu fail the moment the lid closes because lid-closed sleep is governed by a separate system setting requiring root access via sudo pmset -a disablesleep 1. This workflow forces developers to remember flags, type passwords, and risk letting the laptop run hot inside a closed bag.

Stock photo for illustration only, not from the actual event
As developers increasingly rely on autonomous AI agents for heavy coding tasks, standard operating system power management policies often get in the way. Tools like SleepSwitch bridge the gap between aggressive OS power-saving features and the need for uninterrupted developer workflows.
"This started as a "keep the build running" utility. Then AI coding agents happened, and it turned out they're the worst possible workload for macOS power management."
Dmitry Ganin
Developer Dmitry Ganin created SleepSwitch to handle this workflow with a single menu bar click. Left-clicking toggles the mode, while right-clicking opens settings. Closing the lid with the mode active emits a muted porcelain tone, confirming the machine remains awake.
To prevent overheating inside a backpack, SleepSwitch features a Battery Guard that automatically disables the mode once the battery drops to a configurable threshold (defaulting to 20%) or when the power adapter is unplugged. The project is available on GitHub for users looking to manage long runs safely.
Source: Dev.to
Found something wrong in this article? Report an issue with this article
Comments
Leave a Comment