v0.3.0: MCP server, diagnostics & session history
NonSleep app icon

Send the prompt. Shut the lid.Walk away.

You shouldn't have to babysit an open laptop just so Claude, Cursor, or Codex can finish a 30-minute turn. NonSleep keeps your Mac working with the lid closed — and puts it to sleep the second your agent finishes.

Universal binary for M1–M4 Apple Silicon & Intel · Free & Open Source

$git clone https://github.com/Tran-Duc-Duy/nonsleep.git && cd nonsleep && scripts/install.sh
NonSleep
NonSleep: Active
84%
17:45

Stays awake with lid closed

Lid closed · Battery 84% · Clamshell

Active Leases

Claude Code · my-app

pid 48291 · Holding until 18:15

Display Lock:Locked (Touch ID)
Thermal State:38°C (Nominal)
Battery Cut-out:<20% triggers sleep
claude-code — 80x24
~$claude --task "Refactor auth & migrate DB"

[NonSleep] Clamshell closed! pmset disablesleep 1 active.

[NonSleep] Displays powered off. Session locked.

[12/20] Writing unit tests for token expiry...

[Test: OK] 18 tests passing in background

Step 19/20 compiling with lid shut...

Status: Clamshell Task ActiveNonSleep Engine v0.3.0
100% Offline (Zero Network)
Native Swift (2.5 MB)
No Root Daemon
Locks Screen on Close
The Real Developer Pain

Sound Familiar?

We built NonSleep because we were tired of losing hours of coding progress.

Without NonSleep (The 11 PM Nightmare)
  • 1You give Claude Code or Cursor a 30-minute refactoring prompt before going to bed.
  • 2You shut the lid and head to sleep. macOS immediately puts the laptop to sleep.
  • 3Your agent freezes after step 2. The other 18 steps never run.
  • 4You wake up at 7 AM to find zero progress, wasted time, and broken deadlines.
With NonSleep (The Seamless Morning)
  • ✓You submit the prompt and shut the lid immediately.
  • ✓NonSleep keeps the task cawing with the screen locked tight.
  • ✓At step 20, Claude finishes. NonSleep detects the Stop event and puts the Mac to sleep safely.
  • ✓You wake up to a cool laptop, full battery, and completed, tested code.
Engineered for AI

Why Traditional Tools Fail You

Apple designed caffeinate to stop your display from dimming while you stare at it. NonSleep is designed for when you close the lid and walk away.

The Core Fix

True Clamshell Without a Monitor

Apple kills closed-lid tasks. NonSleep doesn't let it.

Standard tools only block idle sleep. The moment you close the lid without an external monitor, macOS forces sleep. NonSleep controls the only system switch that survives a shut lid: pmset disablesleep 1.

No dummy HDMI plugs. No bulky monitors. Just close your laptop.
Zero Babysitting

Agent-Aware: Sleep When Done

Never guess when a turn finishes.

Connects directly to Claude Code, Cursor, Codex, and omp hooks. While your agent thinks or executes commands, your Mac stays awake. The millisecond it finishes, NonSleep releases the flag so your Mac sleeps.

No more running for 3 hours when the agent was done in 10 minutes.
Hardware Protection

Won't Bake in Your Backpack

Automatic thermal & battery cut-outs.

Opening your backpack to find a scalding hot MacBook with 1% battery is a nightmare. NonSleep continuously watches temperature and battery sensors. If it gets hot or battery drops below 20%, it halts immediately.

Safety first: your Mac always sleeps before battery drains to zero.
Privacy Guarantee

Shut Lid = Instant Screen Lock

Keeps running, but locks down your screen.

Your code keeps compiling, but your session is safe. The moment the clamshell closes, NonSleep turns off the display, prompting macOS to lock the session immediately with Touch ID or password.

If someone opens your laptop at a coffee shop, it's locked tight.
No Stuck Flags

Crash-Proof Leases & Reaper

Never leaves your Mac permanently awake.

Ever run pmset manually and forgotten to turn it off? Your battery died overnight. NonSleep ties every request to a process lease. If your agent crashes or gets kill -9, our background reaper cleans it in 60s.

No forgotten background flags. Normal sleep is always guaranteed.
Lifestyle Feature

Bedtime Podcast & YouTube Timer

Fall asleep to audio with the lid closed.

Want to fall asleep listening to a YouTube video or podcast? Click Custom in the menu bar, type 45m, and shut the lid. Audio plays through speakers or AirPods; your Mac sleeps at 45 minutes.

Works with any duration: 30m, 45m, 2h, 1h30m.
Interactive Preview

Designed for Terminal & Automation

One engine shared between the Menu Bar app and the CLI. Predictable, scriptable, and transparent.

nonsleep — zsh
~$nonsleep status
Stays awake with the lid closed
lid closed · battery power · battery 84% · thermal nominal
leases:
Claude Code · my-app (pid 48291, until 19:42)
Auto: agents working (pid 5085)
agents: claude · pid 48291
Agent Ecosystem

Native Hooks for Every Major Agent

Whether you code with Claude Code, Cursor, Codex, or omp, NonSleep attaches to the turn lifecycle seamlessly.

Ready-Made Prompt for Your AI Agent1-Click Prompt

Copy and paste this directly into Claude Code, Cursor, or Codex. Your agent will install and verify everything autonomously.

Please install and configure NonSleep on my Mac so that my coding agent turns can continue running with the lid closed. Follow the official steps from https://github.com/Tran-Duc-Duy/nonsleep: 1. Clone and install: git clone https://github.com/Tran-Duc-Duy/nonsleep.git && cd nonsleep && scripts/install.sh 2. Connect lifecycle hooks for all agents: nonsleep integrate all 3. Run 'nonsleep status' and report the current status to me.

Claude Code

Anthropic CLI

Official Hook

Holds lease during UserPromptSubmit and PostToolUse; releases on Stop or Notification.

Monitored Events

UserPromptSubmitPostToolUseStopSessionEnd
nonsleep integrate claude

Cursor

AI IDE

Official Hook

Listens to observe-only events (beforeSubmitPrompt, postToolUse, stop, sessionEnd).

Monitored Events

beforeSubmitPromptpostToolUseafterShellExecutionstop
nonsleep integrate cursor

OpenAI Codex

OpenAI CLI

Official Hook

Captures prompt start, tool usage, and stop lifecycle to manage MacBook sleep seamlessly.

Monitored Events

UserPromptSubmitPreToolUsePostToolUseStopSubagentStop
nonsleep integrate codex

omp (oh-my-pi)

Agent Harness

Power Assertion

NonSleep automatically reads omp's 'omp agent session' power assertion via IOKit.

Monitored Events

Auto-detected turn in flight across all providers
Built in — no setup needed

Antigravity

Google Agent

Official Hook

Supports CLI, App, and IDE. Observes PreInvocation, PostToolUse, and fullyIdle Stop state.

Monitored Events

PreInvocationPostToolUseStop
nonsleep integrate antigravity
Direct Comparison

How NonSleep Compares

An objective architectural look across all keep-awake solutions for macOS.

CapabilityNonSleep (Ours)AmphetamineCaffeinateAgent CaffeineAmped
Close lid without external monitor
NonSleep uses pmset disablesleep 1, allowing true standalone clamshell mode.
Needs monitor/power
Auto-sleep when AI agent finishes
NonSleep hooks into Claude, Cursor, Codex, and omp; auto-sleeps on turn completion.
Custom timer (e.g. 45m for YouTube)
GUI allows typing custom duration like 45m or 2h with automatic sleep when done.
CLI only
Auto-lock screen on lid close
Displays are turned off on clamshell close, enforcing macOS password/TouchID lock.
Thermal & Low Battery Cut-outs
Protects against battery drain to 0% and backpack heat build-up.
Auto (<20% or Hot)Battery % onlyBattery only
Zero Background Root Daemon
NonSleep uses a tightly scoped sudoers rule for pmset only. No root daemon.
100% Offline (Zero Telemetry)
NonSleep contains 0 network code, verified with lsof -i (completely empty).
Closed-source
Open Source & Verifiable (SLSA)
Every release is cryptographically signed and verified via GitHub Artifact Attestations.
MIT + SLSA ProvenanceProprietaryApple Built-inProprietaryGPL-3.0
Memory Footprint
Pure Swift AppKit/SwiftUI native compilation. Zero Electron overhead.
~25 MB RAM (3.9 MB CLI)~40 MB< 5 MB~70 MB~30 MB
Pure Swift

Real Measurements on Apple Silicon

No Electron bloat. Starts in 30ms, takes ~25 MB RAM, and uses 0.0% CPU when idle.

App Bundle SizeUniversal Mach-O
2.5 MB

Full macOS menu bar app + bundled CLI binary + Retina icons.

vs100x smaller than typical Electron apps (150–350 MB)
CLI Binary SizeStandalone Executable
452 KB

Pure native Swift executable compiled with zero external dependencies.

vsZero runtime dependencies, no Node/Python interpreter required
Idle CPU UsageEvent-Driven
0.0% – 0.1%

Registers Darwin kernel clamshell callbacks; zero CPU wakeups or busy loops.

vsDoesn't drain battery while running in the background
CLI Execution Time30 Milliseconds
0.03s

Subcommands (status, reap, on, off) execute in ~30ms and immediately exit.

vs0.00s user CPU time, instant terminal responsiveness
Resident Memory (RAM)Native AppKit / SwiftUI
3.9 MB / ~25 MB

3.9 MB peak memory for CLI; ~25 MB resident private memory for menu bar app.

vsFraction of memory compared to Electron or Chromium apps (300–800 MB)
On-Disk StorageZero Database Bloat
< 10 KB

Tiny config (~300 B) + ephemeral leases (~150 B) auto-purged on task exit.

vs0 SQLite database, 0 log files, 0 persistent junk

Interactive Sleep Timer Simulator

For YouTube, podcasts, audiobooks, or long compilation tasks.

Native Feature in v0.2.0
Presets:
Simulated System StateLid Closed & Playing Audio
Lease: Manual until +45m (45 min)
Flag: pmset -a disablesleep 1 (managed)
Display: Turned off (session locked)
Mac sleeps automatically at +45mAuto-cutoff if battery < 20%
Audit-Ready

100% Offline. We Don't Want Your Code.

Zero network code, zero third-party dependencies, and zero telemetry. Audited by security engineers.

100% Offline (Air-Gapped)

Zero network imports (URLSession, Network, sockets). Zero telemetry, tracking, or crash analytics. Verify yourself via `lsof -p $(pgrep NonSleepBar) -i` (returns empty).

Zero Third-Party Dependencies

Links exclusively against the Swift standard library and Apple system frameworks (AppKit, SwiftUI, IOKit). Eliminates supply-chain poisoning risks completely.

TOCTOU-Proof Sudoers Setup

Draft rules are staged directly into /etc/sudoers.d/ as 0440 root:wheel before visudo -c verification, preventing local processes from swapping files mid-check.

Cryptographic SLSA Build Provenance

All release binaries are compiled on public GitHub Actions with pinned commit SHAs and signed with GitHub Artifact Attestations (SLSA Level 3).

Verify Release Provenance Locally:
gh attestation verify NonSleep-0.3.0-macOS.zip --owner Tran-Duc-Duy
Clear Answers

Frequently Asked Questions

Everything you need to know about safety, permissions, and everyday workflows.

Standard tools like caffeinate rely on IOPMAssertion, which macOS ignores when the lid closes without an external display connected. NonSleep controls the system flag `pmset -a disablesleep 1`, which is the only switch macOS respects when the lid is shut. NonSleep binds this flag to time-limited, process-monitored leases so the machine always returns to normal sleep when work finishes.