I am currently working on a mobile app and am able to develop it not knowing much about mobile or web development apart from computer science fundamentals. AI makes this possible. I also have other apps I am working on that, while I can do it myself, I have more success giving natural language commands to the AI and getting results that way. My tool of choice is Claude Code exists with a Claude Pro subscription, available on all devices including your mobile device.
But there is a problem with Remote Control for Claude Code: your repo has to live on a computer you control. You have to have Remote Control running in the background while you are away.
You don't need a static IP address fortunately, but you need remote-control to always be on. Running VS Code in a Window on my non-server desktop at home was a no-go, as it would frequently reboot without permission and shut down VS Code. I need to run VS Code as a daemon on a server which is perpetually up.
I found a way to do this by installing Remote Control on my Unraid server, which is always up. This serves Remote Control for Claude Code and provides a place to store my repos while I work on them.
The steps are:
1) Install the Claude Code plugin for Unraid
2) Run Claude Code inside the tmux server with a script.
3) Configure Claude Code Plugin to connect to Anthropic
3) Set up triggers to that the deamon starts and stop on array mount/unmount
Install The Plugin
Go to the top write of Unraid and click the icon ">_"to open the terminal.
Enter this line
|
1 |
plugin install https://raw.githubusercontent.com/brianpugh/unraid-claude-code/main/claude-code.plg |
This will install the plugin.
Setup Claude Code plugin
type claude into the terminal.
|
1 |
claude |
and follow the prompts to set up claude code.
Set up Claude Code server loop
The following code will set up the claude code server loop, launch it in tmux, and keep your server up. It also moves the script into the boot directory, so it will fire on reboot. See script in Appendix. The code has safeguards to ensure your system boots properly and in the correct order, with a delay in starting claude code until after the array starts. There is also a script to safely tear down claude code when the array stops.
|
1 |
/boot/config/scripts/claude-remote-control.sh |
To start the array
|
1 |
/boot/config/scripts/claude-remote-control.sh |
to stop the array
|
1 2 |
#!/bin/bash bash /boot/config/scripts/claude-remote-control-stop.sh |
Install the User Scripts Plugin and configure
The user scripts plugin will trigger tmux to start on array start and tear down on array stop. This is usefull if you start and stop the array short of a full reboot.
# How cool is it that we can vibe code on our phones now!
Now You have a Claude Code Remote Control Server
In this article I showed how to set up Claude Remote Control as a server on your Unraid server. Set up correctly, as long as your box is on, Claude Code will be available wherever you are in the world, on your desktop, phone, or tablet. Even if you can't send commands in the subway, if you get your commands in at the stops, it will continue to think while you are underground! This has been super helpful for me programming on the go. Happy vibe coding!
Appendix
starting the array:
|
1 |
/boot/config/scripts/claude-remote-control.sh |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
#!/bin/bash # # claude-remote-control.sh (v2) # # Starts (or cleanly restarts) a persistent Claude Code Remote Control server # on Unraid, inside tmux, with a supervisor loop that survives network drops. # # Safe to run any time. Safe to schedule at "At Startup of Array". # Running it twice does not stack duplicates -- it tears down first. # # /boot is FAT32 and cannot hold an execute bit, so invoke it as: # bash /boot/config/scripts/claude-remote-control.sh # # # ONE-TIME SETUP REQUIRED BEFORE THIS WILL WORK: # cd /mnt/user/appdata/claude-code/workspace # claude # ...accept the workspace trust dialog, then /login if not signed in, # then /config to enable the two push-notification toggles, then /exit # # Trust and login are deliberate human acknowledgments. They cannot be # scripted, and they persist once done, so this script never repeats them. # It only auto-answers the "Enable Remote Control?" first-run prompt, and # only after verifying that is the prompt actually on screen. set -u # ---------------------------------------------------------------- config ---- WORKDIR="/mnt/user/appdata/claude-code/workspace" LOGDIR="/mnt/user/appdata/claude-code" LOG="$LOGDIR/remote-control.log" SESSION="claude-rc" # tmux session name RC_NAME="unraid" # name shown in the Claude app's Code tab LOOP="/tmp/claude-rc-loop.sh" CLAUDE_BIN="" # leave empty to auto-detect via PATH # How long to wait for /mnt/user to appear, in seconds. Gives the array time # to finish mounting when this runs from an array-start hook. MOUNT_WAIT=120 # Extra flags for `claude remote-control`. Consider: # --spawn worktree give each session its own git worktree # --permission-mode acceptEdits stop blocking on edit approvals RC_FLAGS="" # ------------------------------------------------------------- environment -- export HOME=/root export PATH="/root/.local/bin:/usr/local/bin:/usr/bin:/bin:$PATH" say() { echo "[claude-rc] $*"; } die() { echo "[claude-rc] ERROR: $*" >&2; exit 1; } # ------------------------------------------------ARRAY MOUNT GUARD (v2) ---- # # Nothing below this block may touch /mnt/user until it is a real mount. # Writing to /mnt/user while the array is down lands in RAM and shadows the # real share when it mounts. waited=0 while ! mountpoint -q /mnt/user; do if [ "$waited" -ge "$MOUNT_WAIT" ]; then die "/mnt/user is not mounted after ${MOUNT_WAIT}s. Array down? Refusing to run." fi [ "$waited" -eq 0 ] && say "waiting for /mnt/user to mount..." sleep 5 waited=$(( waited + 5 )) done [ "$waited" -gt 0 ] && say "/mnt/user mounted after ${waited}s" # Belt and braces: a real share mount is fuse.shfs, not a stray directory. if ! grep -qE ' /mnt/user (fuse\.shfs|shfs) ' /proc/mounts; then die "/mnt/user is mounted but not as shfs. Refusing to run -- investigate first." fi # -------------------------------------------------------------- preflight -- command -v tmux >/dev/null 2>&1 \ || die "tmux not found. Install it into /boot/extra, then re-run." [ -n "$CLAUDE_BIN" ] || CLAUDE_BIN="$(command -v claude 2>/dev/null || true)" [ -n "$CLAUDE_BIN" ] \ || die "claude not found on PATH. Set CLAUDE_BIN at the top of this script." # Deliberately NOT created here -- see the v2 note above. If it is missing, # that is a signal something is wrong, not something to paper over. [ -d "$WORKDIR" ] \ || die "$WORKDIR does not exist. Create it with the array started, then run 'claude' there once to accept workspace trust." mkdir -p "$LOGDIR" 2>/dev/null say "claude binary : $CLAUDE_BIN" say "workspace : $WORKDIR" say "log : $LOG" # ----------------------------------------------------------- tear down old -- # # Scoped deliberately: this kills the supervisor loop and the remote-control # server only. An interactive `claude` session you have open in another # terminal is left alone. say "stopping any previous instance..." tmux kill-session -t "$SESSION" 2>/dev/null && say " killed tmux session $SESSION" # Loop first, then its child -- reverse order just makes the loop respawn it. pkill -f "$LOOP" >/dev/null 2>&1 && say " killed supervisor loop" sleep 1 pkill -f "claude remote-control" >/dev/null 2>&1 && say " killed remote-control server" sleep 2 if pgrep -f "claude remote-control" >/dev/null 2>&1; then say " something did not exit, sending SIGKILL" pkill -9 -f "claude remote-control" >/dev/null 2>&1 sleep 1 fi # ------------------------------------------------------ write the loop file -- cat > "$LOOP" <<EOF #!/bin/bash export HOME=/root export PATH="$PATH" # Same guard inside the loop: if the array goes away underneath us, stop # rather than writing to a RAM-backed /mnt/user. cd "$WORKDIR" || exit 1 fails=0 while true; do if ! mountpoint -q /mnt/user; then echo "[\$(date)] /mnt/user vanished -- array stopped. Exiting." >> "$LOG" 2>/dev/null exit 1 fi echo "[\$(date)] starting" >> "$LOG" start=\$SECONDS "$CLAUDE_BIN" remote-control --name "$RC_NAME" $RC_FLAGS 2>&1 | tee -a "$LOG" ran=\$(( SECONDS - start )) if [ "\$ran" -lt 15 ]; then fails=\$(( fails + 1 )) echo "[\$(date)] exited after \${ran}s (fast failure \$fails/5)" >> "$LOG" if [ "\$fails" -ge 5 ]; then echo "[\$(date)] giving up -- fix the error above, then re-run the script" >> "$LOG" exit 1 fi else fails=0 echo "[\$(date)] exited after \${ran}s, restarting in 30s" >> "$LOG" fi sleep 30 done EOF chmod +x "$LOOP" || die "cannot chmod $LOOP" # ------------------------------------------------------------------ launch -- echo "[$(date)] === startup script run (v2) ===" >> "$LOG" tmux new-session -d -s "$SESSION" "$LOOP" || die "tmux failed to start the session" say "tmux session '$SESSION' started" # ------------------------------------------- handle the first-run prompt ---- # # Detection reads the log rather than the pane: the loop pipes through tee, so # the log is the reliable copy of what the server printed. say "waiting for server to come up..." answered=0 registered=0 for i in $(seq 1 40); do # up to ~60s sleep 1.5 tail_out="$(tail -20 "$LOG" 2>/dev/null)" case "$tail_out" in *"Workspace not trusted"*) tmux kill-session -t "$SESSION" 2>/dev/null die "workspace is not trusted. Run: cd $WORKDIR && claude then accept the dialog." ;; *"requires a claude.ai subscription"*|*"full-scope login token"*|*"isn't enabled for this account"*) tmux kill-session -t "$SESSION" 2>/dev/null die "not signed in with an eligible account. Run: claude then /login" ;; *"Enable Remote Control?"*) if [ "$answered" -eq 0 ]; then say "answering first-run 'Enable Remote Control?' prompt" tmux send-keys -t "$SESSION" y Enter answered=1 fi ;; esac # A real registration prints a session URL with a query string. The startup # banner also contains the bare string "claude.ai/code", which is why v1 # reported success too early -- match on the URL form instead. case "$tail_out" in *"claude.ai/code?"*|*"claude.ai/code/"*) registered=1 say "session registered" break ;; esac done # ------------------------------------------------------------------ verify -- sleep 3 if ! pgrep -f "claude remote-control" >/dev/null 2>&1; then say "WARNING: no remote-control process found. Check the log:" say " tail -40 $LOG" exit 1 fi if [ "$registered" -eq 1 ]; then say "OK -- remote-control server running and registered as '$RC_NAME'" say "Open the Claude app, tap Code, look for '$RC_NAME' with a green dot." else say "PARTIAL -- process is running but no session URL seen yet." say "It may still be connecting. Check with:" say " tmux capture-pane -p -t $SESSION | tail -20" fi cat <<EOM [claude-rc] Useful commands: tmux attach -t $SESSION # watch it (Ctrl-B then D to leave) tmux capture-pane -p -t $SESSION | tail -30 # peek without attaching tail -f $LOG # follow the log tmux kill-session -t $SESSION # stop everything EOM |
Stopping the array
|
1 |
/boot/config/scripts/claude-remote-control-stop.sh |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#!/bin/bash # # claude-remote-control-stop.sh (v2) # # Tears down the Claude Code Remote Control daemon so it stops holding files # open on /mnt/user. Schedule in User Scripts at "At Stopping of Array". # # Without it, Unraid can hang at "Retry unmounting disk share(s)" because the # daemon's working directory lives on the array. # # /boot is FAT32 and cannot hold an execute bit, so invoke it as: # bash /boot/config/scripts/claude-remote-control-stop.sh # # Always exits 0 -- never block an array stop on a cleanup failure. SESSION="claude-rc" LOOP="/tmp/claude-rc-loop.sh" LOG="/mnt/user/appdata/claude-code/remote-control.log" # stdout always (User Scripts captures it); the array log only when it is safe. log() { local msg="[$(date)] [stop] $*" echo "$msg" if mountpoint -q /mnt/user 2>/dev/null; then echo "$msg" >> "$LOG" 2>/dev/null fi } log "array stopping, tearing down remote control" # --------------------------------------------------------------- teardown -- tmux kill-session -t "$SESSION" 2>/dev/null && log "killed tmux session $SESSION" # Supervisor loop first -- kill the server first and the loop just respawns it. pkill -f "$LOOP" 2>/dev/null && log "killed supervisor loop" sleep 1 pkill -f "claude remote-control" 2>/dev/null && log "killed remote-control server" sleep 2 if pgrep -f "claude remote-control" >/dev/null 2>&1; then log "still running, sending SIGKILL" pkill -9 -f "claude remote-control" 2>/dev/null sleep 1 fi # Anything else of ours still sitting on the array. pkill -9 -f "$LOOP" 2>/dev/null # ----------------------------------------------------------------- report -- if pgrep -f "claude remote-control" >/dev/null 2>&1; then log "WARNING: processes survived SIGKILL -- array unmount may still hang" else log "teardown complete" fi # Informational only: a shell parked in a /mnt/user directory will hold the # mount open just as effectively as the daemon did, and is easy to forget. if command -v fuser >/dev/null 2>&1 && mountpoint -q /mnt/user 2>/dev/null; then holders="$(fuser -m /mnt/user 2>/dev/null | tr -s ' ')" if [ -n "$holders" ]; then log "note: /mnt/user still held by PIDs:$holders" log "note: check with 'fuser -mv /mnt/user' -- often a shell left in a share directory" fi fi exit 0 |
Leave A Reply