Build a Persistent AI Dev Environment That Follows You Everywhere
Build a persistent AI dev environment with AWS EC2, Tailscale, and tmux. Full Claude Code context across devices, zero public exposure.
I switch devices constantly. Mac at my desk, iPad on the couch, iPhone when I’m walking the dog. Every switch used to mean losing Claude Code context — restarting conversations, rebuilding mental state, wasting 10 minutes getting back to where I was.
Claude Code maintains rich context — project understanding, conversation history, file states, running processes. Close your laptop and that state evaporates. Cloud storage sync doesn’t fix this. Claude’s context lives in memory. Active processes can’t pause mid-execution. Semantic understanding doesn’t serialize to iCloud.
What you need isn’t sync — it’s externalized state: a development environment that persists independently of whatever device you’re touching it from.Here’s exactly how to build one. Total cost: ~$18/month. Total public exposure: zero.
The Architecture
Three layers solve the problem:
State Layer: AWS EC2 t3.small running Ubuntu, hosting Claude Code in tmux sessions that persist independently of client connections. This is where your AI context actually lives.
Access Layer: Tailscale mesh network providing zero-trust access. No ports open to the internet. No VPN. No firewall rules. Just a private mesh where your devices talk directly to each other.
Client Layer: Lightweight SSH terminals on any device — iTerm2 on Mac, Blink Shell on iPad, Terminus on iPhone. You connect, attach to the running tmux session, and you’re exactly where you left off.
Step 1: Launch the EC2 Instance
Specs: t3.small (2 vCPU, 2GB RAM), Ubuntu 24.04 LTS, 30GB gp3 EBS. Total: ~$18/month. Compare to GitHub Codespaces at 24/7 which runs ~$130/month.
# AWS Console → EC2 → Launch Instance
# AMI: Ubuntu Server 24.04 LTS
# Instance type: t3.small
# Key pair: Create new (download .pem file)
# Security group: Allow SSH (22) from your IP temporarily
# Storage: 30GB gp3
SSH in temporarily to set up:
chmod 400 ~/Downloads/claude-dev-shell.pem
ssh -i ~/Downloads/claude-dev-shell.pem ubuntu@<public-ip>
sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential curl git tmux
Step 2: Install Tailscale and Lock Down
Install Tailscale on the EC2 instance, then delete the public SSH rule. After this, the instance exists only on your private mesh — invisible to the internet.
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
tailscale ip -4
# Example: 100.104.32.15
Now go to AWS Console and delete the SSH inbound rule. No inbound rules needed — Tailscale handles everything.
Benefits of this security model:
- Zero public exposure — no public IP routes to SSH
- No port scanning possible — attackers can’t see what isn’t there
- No brute force attacks — can’t attack what you can’t reach
- Device authentication — only pre-authorized Tailscale devices connect
- Optional egress lockdown — EC2 can only talk to your mesh devices
Install Tailscale on your other devices: brew install tailscale on Mac, App Store on iPad/iPhone. Sign in with the same account. Done — they’re all on the mesh.
Step 3: Install Dev Tools
# Rust toolchain (for yazi and helix)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
# Bun (for Claude Code)
curl -fsSL https://bun.sh/install | bash
# yazi — terminal file manager (Rust, blazing fast, works on every device)
cargo install --locked yazi-fm
# helix — terminal editor (IDE features built-in, zero config)
git clone https://github.com/helix-editor/helix
cd helix && cargo install --path helix-term --locked
hx --grammar fetch && hx --grammar build
# Claude Code
bun install -g claude-code
Why yazi over ls/ranger? Visual file preview, fuzzy search, syntax highlighting, bulk operations, Git integration — all in a terminal that works identically on Mac, iPad, and iPhone.
Why helix over vim? LSP support out of the box, tree-sitter syntax highlighting, multiple cursors, selection-first editing. Zero configuration required. No plugin management.
Step 4: Set Up the tmux Session Script
This script creates (or attaches to) a persistent session with three windows: Claude Code, file browser, and shell.
cat > ~/start-claude.sh << 'EOF'
#!/bin/bash
SESSION="claude"
tmux has-session -t $SESSION 2>/dev/null
if [ $? != 0 ]; then
tmux new-session -d -s $SESSION -n main
tmux send-keys -t $SESSION:0 'cd ~/projects && claude-code' C-m
tmux new-window -t $SESSION:1 -n files
tmux send-keys -t $SESSION:1 'yazi ~/projects' C-m
tmux new-window -t $SESSION:2 -n shell
tmux select-window -t $SESSION:0
fi
tmux attach-session -t $SESSION
EOF
chmod +x ~/start-claude.sh
👉 Tip: Set your API key in .bashrc — export ANTHROPIC_API_KEY=your_key_here — so Claude Code picks it up automatically when tmux starts.
Step 5: Connect From Any Device
From here forward, the workflow is identical regardless of device:
# Same command from Mac, iPad, or iPhone
ssh ubuntu@100.104.32.15
~/start-claude.sh
Switch windows: Ctrl-b then 0 (Claude Code), 1 (file browser), or 2 (shell).
The magic: Close your laptop. Walk to the couch. Open iPad. SSH in. tmux attach -t claude. You’re exactly where you left off — mid-conversation, mid-analysis, mid-everything.
The Daily Workflow
Morning at desk (Mac): SSH in, start Claude Code, review context. Full keyboard, large screen — ideal for deep work.
Afternoon on couch (iPad): Same tmux session. Continue conversation mid-context. Blink Shell + external keyboard feels like native development.
Evening check-in (iPhone): Quick status check. Scan output, verify a build completed. Landscape mode. Not for heavy editing — for maintaining awareness.
Context persistence changes how you work. Device switches no longer mean “find a stopping point.” The AI remembers where you were.
Backup and Limitations
Backup strategy: Commit aggressively. EC2 isn’t a database — uncommitted work is lost if it corrupts. For extra safety, set up automated S3 backups:
# Cron: 0 */6 * * * /home/ubuntu/backup.sh
tar czf /tmp/projects-$(date +%Y%m%d-%H%M%S).tar.gz ~/projects
aws s3 cp /tmp/projects-*.tar.gz s3://your-backup-bucket/
Known limitations:
- Solo only. Multiple developers can’t share tmux sessions cleanly. One EC2 per developer, shared git repo.
- Mobile editing limits. Helix works on iPad, but complex refactoring is faster on Mac. Use iPad for continuation work.
- Latency on cellular. 100-200ms over cellular. Noticeable but not blocking. WiFi where possible.
👉 Tip: Start with a throwaway project. Test the full workflow — Mac to iPad to iPhone and back — before committing production work. Make sure tmux reattachment feels right on every device you’ll actually use.
The Core Insight
AI development state doesn’t belong on your laptop. It belongs in persistent compute you access from anywhere.
Your device becomes a window, not a container. Close the window — state remains. Open from a different device — state restored. Switch mid-conversation — context preserved.
~$18/month. Zero public exposure. Full Claude context across every device you own.
Continue reading:
- Claude Code Mastery: The Complete Guide — the deep dive on Claude Code architecture and workflows
- 10 Best Practices for Using Claude Code — quick-reference practices for productivity
- Claude Code for Ops Teams: Real Prompts, Real Workflows, Real Results — what to actually do once your environment is set up
