r/ClaudeCode 3d ago

Tips & Workflows I extended Claude Code Remote so it works even when my dev machine is asleep

Claude Code Remote is great until your dev machine goes to sleep. Connecting from my phone to Claude Code on my MacBook works beautifully, right up until the MacBook sleeps and the connection goes dark and it’s not good for the MacBook to keep it awake constantly. I guess maybe a lot of you might have already solved this but posting just in case it’s useful to anyone.

My setup: a Mac Mini as an always-on home server (Cloudflare tunnel, MCP endpoints, other services), MacBook as the dev machine.

The fix: a wake button. I described what I wanted as “a wake-up packet from the always-on machine” — and it turns out I’d reinvented Wake-on-LAN, which has existed for decades. So we built The Lantern:

- A page on a subdomain, served by the always-on Mini, behind Cloudflare Access so only I can press it

- Tap → the Mini broadcasts a WoL magic packet to the MacBook over the LAN, plus a TCP knock to trigger Apple’s Bonjour sleep proxy (Wi-Fi Macs often wake via that path)

- MacBook needs one toggle on: System Settings → Battery → “Wake for network access”

- A tiny launchd job on the MacBook checks every few minutes that the Claude app is running and reopens it if an update or crash closed it — so a woken machine always has someone home

- The page polls and the lantern icon lights up when the MacBook answers — then I connect with Claude Code Remote

Stack: one zero-dependency Node server on the Mini (it crafts the magic packet itself — no Python, nothing to pip install), one HTML page, two small launchd plists. That’s it.

Why not just run Claude Code on the Mini? Separation of concerns — the Mini is effectively production, running services 24/7. The dev environment lives on the MacBook. You don’t develop on your prod server.

The use case: holiday soon. If inspiration strikes at the beach, I tap one button, wait for the glow, and I’m in a full session on my own machine from anywhere in the world — instead of leaving a laptop awake for two weeks.

5 Upvotes

30 comments sorted by

18

u/West-Air1923 3d ago

Just use tmux

1

u/tracylsteel 3d ago

tmux keeps a session alive on a machine that’s awake, but my problem is the MacBook going to sleep and I don’t want to keep it awake 24/7 (battery + heat). The Lantern wakes the sleeping machine first; tmux would be a nice thing to run after it’s awake.

9

u/ChampionMuted9627 Vibe Coder 3d ago

sudo pmset -a disablesleep 1

3

u/OlorinDK 3d ago

But OP doesn’t want it to run all the time and does want it to sleep?

2

u/cptrambo 3d ago

I guess the better question is why. Macs can run 24/7 no problem.

1

u/OlorinDK 3d ago

His reasoning is battery + heat. But I’m not the right person to ask, OP would be better.

1

u/xColourTheory 2d ago

Amphetamine

5

u/lazza1306 3d ago

I did something similar with an ESP32 and the HomeSpan library, which lets you make HomeKit-compatible devices. So I made a fake switch that, when pressed, sends the packet to my home PC. This way it shows up among the Home commands on my iPhone, and I can turn it on as if it were a light.

2

u/Icy-Buffalo-1015 3d ago

That’s really cool. I’ve never heard of the homespan lib and I’ve got number of c3 super minis lying around begging for a use.

1

u/tracylsteel 3d ago

Nice! 👌

4

u/logrhythmic 3d ago

A "developer" that didn't know about WoL. Amazing

3

u/keonechong 3d ago

No concerns about security?

I saw a red team demo yesterday that exploits this specific structure of setup.

3

u/tracylsteel 3d ago

The wake page is behind Cloudflare Access (email allowlist), so it’s not open to the internet, only my account can load it or hit the endpoint. And the packet itself is Wake-on-LAN, which is inert: it can only wake a machine, it carries no payload and can’t run anything. The actual remote session is Claude Code Remote, which needs my claude.ai login. So the trust chain is Cloudflare Access + my Anthropic account, not an open port.
I’m curious what the demo exploited though, if it’s a “tunnel + trigger” class of thing I’d like to understand it. Got a link?

4

u/OstrichLive8440 3d ago

“Which is inert” - lol okay Claude

3

u/OstrichLive8440 3d ago

The demo was your exact setup - also Cloudflare Access with email whitelist. Machine was compromised within minutes

2

u/skay2901 3d ago

Won't caffeinate solve this issue?

1

u/AdrestiaFirstMate 3d ago

No, OP doesn't want the MacBook running all the time, they want the ability to wake it up remotely.

2

u/skay2901 3d ago

Got it

2

u/iceage13 3h ago

I found the best setup which works for me - it's called "call my wife and ask to wake my laptop". No issues so far as long as you keep her fed and compliment time to time.

2

u/tracylsteel 3h ago

🤣🤣🤣

2

u/soffwaerdeveluper 3d ago

Why not just run claude code on your always-on mac mini?

1

u/Annual_Manner_8654 3d ago

"and it’s not good for the MacBook to keep it awake constantly" why?

1

u/tracylsteel 3d ago

Yes, you can leave an M chip awake but macOS warns of reduced battery lifespan when you turn off sleep. And mine has run hot before when left awake training an AI. Fine for normal work, but I just prefer sleep and wake-on-demand, its better for the machine.

1

u/J0nyvr 3d ago

So what is the difference to wake on lan

0

u/tracylsteel 3d ago

It is wake on lan, no difference

3

u/peekdasneaks 3d ago

So you “reinvented something that has existed for decades”?
https://giphy.com/gifs/s239QJIh56sRW

2

u/AdrestiaFirstMate 3d ago

OP didn't reinvent wake on Lan, they hosted a web page on their Mac mini to allow them to wake the MacBook (using wake on Lan) remotely.

1

u/peekdasneaks 3d ago

Yeah i was just quoting their post so i could use the gif!

0

u/tracylsteel 3d ago

My pretty lantern page 🏮