Meta Description: Learn how to use Claude Code with your phone from anywhere — Windows or Mac — and run tasks overnight automatically. Includes ready-to-paste setup prompts and a full step-by-step guide.
How to Use Claude Code With Your Phone — and Let It Work While You Sleep
If you use Claude Code every day, you already know the frustration: the moment you close your laptop, everything stops. You have to sit and wait for tasks to finish before you can walk away.
This guide shows you exactly how to use Claude Code with your phone from anywhere, and how to let it keep running tasks overnight while you sleep. Works on both Windows and Mac. One-time setup, about 30–45 minutes, and then it just works.
What You’ll Be Able to Do
- Open any Claude Code project from your phone in seconds
- Send prompts while commuting, in a meeting, or lying on the couch
- Start a task before bed and wake up to the results
- Let Claude keep working even after your phone screen turns off
What You Need Before Starting
- A Windows PC or MacBook you can leave powered on
- Claude Code installed on that computer
- A Claude Pro or Max plan (needed for the phone mirroring feature)
- An iPhone or Android phone
- Termius app on your phone — it’s free
How It Works in Plain English
Think of your computer as the engine and your phone as the remote control. The computer does all the work. Your phone just lets you watch, steer, and send new instructions — from anywhere.
There are three pieces to this setup:
1. Phone Mirroring
Claude Code has a built-in feature called Remote Control. You type one command, a pairing code appears, scan it on your phone, and your session is now live on both devices. What you type on your phone runs on your computer.
2. Backup Connection via Tailscale
Tailscale is a free app that links your phone and computer privately over the internet — like a tunnel only you can use. Remote Control is the easy option, but having Tailscale as a backup means you always have a way in.
3. Overnight Tasks
You can tell Claude Code to run a task completely on its own. Give it a prompt, set a step limit and a spend limit, and it runs while you sleep. Everything gets saved to a log file you can read in the morning.
Pick Your Setup — Windows PC or MacBook
Jump to the section that matches your computer:
🖥 Windows PC Setup
Option A — Let Claude Set It All Up for You (Windows)
Copy the prompt below, open Claude Code on your PC, paste it in, and press Enter. Claude will detect your Windows username automatically, check what’s already installed, run each step, and give you a summary of what it did.
The only thing you need to change: replace YOUR_PROJECT_FOLDER_PATH near the top with the actual path to your projects folder — for example C:\Users\YourName\Documents\My Projects.
📋 Windows Setup Prompt — paste into Claude Code on your PC
Claude handles the setup. You only change one line.
Set up my Windows PC so I can use Claude Code with my phone and run tasks overnight.
My project folder is: YOUR_PROJECT_FOLDER_PATH
Work through each step in order. Before each step, check if it is already done — if so, skip it and mark it complete. Do not delete or overwrite any existing files. Ask me if anything is unclear.
---
STEP 1 — Find my Windows username
Run this and show me the result:
echo $env:USERNAME
---
STEP 2 — Disable sleep mode
Print these instructions so I can do it in 30 seconds:
Windows Settings → System → Power and battery → Screen and sleep
Set "When plugged in, put my device to sleep after" → Never
---
STEP 3 — Install OpenSSH Server (lets my phone connect to this PC)
Run in PowerShell as Administrator. Skip any line that is already done:
Add-WindowsCapability -Online -Name 'OpenSSH.Server~~~~0.0.1.0'
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Profile Private,Domain
Note: The first line can silently take up to 30 minutes. Leave it running.
---
STEP 4 — Create the SSH key file
IMPORTANT: For Windows admin accounts the correct file path is:
C:\ProgramData\ssh\administrators_authorized_keys
Do NOT use ~/.ssh/authorized_keys — Windows ignores that path for admin users and gives no error.
Run in Admin PowerShell:
$f = "C:\ProgramData\ssh\administrators_authorized_keys"
if (-not (Test-Path $f)) { New-Item -ItemType File -Path $f -Force | Out-Null }
icacls $f /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
Write-Host "File ready at: $f"
Tell me the path and remind me to paste my phone's public key into it.
---
STEP 5 — Install WSL2 + Ubuntu + tmux
Run in PowerShell:
wsl --install -d Ubuntu
If WSL is already installed, verify Ubuntu is present with: wsl -l -v
Once Ubuntu is set up, run inside the Ubuntu terminal:
sudo apt update && sudo apt install -y tmux && mkdir -p ~/claude-logs && echo "Ready"
---
STEP 6 — Find where Claude Code is installed
Check these paths and tell me which one exists:
ls /mnt/c/Users/$env:USERNAME/.local/bin/claude.exe 2>/dev/null
which claude 2>/dev/null
Show me the full path.
---
STEP 7 — Create one-word shortcuts for all my projects
List every subfolder inside: YOUR_PROJECT_FOLDER_PATH
For each folder create a shortcut keyword (lowercase, no spaces).
Write all shortcuts into ~/.claude_shortcuts.sh inside WSL using this template:
CLAUDE='[path from Step 6]'
BASE='[project folder in /mnt/c/... format]'
_launch() {
local session="$1"; local path="$2"; local label="$3"
echo ""; echo " Opening: $label"; echo ""
if tmux has-session -t "$session" 2>/dev/null; then
echo " Already open — reconnecting..."
tmux attach -t "$session"
else
tmux new-session -d -s "$session" -c "$path"
tmux send-keys -t "$session" "$CLAUDE" Enter
tmux attach -t "$session"
fi
}
sessions() { echo "Active sessions:"; tmux ls 2>/dev/null || echo "(none)"; }
kill_session() { tmux kill-session -t "$1" && echo "Closed: $1"; }
Then run:
echo '[ -f ~/.claude_shortcuts.sh ] && source ~/.claude_shortcuts.sh' >> ~/.bashrc
source ~/.bashrc
---
STEP 8 — Tailscale instructions
Print these clearly:
1. Go to https://tailscale.com — install on PC (free)
2. Install Tailscale on your phone (App Store or Google Play)
3. Sign into the same account on both
4. Open https://login.tailscale.com/admin/machines
5. Find your PC — copy the hostname ending in .ts.net
---
STEP 9 — Remote Control instructions
Print these clearly:
1. Open Claude Code in any project folder on your PC
2. Type: /remote-control
3. A pairing code appears
4. On your phone: Claude app → tap Code → enter the code
5. Your session is now live on your phone
6. Closing the app does NOT stop Claude
---
STEP 10 — Final summary
Print three sections:
✅ DONE
⏭ ALREADY SET UP — SKIPPED
📱 STILL NEEDED ON YOUR PHONE — with simple instructions
Option B — Step-by-Step Guide (Windows)
Step 1 — Stop Your PC Going to Sleep
Press Win + I → System → Power & battery → Screen and sleep
Set “When plugged in, put my device to sleep after” to Never. Keep your PC plugged into power.
Step 2 — Allow Your Phone to Connect to Your PC
Press Win + X → choose Terminal (Admin) or PowerShell (Admin).
⏳ The first line can take up to 30 minutes silently. Leave it running.
# Install OpenSSH Server — may take up to 30 min, leave it running
Add-WindowsCapability -Online -Name 'OpenSSH.Server~~~~0.0.1.0'
# Start it now
Start-Service sshd
# Make it start automatically every time Windows boots
Set-Service -Name sshd -StartupType Automatic
# Open the connection on your firewall (private networks only)
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' `
-Enabled True -Direction Inbound -Protocol TCP -Action Allow `
-LocalPort 22 -Profile Private,Domain
Step 3 — Set Up Passwordless Login From Your Phone
On your phone in Termius: Keychain tab → + → Generate Key → Ed25519 → tap the key → Copy Public Key.
⚠️ Use exactly this file path — Windows silently ignores ~\.ssh\authorized_keys for admin accounts. This is the most common reason phone login fails.
$f = "C:\ProgramData\ssh\administrators_authorized_keys"
New-Item -ItemType File -Path $f -Force | Out-Null
icacls $f /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
Add-Content -Path $f -Value "ssh-ed25519 AAAA...paste-your-key-here... MyPhone"
Write-Host "Done."
Step 4 — Install a Linux Layer and Session Keeper
WSL2 gives your PC a Linux terminal. tmux keeps your sessions alive when you close your phone — without it, closing the app stops Claude mid-task.
wsl --install -d Ubuntu
Restart if asked. Ubuntu opens and asks for a username and password — write them down. Then inside Ubuntu run:
sudo apt update && sudo apt install -y tmux && mkdir -p ~/claude-logs && echo "All ready"
Step 5 — Install Tailscale
- Download at tailscale.com → install on PC and sign up (free)
- Install Tailscale on your phone and sign in with the same account
- Open the Tailscale dashboard → find your PC → note the address ending in
.ts.net
Step 6 — Connect From Your Phone (Termius)
- Hosts →
+→ New Host - Hostname: your Tailscale
.ts.netaddress - Username: your Windows login name
- SSH ID: tap “+ SSH ID, Key…” → select the key from Step 3
- Tap Connect → type
wsl→ typeclaude
If it says “Not logged in”, type /login inside Claude Code and sign in through your phone browser.
Step 7 — Create One-Word Project Shortcuts
nano ~/.claude_shortcuts.sh
Paste the template below. Change the two top lines to your own paths and add your projects at the bottom. Save: Ctrl+O → Enter → Ctrl+X.
# Edit these two lines
CLAUDE='/mnt/c/Users/YOUR-USERNAME/.local/bin/claude.exe'
BASE='/mnt/c/Users/YOUR-USERNAME/Documents/YOUR-PROJECT-FOLDER'
_launch() {
local session="$1"; local path="$2"; local label="$3"
echo ""; echo " Opening: $label"; echo ""
if tmux has-session -t "$session" 2>/dev/null; then
echo " Already open — reconnecting..."
tmux attach -t "$session"
else
tmux new-session -d -s "$session" -c "$path"
tmux send-keys -t "$session" "$CLAUDE" Enter
tmux attach -t "$session"
fi
}
sessions() { tmux ls 2>/dev/null || echo "(none running)"; }
kill_session() { tmux kill-session -t "$1" && echo "Closed: $1"; }
# Add one line per project:
newsletter() { _launch 'newsletter' "$BASE/Newsletter" 'Newsletter'; }
client1() { _launch 'client1' "$BASE/Client 1" 'Client 1'; }
mywebsite() { _launch 'mywebsite' "$BASE/Website" 'My Website'; }
echo '[ -f ~/.claude_shortcuts.sh ] && source ~/.claude_shortcuts.sh' >> ~/.bashrc && source ~/.bashrc
Step 8 — Enable Phone Mirroring
Open Claude Code in any project and type:
/remote-control
Scan the code on your phone in the Claude app → Code tab. Done — your session is live on both devices.
Step 9 — Overnight Tasks (Windows)
Send a task from the Claude app before bed. Or use Windows Task Scheduler to run one automatically:
wsl.exe bash -lc "cd '/mnt/c/Users/YOUR-USERNAME/Documents/YOUR-PROJECT' && claude -p 'Your task here' --allowedTools 'Read' 'Write' 'Bash(git *)' --max-turns 20 --max-budget-usd 1.50 >> ~/claude-logs/$(date +%F).log 2>&1"
🍎 MacBook Setup
The Mac setup is actually simpler than Windows. macOS already has a built-in terminal, SSH support, and does not need a Linux layer. The steps are fewer and faster.
Option A — Let Claude Set It All Up for You (Mac)
Copy the prompt below, open Claude Code in Terminal on your Mac, paste it in, and press Enter.
The only thing you need to change: replace YOUR_PROJECT_FOLDER_PATH near the top with the path to your projects — for example /Users/yourname/Documents/My Projects.
📋 Mac Setup Prompt — paste into Claude Code in Terminal
Claude handles the setup. You only change one line.
Set up my Mac so I can use Claude Code with my phone and run tasks overnight.
My project folder is: YOUR_PROJECT_FOLDER_PATH
Work through each step in order. Before each step, check if it is already done — if so, skip it and mark it complete. Do not delete or overwrite any existing files. Ask me if anything is unclear.
---
STEP 1 — Find my Mac username
Run this and show me the result:
whoami
---
STEP 2 — Disable sleep mode
Print these instructions so I can do it quickly:
System Settings → Battery → Options → Enable "Prevent automatic sleeping when display is off"
Or for older macOS: System Preferences → Energy Saver → uncheck "Put hard disks to sleep"
Also: System Settings → Lock Screen → set "Turn display off" to Never (when plugged in)
---
STEP 3 — Enable Remote Login (SSH) on Mac
Run this command to enable SSH:
sudo systemsetup -setremotelogin on
Then verify it is on:
sudo systemsetup -getremotelogin
If the command is not available (macOS Ventura+), print these manual instructions:
System Settings → General → Sharing → turn on "Remote Login"
Click the (i) icon → Allow access for: All users (or specific users)
---
STEP 4 — Set up SSH key file for phone login
The correct file on Mac is the standard location:
~/.ssh/authorized_keys
Run these commands:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
echo "File ready at: ~/.ssh/authorized_keys"
Tell me the path and remind me to paste my phone's public key into it.
---
STEP 5 — Install tmux (session keeper)
First check if Homebrew is installed:
which brew
If Homebrew is not installed, run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install tmux:
brew install tmux
Create the log folder:
mkdir -p ~/claude-logs && echo "tmux ready"
---
STEP 6 — Find where Claude Code is installed
Check these paths and tell me which one exists:
which claude
ls ~/.local/bin/claude 2>/dev/null
ls /usr/local/bin/claude 2>/dev/null
Show me the full path.
---
STEP 7 — Create one-word shortcuts for all my projects
List every subfolder inside: YOUR_PROJECT_FOLDER_PATH
For each folder create a shortcut keyword (lowercase, no spaces).
Write all shortcuts into ~/.claude_shortcuts.sh using this template:
CLAUDE='[path from Step 6]'
BASE='[project folder path]'
_launch() {
local session="$1"; local path="$2"; local label="$3"
echo ""; echo " Opening: $label"; echo ""
if tmux has-session -t "$session" 2>/dev/null; then
echo " Already open — reconnecting..."
tmux attach -t "$session"
else
tmux new-session -d -s "$session" -c "$path"
tmux send-keys -t "$session" "$CLAUDE" Enter
tmux attach -t "$session"
fi
}
sessions() { echo "Active sessions:"; tmux ls 2>/dev/null || echo "(none)"; }
kill_session() { tmux kill-session -t "$1" && echo "Closed: $1"; }
Then add to your shell profile. Check which shell you use:
echo $SHELL
If it says zsh (most Macs since 2019):
echo '[ -f ~/.claude_shortcuts.sh ] && source ~/.claude_shortcuts.sh' >> ~/.zshrc
source ~/.zshrc
If it says bash:
echo '[ -f ~/.claude_shortcuts.sh ] && source ~/.claude_shortcuts.sh' >> ~/.bash_profile
source ~/.bash_profile
---
STEP 8 — Tailscale instructions
Print these clearly:
1. Go to https://tailscale.com — install on Mac (free)
2. Install Tailscale on your phone (App Store or Google Play)
3. Sign into the same account on both
4. Open https://login.tailscale.com/admin/machines
5. Find your Mac — copy the hostname ending in .ts.net
---
STEP 9 — Remote Control instructions
Print these clearly:
1. Open Claude Code in any project folder on your Mac
2. Type: /remote-control
3. A pairing code appears
4. On your phone: Claude app → tap Code → enter the code
5. Your session is now live on your phone
6. Closing the app does NOT stop Claude
---
STEP 10 — Final summary
Print three sections:
✅ DONE
⏭ ALREADY SET UP — SKIPPED
📱 STILL NEEDED ON YOUR PHONE — with simple instructions
Option B — Step-by-Step Guide (Mac)
Step 1 — Stop Your Mac Going to Sleep
Go to System Settings → Battery → Options → turn on “Prevent automatic sleeping on power adapter when display is off”. Keep your Mac plugged in.
On older macOS: System Preferences → Energy Saver → uncheck “Put hard disks to sleep when possible” and set Computer Sleep to Never when plugged in.
Step 2 — Enable SSH on Your Mac
This lets your phone connect to your Mac. Open Terminal (Applications → Utilities → Terminal) and run:
sudo systemsetup -setremotelogin on
If you’re on macOS Ventura or later and that command doesn’t work, go to:
System Settings → General → Sharing → Remote Login → turn it On
Click the (i) icon and set “Allow access for” to All users.
Step 3 — Set Up Passwordless Login From Your Phone
On your phone in Termius: Keychain tab → + → Generate Key → Ed25519 → tap the key → Copy Public Key.
On your Mac in Terminal:
# Create the SSH folder and key file
mkdir -p ~/.ssh && chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys
# Add your phone's key — replace the example with your actual key
echo "ssh-ed25519 AAAA...paste-your-key-here... MyPhone" >> ~/.ssh/authorized_keys
echo "Done."
✅ On Mac, ~/.ssh/authorized_keys is the correct location — no special path needed.
Step 4 — Install tmux (Session Keeper)
tmux keeps your Claude sessions running after you close your phone. First install Homebrew if you don’t have it (Homebrew is a free tool that makes installing Mac software easy):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install tmux:
brew install tmux && mkdir -p ~/claude-logs && echo "All ready"
Step 5 — Install Tailscale
- Download at tailscale.com → install on Mac and sign up (free)
- Install Tailscale on your phone and sign in with the same account
- Open the Tailscale dashboard → find your Mac → note the address ending in
.ts.net
Step 6 — Connect From Your Phone (Termius)
- Hosts →
+→ New Host - Hostname: your Tailscale
.ts.netaddress - Username: your Mac username (the one shown in System Settings)
- SSH ID: tap “+ SSH ID, Key…” → select the key from Step 3
- Tap Connect → you’ll see a Mac terminal → type
claude
Step 7 — Create One-Word Project Shortcuts
nano ~/.claude_shortcuts.sh
Paste the template, edit your paths and projects, save with Ctrl+O → Enter → Ctrl+X:
# Edit these two lines
CLAUDE=$(which claude)
BASE='/Users/YOUR-USERNAME/Documents/YOUR-PROJECT-FOLDER'
_launch() {
local session="$1"; local path="$2"; local label="$3"
echo ""; echo " Opening: $label"; echo ""
if tmux has-session -t "$session" 2>/dev/null; then
echo " Already open — reconnecting..."
tmux attach -t "$session"
else
tmux new-session -d -s "$session" -c "$path"
tmux send-keys -t "$session" "$CLAUDE" Enter
tmux attach -t "$session"
fi
}
sessions() { tmux ls 2>/dev/null || echo "(none running)"; }
kill_session() { tmux kill-session -t "$1" && echo "Closed: $1"; }
# Add one line per project:
newsletter() { _launch 'newsletter' "$BASE/Newsletter" 'Newsletter'; }
client1() { _launch 'client1' "$BASE/Client 1" 'Client 1'; }
mywebsite() { _launch 'mywebsite' "$BASE/Website" 'My Website'; }
Activate (most Macs use zsh since 2019 — if unsure, run echo $SHELL first):
echo '[ -f ~/.claude_shortcuts.sh ] && source ~/.claude_shortcuts.sh' >> ~/.zshrc && source ~/.zshrc
Step 8 — Enable Phone Mirroring
Open Claude Code in any project and type:
/remote-control
Scan the code on your phone in the Claude app → Code tab. Your session is now live on both devices.
Step 9 — Overnight Tasks (Mac)
Send a task from the Claude app before bed. Or use a cron job to run one automatically (this example runs every day at 7am):
# Open your cron schedule editor
crontab -e
Add this line (change the path, username, and prompt to your own):
0 7 * * * cd "/Users/YOUR-USERNAME/Documents/YOUR-PROJECT" && claude -p "Your task here" --allowedTools "Read" "Write" "Bash(git *)" --max-turns 20 --max-budget-usd 1.50 >> ~/claude-logs/$(date +\%F).log 2>&1
--max-turns 20 stops Claude after 20 steps. --max-budget-usd 1.50 stops it if cost goes over $1.50. Always set both.
Quick Reference — Commands for Both Platforms
| What you want to do | What to type |
|---|---|
| Open a project from phone | Your keyword (e.g. newsletter) |
| See what’s currently running | sessions |
| Come back to a running session | tmux attach -t sessionname |
| Step away without stopping Claude | Ctrl+b then d |
| Read today’s overnight log | cat ~/claude-logs/$(date +%F).log |
| Close a session you’re done with | kill_session sessionname |
| Mirror session to your phone | Inside Claude Code: /remote-control |
Conclusion
Once this is set up — whether you’re on Windows or Mac — you can use Claude Code with your phone from anywhere and let it run tasks overnight without anyone watching. The one-time setup takes under an hour. After that, it just works.
You stop waiting for tasks to finish. You start checking in on what got done.
Frequently Asked Questions
1. Does this work on Mac as well as Windows?
Yes. This guide covers both. The Mac setup is actually simpler — no Linux layer needed, and the standard SSH key location works without any extra steps. Both platforms use the same phone apps (Claude, Tailscale, Termius) and the same Remote Control feature.
2. Do I need a paid Claude plan to use Claude Code with my phone?
The phone mirroring feature (Remote Control) requires a Claude Pro or Max plan. However, connecting via Tailscale and Termius works with any plan — it gives you full access to your computer and Claude Code without the mirroring feature.
3. Does my computer have to stay on all night?
Yes. Claude Code runs locally on your computer, so the machine must stay on and connected to the internet. Disable sleep mode and keep it plugged into power. Most modern computers use very little electricity when idle.
4. What is Tailscale in plain English?
Tailscale creates a private, secure link between your phone and your computer — like a tunnel only you can use. Without it, your computer’s internet address keeps changing and your phone can’t reliably find it. Tailscale gives your computer a permanent address that always works, even on mobile data. Free for personal use.
5. What is tmux and why does it matter?
tmux keeps your Claude Code session running even after you close your phone or lose your connection. Without it, closing the app stops Claude mid-task. With tmux running in the background, the session keeps going. You can reconnect hours later and find everything exactly as you left it.
6. Is it safe to leave Claude running overnight?
Yes, as long as you set limits. Always include how many steps Claude can take (–max-turns) and a maximum spend (–max-budget-usd). Claude stops as soon as either limit is reached. Run any new task manually once first before scheduling it overnight — so you know exactly what it does.
7. How much does an overnight task actually cost?
It depends on the task. A short task like summarising files might cost $0.10 to $0.50. A bigger task like reviewing a large codebase could cost $2 to $10. Set a spend cap on every task and run it manually once first so there are no surprises.
8. What is the difference between Remote Control and Tailscale?
Remote Control is the built-in Anthropic feature that mirrors your Claude Code session to the Claude app — the easiest option, no extra setup. Tailscale gives you full terminal access to your computer and works completely independently. Having both means you always have a way in.
9. Does this work on Android too, not just iPhone?
Yes. The Claude app is available on both iOS and Android and Remote Control works on both. Termius is also available on Android via Google Play. Everything in this guide applies to both phone platforms.
10. My phone can’t connect. What should I check first?
On Windows: Check Tailscale is connected on both devices. Run Get-Service sshd in PowerShell — it should say Running. Check your key is at C:\ProgramData\ssh\administrators_authorized_keys (not ~/.ssh/authorized_keys).
On Mac: Check Tailscale is connected. Run sudo systemsetup -getremotelogin — it should say “Remote Login: On”. Check your key is in ~/.ssh/authorized_keys and that the file permissions are correct (run chmod 600 ~/.ssh/authorized_keys).





