Show HN: Adrafinil – keep a lid-closed Mac awake only while agents work Adrafinil, a macOS menu bar app, keeps a Mac awake only while AI coding agents have active sessions, preventing sleep during clamshell mode. It uses a privileged helper for root-level sleep control and supports nine agents including Claude Code and Cursor. The app ensures normal sleep resumes when no agents are working. rx no. 006 ・ a·draf·i·nil /əˈdræfɪnɪl/ ・ a eugeroic for machines ♡ awake ・ an agent is working | sleeping ・ no agents, normal sleep | 服用注意 ・ for machines that keep watch after you've gone to sleep.It's 3 a.m. You're asleep. The agent isn't — it's still mid-thought in a session you started hours ago, and you've closed the lid over it like an eyelid that won't quite shut. caffeinate and Amphetamine are stimulants: they keep the machine wiredforever, whether or not anyone's home. Adrafinil is the eugeroic. It doesnothinguntil an agent acquires it, keeps your Mac awake through a closed lid only for as long as that work lives, and clears the moment the last session releases. It only ever wakes for the work — then you both sleep. ♡ 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. ⚠️ Privileged sleep control.Overriding clamshell sleep requires root. Adrafinil isolates that in a tiny, audited helper that only exposes setSleepBlocked Bool — all policy lives in an unprivileged daemon. It holds a standard IOPMAssertion for idle sleep and uses pmset disablesleep for clamshell lid-closed sleep, after verifying on-device that the cleaner private IOPMrootDomain paths don't keep a displayless lid-closed Mac awake. See Docs/ARCHITECTURE.md §2. 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. macOS Tahoe 26.4. That's what I build and test on; it likely runs on earlier 26.x, but I haven't tested it there. Xcode 26+ to build, with Swift 6 strict concurrency enabled.- Admin rights for the standard install the privileged helper installs via SMAppService . A non-admin install path drops the CLI in ~/.local/bin instead of /usr/local/bin . Download Adrafinil — a signed, notarized disk image. Open it, drag Adrafinil to Applications, and launch. The first launch asks for admin rights once to register the privileged helper. Requires macOS 26.4 or later. Prefer to build it yourself? See Building building . git clone https://github.com/kageroumado/adrafinil.git cd adrafinil open Adrafinil.xcodeproj In Xcode, select the Adrafinil scheme and Run. You'll need to set a development team for code signing — the daemon LaunchAgent and helper LaunchDaemon are embedded into the app bundle and registered with the system when the app launches. No Team ID is baked into the source; the XPC caller check reads your own signing team at runtime, so a rebuild under any Developer ID authorizes its own components without code changes. For a headless compile check without local signing identities: xcodebuild -project Adrafinil.xcodeproj -scheme Adrafinil -configuration Debug \ -destination 'generic/platform=macOS' \ CODE SIGNING ALLOWED=NO CODE SIGNING REQUIRED=NO CODE SIGN IDENTITY='' build The shared logic builds and tests standalone as a Swift package: cd AdrafinilShared swift test Agents don't talk to Adrafinil directly. Each agent's hook system calls the bundled CLI: adrafinil acquire