Barista: caffeinate Claude Code

May 7, 2026

Note 8/9/2026: Claude Code caffeinates already, but with a 5 minute timeout.

As a new Mac user, it seems like a rite of passage to write a caffeinate wrapper of some sort. I had been using caffeinate for a while to keep my laptop awake during long-running agentic tasks, but I didn’t like how its lifetime was bound to the process itself, and could drain my battery indefinitely. Using Claude Code hooks, we are able to receive events like the start and end of a turn, allowing us to start and stop caffeinate as needed.

There is a bit more machinery for handling Claude Code subprocesses: a watchdog process is spawned in cases where a turn has ended but an asynchronous task is still running. Claude Code often uses this pattern with monitors to standby for long-running operations like code compilation, or to periodically check for updates.

Barista is available on GitHub, and can be installed via:

/plugin marketplace add wlenig/barista
/plugin install barista@barista