anti-sleep
它能做什么
防止你的 Mac 在下载或更新等长时间任务中自动进入睡眠。它会保持屏幕常亮,让系统维持唤醒状态。
适用场景
- ✓在进行耗时较长的下载或更新时。
- ✓运行耗时很长的程序时。
- ✓希望 Mac 在特定时间段内都不进入睡眠时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/anti-sleep/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“让我的 Mac 保持唤醒 3 小时。”
每周 5 个新技能,1 分钟读完。
工作原理
它使用 Mac 内置的命令 `caffeinate`。你可以指定让 Mac 保持唤醒的时长,或者让它一直保持唤醒,直到某个任务完成。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Anti-Sleep (macOS caffeinate)
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 # inspect PreventUserIdleSystemSleep / PreventUserIdleDisplaySleep # 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
kill <recorded-caffeinate-PID> # or Ctrl+C in the pane running this task
Record the PID of the process started for this task; verify its command before stopping it. Do not stop unrelated caffeinate sessions by a broad pattern.
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.
常见问题
我怎么知道它有没有在工作?
你可以检查 Mac 上是否正在运行 `caffeinate` 命令。它不会在屏幕上显示任何内容,所以可能会让人以为它没有生效,但它其实一直在工作。
怎样提前停止它?
如果是你手动启动的命令,它会给出一个编号(PID)。你可以用这个编号,在时间用完之前结束该进程。
它会让键盘背光保持亮着吗?
不会。`caffeinate` 无法控制键盘背光。如果需要,你得在 Mac 的设置中手动调整。
详情
作者的原始描述
Keep a Mac awake with caffeinate during long builds, downloads, or supervised automation runs.
热度
- GitHub 星标
- 48k
- 排名
- #3754
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。