/nosleep keeps the Mac awake with the lid closed (pmset disablesleep) until the session ends

Small Claude Code mods.
/plugin marketplace add PhilRoli/claude-mods
For TrainTracker. Shortly before your tracked train arrives (default: 10 minutes), every session is told to stop starting new work, leave the code in a consistent state and report what's done and what remains, so you can switch locations or turn off wifi without cutting a session off mid-task.
/plugin install train-pause@claude-mods
Requires TrainTracker (≥ 1.3.0), which writes the arrival time to ~/.traintracker/arrival.json ({"arrival": <epoch seconds, delay included>}) while a train is tracked. Idle sessions pick up the instruction on their next prompt; the status line shows a countdown. Change the window with WRAP_UP_MINUTES in plugins/train-pause/hooks/register.ts.
Same idea for usage limits: once the 5-hour or weekly window is ≥ 95% used, the session is told to wrap up. A window that resets within 5 minutes is ignored. Needs a subscription (the engine reports no limits otherwise).
/plugin install session-limit-pause@claude-mods
Tune with WRAP_UP_PERCENT and IGNORE_IF_RESET_WITHIN_MIN in plugins/session-limit-pause/hooks/register.ts.
/nosleep keeps the Mac awake with the lid closed (pmset -a disablesleep 1) and restores sleep when the session ends. /nosleep on|off sets it explicitly; the status line shows lid-closed awake while active.
/plugin install nosleep@claude-mods
macOS only. One-time setup so sudo doesn't prompt:
echo "$USER ALL=(root) NOPASSWD: /usr/bin/pmset -a disablesleep 1, /usr/bin/pmset -a disablesleep 0" | sudo tee /etc/sudoers.d/nosleep >/dev/null && sudo chmod 0440 /etc/sudoers.d/nosleep && sudo visudo -cf /etc/sudoers.d/nosleep
A hard-killed session leaves sleep disabled until the next session starts (or sudo pmset -a disablesleep 0).
For ClaudePulse. After your first prompt, Haiku gives the session a short title (/rename) and a color is picked from the session id (/color), so the menu bar app can show both.
/plugin install session-label@claude-modshooks/register.ts 42 lines1import type { Register } from 'claude-code'
2
3const SLEEP = ['sudo', '-n', '/usr/bin/pmset', '-a', 'disablesleep']
4
5async function setDisabled($: any, isDisabled: boolean) {
6 const { exitCode, stderr } = await $.process.run([...SLEEP, isDisabled ? '1' : '0'])
7 if (exitCode !== 0) return stderr.trim() || `pmset exited ${exitCode}`
8 isDisabled ? await $.store.set('active', true) : await $.store.delete('active')
9 $.ui.status(isDisabled ? 'lid-closed awake' : undefined)
10 return undefined
11}
12
13export const register: Register = on => {
14 on('session.start', async ($, e, next) => {
15 await $.command.register({
16 name: 'nosleep',
17 description: 'Keep the Mac awake with the lid closed until this session ends',
18 argumentHint: '[on|off]',
19 })
20 // a crashed session can leave disablesleep on; undo it
21 if (await $.store.get('active')) await setDisabled($, false)
22 return next(e)
23 })
24
25 on('command.run', { command: 'nosleep' }, async ($, e) => {
26 const isOn = Boolean(await $.store.get('active'))
27 const want = e.args.trim() === 'on' ? true : e.args.trim() === 'off' ? false : !isOn
28 const error = await setDisabled($, want)
29 if (error) {
30 return {
31 text: `nosleep failed: ${error}\nAllow it once: echo "$USER ALL=(root) NOPASSWD: /usr/bin/pmset -a disablesleep 1, /usr/bin/pmset -a disablesleep 0" | sudo tee /etc/sudoers.d/nosleep >/dev/null && sudo chmod 0440 /etc/sudoers.d/nosleep && sudo visudo -cf /etc/sudoers.d/nosleep`,
32 }
33 }
34 return { text: want ? 'Lid-closed sleep disabled until this session ends (or /nosleep off).' : 'Sleep restored.' }
35 })
36
37 on('session.end', async ($, e, next) => {
38 if (await $.store.get('active')) await setDisabled($, false)
39 return next(e)
40 })
41}
42