Skills

Anti Sleep

Keep a Mac awake for a set duration or while a process runs.

Install

npx skills add davidondrej/skills --skill anti-sleep -g -a claude-code -y
Repository
davidondrej/skills4.2k
Category
Engineering
Updated
3d ago
License
MIT
Context cost
Lightabout 649 tokens
Runs scripts
Yes, review before use

What it does

Keep a Mac awake for a set duration or while a process runs. Use only when the user explicitly invokes /anti-sleep.

Anti-Sleep (macOS caffeinate)

Use the bundled launcher from this skill directory. It creates a one-shot user LaunchAgent using only built-in macOS tools.

Required workflow

Never launch caffeinate with raw &, nohup, disown, or launchctl submit. Temporary execution shells can kill their descendants, and launchctl submit can restart a timed job.

Resolve scripts/anti-sleep.sh relative to this SKILL.md; never assume the user's current directory. Run:

  1. Inspect current state:
scripts/anti-sleep.sh status
  1. If status reports an active session and the user requested a new duration, automatically stop the old session. Never ask for confirmation.
scripts/anti-sleep.sh stop
  1. Start the new timer for the requested duration:
scripts/anti-sleep.sh start 10800    # 3 hours

For a specific process, use start-pid. Apply the same automatic replacement rule if another session is active.

scripts/anti-sleep.sh start-pid <PID>
  1. In a separate tool/shell call after the start command has returned, verify:
scripts/anti-sleep.sh verify

Only report success when verification returns STATUS=running and ASSERTIONS=active. Confirm the PID, flags, and wall-clock expiry. If verification fails, run stop and do not claim the Mac is protected.

Assertion flags

The default is -d -i: keep the display on and prevent idle system sleep. Pass explicit flags after the duration or PID when needed:

FlagsEffect
-iPrevent idle system sleep; display may dim
-dPrevent display sleep
-d -i -sAlso prevent system sleep while on AC power

None of these stop sleep when the lid closes. For agent runs that must survive a closed lid, see Keep Claude Code running when your laptop is closed.

Example:

scripts/anti-sleep.sh start 10800 -i

Status and stop

Read the whole SKILL.md on GitHub

More in Engineering