The usual advice for long Claude Code runs is “keep your Mac awake”. That's a blunt instrument: the Mac stays awake while the agent is busy, but also while it waits for your answer, and after it finished an hour ago.
A better default is awake while the agent works, normal sleep when it doesn't. Claude Code exposes hooks for exactly the moments that matter — a task starting, a tool running, the agent stopping or waiting for you — so a small plugin can hold a sleep assertion only during real work.
What we're building
- Free and open source. A Claude Code plugin you install with the plugin command, no account.
- Idle-sleep protection while Claude Code works, released when it stops or waits for input.
- No root, nothing persistent. It uses the same kind of temporary power assertion as
caffeinate, so if anything crashes, normal sleep is back. - Optional lid-closed mode with Lidwork. If Lidwork is installed, the plugin can ask it to keep the Mac awake with the lid closed for the duration of the run — with Lidwork's battery cutoff and crash recovery still in charge.
What it won't do
- It won't keep a closed MacBook awake on its own — the plugin alone covers idle sleep, like
caffeinate. - It won't send anything anywhere. No telemetry.
Today: two hooks, lid closed
You don't have to wait for the plugin. If Lidwork is installed, Claude Code can switch it on when a session starts and off when it ends. Paste this into ~/.claude/settings.json:
{
"hooks": {
"SessionStart": [{ "hooks": [{ "type": "command", "command": "open -g 'lidwork://on?hours=8'" }] }],
"SessionEnd": [{ "hooks": [{ "type": "command", "command": "open -g lidwork://off" }] }]
}
}
Start claude and the star turns yellow: your Mac stays awake, lid open or closed. End the session and it sleeps normally again. hours=8 is a cap in case a session never ends cleanly. Lidwork's battery limit and heat stop still apply. To stay awake only while Claude is answering, use UserPromptSubmit → open -g lidwork://on and Stop → open -g lidwork://off instead. More in keep Claude Code running with the lid closed.
No Lidwork, lid open? caffeinate -i claude keeps the Mac awake exactly as long as the session.
Want to know when it ships?
Send us a one-line email and we'll write back once, when it's out. No newsletter.
Tell me when it's out