For most of September my Claude Code sessions lived on my Synology NAS. It’s always on, it’s where the files are, and SSH-ing in from anywhere was easy. It was also the weakest machine I own: under 2 GB of RAM, spinning disks, and a CPU that sat pinned whenever the agent ran a build or a big search.
This week I moved everything to a Mac Mini. It has 16 GB of RAM, an NVMe drive, and draws a few watts at idle, so it’s just as “always on” as the NAS. The move took about ten minutes, and the setup is simple enough that I think it’s the best way to run a coding agent at home. Here’s exactly how it works.
The goal: sessions that never die
Run claude in a normal terminal and the session dies when you close the lid, lose Wi-Fi, or your SSH connection drops. What I wanted instead:
- One long-running session per project, living on a box that never sleeps.
- Attach from any machine — laptop, desktop, or phone — and pick up exactly where I left off.
- Start a session in the background with one command, without opening a terminal window for it.
The answer is old and boring: tmux. tmux keeps a terminal session running on the server whether or not anyone is attached to it.
The whole thing is one shell script
I keep this in ~/.local/bin/cc on the Mac Mini (it’s on my PATH). Install tmux first with brew install tmux.
#!/bin/sh
# cc [-d] [project] - persistent Claude Code session in tmux.
# cc list sessions and projects
# cc myapp attach to (or create and attach) the session for myapp
# cc -d myapp create it detached in the background
DETACH=0
if [ "${1:-}" = "-d" ]; then DETACH=1; shift; fi
PROJ="${1:-}"
ROOT="${CC_PROJECTS:-$HOME/projects}"
if [ -z "$PROJ" ]; then
echo "Running sessions:"; tmux ls 2>/dev/null || echo " (none)"
echo; echo "Projects in $ROOT:"; ls -1 "$ROOT"
exit 0
fi
DIR="$ROOT/$PROJ"
mkdir -p "$DIR"
SESS="cc-$PROJ"
if tmux has-session -t "$SESS" 2>/dev/null; then
[ "$DETACH" = 1 ] && echo "$SESS already running" || exec tmux attach -t "$SESS"
else
if [ "$DETACH" = 1 ]; then
tmux new-session -d -s "$SESS" -c "$DIR" "claude; exec $SHELL"
echo "started $SESS in background"
else
exec tmux new-session -s "$SESS" -c "$DIR" "claude; exec $SHELL"
fi
fi
Day to day that turns into three commands:
cc # what's running, what projects exist
cc -d nas-maintenance # start a session in the background
cc nas-maintenance # attach to it (Ctrl+b then d to detach)
The exec $SHELL at the end matters. If Claude Code exits or crashes, the tmux window drops you into a shell in the project folder instead of vanishing, so you can see what happened and restart it.
Moving the sessions off the NAS
The migration was mostly about not losing anything:
- Put the project on the Mini. My
nas-maintenancescripts were already in a git repo, so this was a clone. - Check the old session is idle, then stop it cleanly. I confirmed its last turn had finished and sent a normal
kill -TERMrather than-9, so it could exit cleanly. - Copy the history. Claude Code stores each project’s conversations as
.jsonlfiles under~/.claude/projects/, in a folder named after the project path. I copied them into the matching folder on the Mini and compared checksums before deleting anything. - Back up the old config, minus the login token. The whole
~/.claudefolder went into a dated archive on the Mini. I excluded the credentials file: there’s no reason to copy a live token around. - Uninstall from the NAS. Remove the binary,
~/.local/share/claude,~/.claudeand~/.claude.json. Deleting the local token doesn’t revoke it on the server, so sign the old device out from your account settings too.
The NAS still does what it’s good at — storage and backups — and the agent reaches it over SSH when it needs to.
Following sessions from your phone
Inside any running session, the /remote-control command connects it to the Claude app, so I can watch progress and answer questions from my phone. Because the session lives in tmux on the Mini, it keeps running whether or not the phone is connected. I’ll start a long job at my desk, walk away, and approve the next step from wherever I am.
A warning about permission modes
My own version of this script launches Claude with --dangerously-skip-permissions, so tool calls run without asking. On a box that holds SSH keys to my NAS and web server, that’s a real decision, not a default to copy blindly. The flag is named that way for a reason. If you use it:
- Only on machines you own, running projects you trust.
- Keep backups of anything the agent can touch. More on that in my guide to letting an AI agent maintain your homelab safely.
- Give the agent SSH keys for the specific accounts it needs, not root.
If you’re unsure, leave the flag out. The approval prompts are slower, but tmux keeps the session alive while it waits for you.
Why the Mac Mini
You can do all of this on any always-on Linux box or mini PC. The Mini won for me because it’s silent, sips power, and has enough RAM and fast storage that the agent is never the bottleneck. Builds, searches and test runs that crawled on the NAS now finish before I’ve switched windows. If your coding agent lives on your weakest machine, it’s worth moving.