DEV Community

Kewton
Kewton

Posted on

Control Local AI Coding Agents from Your Phone (Tailscale & Cloudflare)

Leaving your desk should not mean leaving your coding agents stalled until evening. At the same time, running heavy builds, tests, and local models on a phone makes no sense when you already have a fast desktop or home server.

The sweet spot is a clean split: keep execution on your local machine, and move 1-minute reviews, file checks, and prompt approvals to your phone.

In this second part of the series (verified as of CommandMate v0.55.0), I cover how commandmate remote pairs your phone securely over Tailscale or Cloudflare Tunnel without opening raw ports, how the mobile UI preserves full desktop capability, and where to draw the line with Auto-Yes.

Series: Building CommandMate

  1. What is CommandMate?
  2. Mobile Workflow with Tailscale & Cloudflare Tunnel (This post)
  3. Autonomous AI Coding Agent Team (Coming soon)
  4. Persistent Memory & Automated Retrospectives (Coming soon)

Want to try CommandMate in 1 minute? Run npx commandmate@latest or visit Kewton/CommandMate.

Prerequisites and Threat Model

Prerequisites:

  • CommandMate installed and working locally (commandmate status reports running)
  • Either Tailscale (installed and signed in on both your host machine and phone) or cloudflared installed (brew install cloudflared on macOS)
  • macOS or Linux host (note: WSL2 remote tunneling is currently unverified because 127.0.0.1 forwarding between WSL2 and Windows varies by host configuration)

What this post does not cover:

  • Exposing CM_BIND=0.0.0.0 directly without authentication (unsafe on any shared Wi-Fi)
  • Multi-user hosted SaaS deployments behind custom reverse proxies

How commandmate remote Keeps Localhost Intact

By default, CommandMate binds only to 127.0.0.1 with no external listener. Running commandmate remote never writes CM_BIND=0.0.0.0. Instead, it restarts the server with token authentication enabled and attaches an outbound provider process (Tailscale Serve or Cloudflare Quick Tunnel) pointing at the loopback port.

Long-lived plaintext tokens are not stored on disk: the server receives only CM_AUTH_TOKEN_HASH, and the one-time pairing file (~/.commandmate/remote-pairing.json, mode 0600) is deleted the moment your phone completes pairing.

Desktop Parity on Mobile: Don't Drop Productivity Away from Your Desk

Most remote terminal tools degrade into squinting at wrapped TUI text over mobile SSH. CommandMate treats the mobile browser (and installable PWA) as a first-class client with the same capabilities as desktop:

  • Full Feature Parity: Anything you do on desktop—switching between Chat and Terminal views, inspecting diffs, approving prompts, managing agent instances, or starting new sessions—works directly on your phone.
  • Mobile Tab Bar for Self-Contained Inspection: The bottom tab bar gives single-tap access to Terminal (live output + input), History (past turns), Files (full File Tree), Tools (agent instances, execution logs, and CMATE), and Info (worktree details and Notes).
  • Files, Images, and Videos on Mobile: Tap Files to browse the worktree directory tree, read source files, or view generated images and videos without switching apps.
  • Tree Sidebar for Instant Session Switching: Repositories, branches, and worktrees appear as a structured tree with live status dots and Ready for work badges, so jumping to the exact session waiting on you takes one tap.
  • Reusable Prompts via Notes: Typing long instructions on a phone keyboard is slow. Each worktree includes an auto-saved Notes section (accessible via Info on mobile or desktop) where you can keep frequently used instructions, review checklists, or temporary text ready to copy and send.

In my own daily workflow, I primarily use Cloudflare Quick Tunnel (commandmate remote --provider cloudflare --yes) for quick zero-account pairing, and switch to Tailscale on occasions when I want the endpoint strictly limited to my private tailnet. Away from my desk, two mobile UI details made the biggest practical difference: saving recurring review checklists and verification prompts in Notes eliminates slow thumb-typing on a phone keyboard, and opening Files directly lets me inspect modified .tsx files, screenshots, or videos instead of approving blindly from a short text summary.

Three CommandMate mobile web UI screens side by side showing the Chat view with bottom tab bar, the worktree tree sidebar, and the File Tree panel

Choosing Your Tunnel: Tailscale vs. Cloudflare Tunnel

CommandMate supports two built-in remote providers. Neither is universally "better"—pick based on your network constraints:

Dimension Tailscale (--provider tailscale) Cloudflare (--provider cloudflare --yes)
Who can reach the URL Only devices signed into your own tailnet Anyone who knows the Quick Tunnel URL (public internet)
Access protection Tailnet membership + CommandMate token login Single-use pairing code (default 10m TTL) + token login
Account requirement Tailscale app + account on both PC and phone cloudflared CLI only; no Cloudflare account needed
Non-interactive safety Runs directly when signed in Requires explicit --yes to confirm public URL exposure

If you already use Tailscale, it keeps your server completely off the public internet. If you cannot install VPN software on a device or want zero-account setup, Cloudflare Quick Tunnel gets you paired in seconds.

Step-by-Step Setup with commandmate remote

Follow these steps to pair a phone safely:

Step 1: Check Provider Readiness and Stop Any Unauthenticated Local Instance

commandmate status
tailscale status        # if using Tailscale
cloudflared --version   # if using Cloudflare
commandmate stop
Enter fullscreen mode Exit fullscreen mode

Step 2: Start the Authenticated Remote Session and Scan the QR Code

Scan the printed QR code or paste the one-time pairing URL into your phone's browser:

# Option A: Tailscale Serve (tailnet-only)
commandmate remote --provider tailscale

# Option B: Cloudflare Quick Tunnel (requires --yes to confirm public URL)
commandmate remote --provider cloudflare --yes
Enter fullscreen mode Exit fullscreen mode

Step 3: Decide Whether Your Local PC Stays Usable (--auth all vs. --auth remote-only)

Flag Through the phone tunnel Local PC browser & CLI (127.0.0.1) When to choose
--auth all (default) Token required Token required You are leaving your desk and want maximum isolation
--auth remote-only Token required Unauthenticated You actively use PC CLI (commandmate ls/send) and phone together

Note: Under --auth remote-only, CommandMate opens a second loopback listener on 127.0.0.1 dedicated to the tunnel so forged Host headers cannot bypass authentication. However, local processes on your machine (including agents running inside tmux) remain unauthenticated—the same exposure as running CommandMate locally without remote.

Step 4: Verify Pairing State and Close the Tunnel When You Return

commandmate remote status   # confirms Pairing: consumed
commandmate remote stop     # closes the outward tunnel; leaves local server running
Enter fullscreen mode Exit fullscreen mode

Warning: Always tear down Tailscale sessions with commandmate remote stop, not manual tailscale serve reset commands, so other port handlers you configured on the machine stay untouched.

Installing the PWA and Enabling Web Push

Because commandmate remote terminates TLS over HTTPS, you can install CommandMate via Add to Home Screen on iOS Safari or Android Chrome and receive Web Push notifications even when the app is closed (when an agent waits on you, a verification gate fails, or a session fails to start). On iOS/iPadOS, adding the app to the Home Screen is required by Safari before Web Push subscription works.

Auto-Yes Guardrails: What to Automate and What to Keep Manual

Leaving your desk exposes a subtle question: should you turn on Auto-Yes so an agent does not pause every 3 minutes on routine tool calls?

CommandMate treats Auto-Yes defensively:

  • Off by default: commandmate remote has no flag to turn on Auto-Yes automatically.
  • Time-boxed: When enabled, Auto-Yes runs only for 1 to 24 hours (presets: 1h, 3h, 8h), then disables itself.
  • Stop patterns: You can define regex/text stop patterns so any matching prompt immediately cancels Auto-Yes and waits for you.
  • Trust dialogs stay manual: Initial folder trust confirmations (such as Codex or Antigravity trust screens) are never answered by Auto-Yes.

A practical boundary that works well in mobile workflows:

  • Allow Auto-Yes on: Read-only exploration, running local unit tests, and edits inside an isolated feature worktree with a scoped task contract.
  • Keep manual on: git push, PR merges, database schema drops, package installs outside the repository, and specification changes.

Security Checklist Before You Leave Your Desk

Before walking out the door with a remote session live, verify these five points:

  1. commandmate remote status shows Pairing: consumed (no unused pairing link sitting around).
  2. You chose --auth all if you do not need unauthenticated local CLI access while away.
  3. Any Auto-Yes toggle has a short expiry (1h or 3h) and stop patterns configured for destructive commands.
  4. Your host machine's power settings will not immediately sleep mid-build.
  5. You remember to run commandmate remote stop when your away window ends.

In Part 3, we step beyond controlling individual sessions and look at how a 5-role AI agent team, task contracts, and local verification gates ship real releases on a 468k-LOC codebase.


Meta note: This draft was structured and verified against CommandMate v0.55.0 documentation and source files with AI assistance, then reviewed and edited by hand.

Top comments (0)