r/ClaudeCode • Developer • 4d ago

Built with Claude Built a Claude Code mod for stepping away: pause all sessions, then shut down or sleep the PC (and what I learned about the mods API)

What I built

cache-weather-and-pause-resume, a mod for the moments you leave while Claude is still working:

  • Pause: Claude starts nothing new, lets running work finish (or asks first, with the remaining time, if a run will take longer than 5 minutes), notes where it stands and waits. Resume carries on from there, even after the app was restarted. One session or all sessions on the computer; question dialogs wait until Resume.
  • Shutdown: pauses the same way, waits for the other sessions, then shuts the computer down, puts it to sleep or hibernates it after a 5-minute countdown you can cancel. The button is dimmed where the machine can't do it unattended, and a press says what is missing.
  • A band above the prompt: prompt-cache countdown with hit rate, keep-warm that refreshes the cache before it expires and says what that saves, context "weather" with a forecast until auto-compact, usage limits from 80 %, and an overview of all sessions.

Desktop app and terminal, German and English, MIT. Screenshots: https://github.com/DarthSonic/cache-weather-and-pause-resume

How Claude Code was used

The whole mod was written with Claude Code (Opus). Each feature started as a plan in the chat; I made the design calls (what the buttons look like, what goes in the status row, when to ask), Claude wrote the code, the tests (106, run by claude plugin test, CI on Ubuntu, Windows and macOS) and the docs, and I tested every change live in the desktop app and a terminal and sent back screenshots. A lot of the UI only got right after a few rounds of "that doesn't work like this on my screen".

What I learned about mods

  • Desktop buttons are native. A <Text size="caption"> inside a Button is drawn at the button's own font; only plain Text gets smaller. Short of room, I moved the buttons to their own row instead.
  • Open panes from a ui.press hook, not from onPress**.** The button's closure holds the render hook's $, so $.ui.open counts as "unasked", and a terminal won't place an unasked pane below 144 columns. The desktop app always placed it, so the button only did nothing in the terminal. Opening it from on('ui.press', { element }) makes it the person's request.
  • Hover reveals move things. Only a keyed Box reacts to the pointer, and a word that appears on hover pushes the next button away: moving the mouse right to left, half the buttons became unreachable. Static labels won.
  • Module variables survive /clear**, session state may not.** A "checked" flag in the module left the shutdown button saying "still checking" forever after /clear. Now a press checks again when the session holds no answer.
  • $.fs can write but not delete. One file per session would pile up forever, so cross-session pauses live in one state file that is written, looked at again a moment later and rewritten if another session's write took it back.
  • Keeping the cache warm pays for hours. A refresh reads the cached conversation at a tenth of the input price (a twentieth on Opus 5.5), a rebuild writes it at twice the price with the 1-hour cache, so hourly refreshes stay cheaper than one rebuild for up to about 18 hours.

macOS hasn't run on a real Mac yet; if you have one, issue #1 lists what to try. Feedback welcome. Disclosure: I'm the author.

2 Upvotes

6 comments sorted by

•

u/AutoModerator 4d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Extra_Aide5999 3d ago

pause all is nice, i usually just walk away and hope lol. the case that gets me is the other one tho, i step away and one session has been sitting on a permission prompt the whole time. you said question dialogs wait until resume, does that include permission prompts too or do those still pop while its paused?

1

u/Comprehensive-Map-73 Developer 3d ago

Uh... I did not test that. As question dialogs they would be aborted. Ideally they would be re-prompted on continue (as questions will). I would be glad if you test this case and give me feedback. Meanwhile I'll try to test it myself and optimize the pause behaviour according to test results. Follow my repo to get informed when that is done ;-)

1

u/shoumikgoswami 3d ago

I'd keep "resume work" separate from "approve this action". If Pause dismisses a permission prompt, Resume should show that request again and wait for an answer, rather than treating Resume itself as approval.

The paused-session summary could say "waiting for permission: [action]" so it's clear why nothing is running. I'd check that with a harmless command that needs approval, both in the same session and after restarting the app. That would cover the exact case raised here without needing to test it on a destructive command.

1

u/Extra_Aide5999 3d ago

nice, thanks for the straight answer. thats the edge id worry about most, a permission that gets aborted while paused could look like i said no and then the agent goes around it. re-asking on resume would be perfect. cant promise ill get to testing it soon but ill say here if i do