nosleep4mac

Installs and maintains a per-user macOS LaunchAgent running caffeinate -s to prevent system sleep on AC power.

7|5|Updated Jul 22, 2025
One-click install
npx skills add https://github.com/nebius/nebius-ps-services --skill nosleep4mac-nebius
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nosleep4mac
Source: https://github.com/nebius/nebius-ps-services/tree/main/skills/nosleep4mac
Command: npx skills add https://github.com/nebius/nebius-ps-services --skill nosleep4mac-nebius

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Keeping a Mac awake during long-running tasks on AC power normally requires manual pmset tweaks or ad-hoc caffeinate sessions that do not survive restarts. This Skill converges a single persistent per-user LaunchAgent that holds a PreventSystemSleep assertion only while the Mac is connected to AC power, without touching display sleep, battery behavior, or system power settings. ## Core Features & Use Cases - Idempotent convergence: One no-argument helper creates missing state, repairs stopped or drifted state, and leaves a healthy service byte-for-byte unchanged (no plist rewrite, no PID change). - Safe failure handling: Atomic plist replacement, kernel-held file locking against concurrent runs, and automatic rollback that restores the prior file and loaded state if verification fails. - Strict guardrails: No sudo, no pmset writes, no LaunchDaemons, no pkill; rejects symlinks, root execution, non-macOS systems, and unsafe file permissions. - Use Case: A developer running an overnight model training job on a plugged-in MacBook invokes the skill once; the LaunchAgent keeps the system awake on AC across restarts while still allowing normal sleep on battery. ## Quick Start Ask the agent to run $nosleep4mac so your logged-in Mac stays awake whenever it is connected to AC power.

Frequently Asked Questions about nosleep4mac

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep my Mac awake on AC power automatically?▼

Run the nosleep4mac helper once with no arguments. It installs a per-user LaunchAgent at ~/Library/LaunchAgents that runs /usr/bin/caffeinate -s with KeepAlive=true, holding a PreventSystemSleep assertion whenever the Mac is on AC power.

How do I prevent macOS system sleep without changing pmset settings?▼

Use a caffeinate-based LaunchAgent instead of pmset. This skill manages a user-level agent that asserts PreventSystemSleep on AC power only, leaving pmset, display sleep, battery sleep, and Lock Screen settings completely untouched.

Does the caffeinate LaunchAgent work on battery power?▼

No, the -s assertion is only effective on AC power by macOS design. On battery the process may keep running but does not prevent system sleep; the assertion becomes effective again when AC power returns.

Do I need to rerun the setup after restarting my Mac?▼

No. macOS loads per-user LaunchAgents from ~/Library/LaunchAgents at each login, and KeepAlive=true implies launch-at-load behavior, so a new caffeinate process starts automatically after every restart and login.

What are the limitations of using caffeinate to prevent sleep?▼

The assertion does not wake an already-sleeping Mac, does not survive logout, and does not guarantee closed-lid operation. macOS may still sleep during low-power or thermal emergencies, since power assertions are treated as suggestions.

Why does the helper refuse to run as root or with sudo?▼

The skill manages a per-user GUI-domain LaunchAgent, which must belong to the logged-in user. Running as root would target the wrong launchd domain and violate the safety contract, so the helper exits with an error instead.