Anti-Sleep (macOS caffeinate)
SkillDev toolsAnti-sleep is a skill for AI agents that keeps a Mac awake during long builds, downloads, or supervised automation runs. It uses the built-in macOS caffeinate command, so nothing needs to be installed. The agent chooses the right flags, ties the awake state to a timer or a running process, verifies it, and stops it when done.
Use Anti-Sleep (macOS caffeinate) in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Anti-Sleep (macOS caffeinate) and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Anti-Sleep (macOS caffeinate) skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; ahel provides instructions and does not run this skill.
No other account needed.
Have a Mac running macOS, since caffeinate is built in and no installation is needed.
What your AI can do with it
- Prevent system sleep with the -i flag while allowing the screen to dim
- Keep the display on with -d, or combine -d -i for full awake state
- Set a fixed awake duration in seconds with -t (e.g. 7200 for two hours)
- Tie the awake state to a process with -w <PID> or wrap a build command directly
- Verify that caffeinate is running with pgrep and check sleep assertions with pmset
- Stop caffeinate early with pkill or Ctrl+C
Getting started
- Have a Mac running macOS, since caffeinate is built in and no installation is needed.
- Have your agent run the standard command caffeinate -d -i -t <seconds>, replacing seconds with the desired duration.
- Optionally tie the awake state to a process instead of a timer, for example by wrapping a build command with caffeinate.
- Run it in a visible terminal pane or as a background task rather than blocking the agent's own foreground shell.
- Use pgrep to confirm caffeinate is running, and pkill to stop it before the timer expires.
What this skill tells your AI
The instructions your AI receives, as published by sickn33/agentic-awesome-skills in skills/anti-sleep/SKILL.md and read by ahel’s review.
When to Use
- Use when the user wants the Mac to stay awake during a long supervised task.
- Use when a build, download, or automation run should not be interrupted by sleep.
Keep the Mac awake using the built-in caffeinate command. No install needed.
Quick start — the standard command
caffeinate -d -i -t 7200 # full power: screen stays on + no idle sleep, for 2 hours
Duration is -t <seconds>: 2h = 7200, 7h = 25200, overnight (9h) = 32400.
Aggressiveness levels
| Flags | Effect |
|---|---|
-i | prevents idle system sleep only (screen may still dim/lock) |
-d | prevents display sleep (screen stays on) |
-d -i | default choice — screen on + system awake |
-d -i -s | adds -s: prevents sleep even on AC power semantics; -s only works when plugged in |
-u -t 1 | simulates user activity — wakes the display right now |
Default to -d -i -t <seconds> unless the user says otherwise.
Tie to a process instead of a timer
caffeinate -d -i -w <PID> # stays awake until that process exits (great for builds)
caffeinate -i npm run build # wraps a command; exits when the command finishes
Run it in a visible terminal (cmux pane)
Prefer running it in the user's own terminal pane so it's visible and easy to Ctrl+C. In cmux (read the cmux skill first if interacting with panes):
cmux send --surface surface:<N> "caffeinate -d -i -t 25200\n"
Otherwise run it as a background Bash task. Never block your own foreground shell with it.
Verify and monitor
pgrep -fl caffeinate # is it running? shows exact flags
ps -o etime= -p <PID> # how long it's been running
pmset -g assertions | grep -i deny # confirm sleep assertions are active
Gotcha: caffeinate prints nothing and holds the prompt — it looks "stuck" or like Enter wasn't pressed. It isn't stuck. Verify with pgrep, not by looking at the terminal.
Expiry: with -t it exits silently when time runs out — no notification. If the user asks "is it still on?" after hours, check pgrep first; it may simply have expired.
Keyboard backlight
caffeinate cannot keep the keyboard backlight on — it has its own inactivity timer with no CLI/API on Apple Silicon (researched 2026-07). Fix is manual, one-time: System Settings > Keyboard > "Turn keyboard backlight off after inactivity" > Never.
Stop early
pkill -f "caffeinate -d -i" # or Ctrl+C in the pane running it
After starting: confirm to the user the PID, the flags, and the wall-clock time it will expire.
Limitations
- Adapted from
davidondrej/skills; verify local paths, tools, credentials, and agent features before acting. - For commands, remote access, scheduling, browser automation, or file-changing workflows, get explicit user approval and confirm the target environment first.
Signals
- GitHub stars
- 47k
- Forks
- 7k
- Last commit
- Sep 2026
Others that do the same job
Questions
- How do I keep the Mac awake for a specific duration?
- Use caffeinate -d -i -t <seconds>. For example, 7200 is two hours, 25200 is seven hours, and 32400 is an overnight nine-hour run. It exits silently when the time runs out.
- Why does the terminal look stuck when caffeinate runs?
- caffeinate prints nothing and holds the prompt, so it looks like Enter was not pressed. It is not stuck. Verify it is running with pgrep -fl caffeinate, not by looking at the terminal.
Advanced
- Item type
- skill
- Key
anti-sleep-sickn33- Source
- github.com/sickn33/agentic-awesome-skills
github.com/sickn33/agentic-awesome-skills