Barista: caffeinate Claude Code

May 7, 2026

As a new Mac user, it seems like a rite of passage to write a caffeine wrapper of some sort. I had been using caffeine 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 caffeine 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