Keeps your Mac awake while your agents are working — close the lid and the job keeps running. Once they are idle, normal sleep comes back.
Works with Claude Code and Codex.
How it works
Claude Code / Codex hooks stamp a "last activity" time on every prompt and tool call. A root daemon checks it every 30s:
- active in the last 10 min →
pmset disablesleep 1(stay awake, lid open or closed) - idle →
pmset disablesleep 0(sleep normally)
A timestamp drives everything — no state machine.
Menu bar
An icon shows the live state so you can check before closing the lid:
- ⚡️ Awake — safe to close the lid, the job keeps running
- 🌙 Will sleep — closing the lid now sleeps the Mac
Click it to pause/resume keep-awake or quit.
Install
git clone https://github.com/gergomiklos/nosleepagent.git
cd nosleepagent
./install.shWires up the hooks for both Claude Code (~/.claude/settings.json) and Codex
(~/.codex/hooks.json), backing up each first, installs the daemon, and adds a
/nosleep command. Needs sudo (flipping disablesleep is root-only). Works on
any Mac.
Afterward: restart open Claude Code sessions; in Codex, run /hooks and trust
the new hooks.
Use
Nothing — it just runs. To turn it off: ./ctl.sh off (on / status), or
/nosleep off inside Claude Code.
Uninstall
Removes the daemon and re-enables normal sleep.
License
MIT — see LICENSE.























