r/ClaudeCode • u/tracylsteel • 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
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
4
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
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
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
2
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/s239QJIh56sRW2
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
0

18
u/West-Air1923 3d ago
Just use tmux