Keep your Mac awake only while AI agents are working.
Adrafinil is a macOS menu bar app that prevents the system from sleeping — including clamshell (lid-closed) sleep — exclusively while an AI coding agent has an active session. When no agent is working, sleep behavior is untouched: close the lid and the Mac sleeps normally.
It's the opposite of always-on wake utilities like caffeinate or Amphetamine. Adrafinil only intervenes when an agent (Claude Code, Codex, Cursor, …) is mid-task, and gets out of the way the moment that work finishes.
Features:
Agent-aware, not always-on. Sleep is blocked only while =1 agent session holds an assertion. Zero sessions ? normal sleep, including lid-close.
Hook integration for 9 agents. One-click installer wires Adrafinil into the hook systems of Claude Code, Codex, Cursor, Gemini CLI, Aider, Hermes, OpenCode, Cline, and Pi.
Sub-50ms CLI. adrafinil acquire / release are called from agent hooks and round-trip to the daemon in under 50ms, so they never stall an agent's workflow.
Reference-counted assertions. Overlapping sessions stack cleanly; sleep unblocks only when the last one releases.
Thermal cutout. If skin/CPU temperature crosses threshold while the lid is closed, all assertions are force-released so a bag-bound Mac can't cook itself.
Idle release. Assertions whose owning process has died or gone CPU-idle for N minutes are dropped automatically.
Process sniffing (optional). The daemon can auto-acquire when it sees a known agent binary running, even without hooks installed.
Lid-close audio + lid-open summary. A chime confirms an assertion is held when you close the lid (the screen is off, so no notification); reopening shows what ran while you were away, peak temperature, and whether the thermal cutout fired.
Clean uninstall. Removes every hook entry it added across all agent configs.