A simple plugin that prevents your Mac from sleeping while Claude Code is working.
Uses macOS's built-in caffeinate command with a 5-minute auto-expiring timer that resets on activity.
Triggers that reset the timer:
UserPromptSubmit- When you send a promptPreToolUse/PostToolUse- Before/after each tool (Bash, Read, Write, etc.)SubagentStop- When subagents finishNotification- On Claude notifications
Cleanup hooks:
Stop- Kills caffeinate when Claude finishes respondingSessionEnd- Kills caffeinate when session ends
Failsafe: If Claude crashes or Ctrl+C doesn't trigger hooks, caffeinate auto-expires after 5 minutes of inactivity.
claude
/plugin marketplace add boostvolt/claude-code-caffeinate/plugin install caffeinate@claude-code-caffeinateOr browse and install interactively:
/pluginWhile Claude is responding, run in another terminal:
pgrep caffeinateIf it returns a process ID, caffeinate is active.
The plugin uses these flags:
-d- Prevent display sleep-i- Prevent system idle sleep-s- Prevent system sleep (when on AC power)-t 300- Auto-expire after 5 minutes (300 seconds)
- macOS (uses native
caffeinatecommand) - Claude Code
MIT