Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article walks through how to set up an environment where you can control Claude Code on your PC directly from an iPhone, wherever you are.

I keep Claude Code UI (Cloud CLI) running on my home computer (a Mac mini, MacBook, or similar device), create a private network with Tailscale, and access the web UI from the iPhone browser. I also use Claude Code's hooks to send push notifications through ntfy, so I can see when tasks finish or permission requests arrive in real time.

What this setup provides

By the end of this article, you will have an environment with the following capabilities.

  • Control Claude Code UI from the iPhone browser.
  • Access the UI only from within the private Tailscale network, without exposing it to the public Internet.
  • Keep the UI running under pm2 so that it automatically recovers if the process crashes.
  • Receive push notifications on the iPhone when Claude Code finishes a task or requests permission.

System architecture

The following Mermaid diagram shows how the components fit together.

flowchart TD
    subgraph iPhone
        A[ブラウザ] -->|HTTPS| B[Tailscale VPN]
        D[ntfyアプリ]
    end

    subgraph ホストPC
        E[Tailscale] --> S[tailscale serve<br/>HTTPS → localhost]
        S --> F[Claude Code UI<br/>cloudcli]
        F --> G[Claude Code CLI]
        G --> H[transcript保存]
        G --> I[Stopイベント発火]
        I --> J[hooks → 通知スクリプト]
        J -->|POST| K[ntfyサーバー]
        L[pm2] -->|プロセス管理| F
    end

    B --> E
    K --> D

On the iPhone, the browser accesses the web UI and the ntfy app receives notifications. On the host computer, Tailscale provides access to the private network, Claude Code UI orchestrates the CLI, and pm2 keeps the process running and restarts it if necessary. Claude Code's hooks notify ntfy when events occur.

Responsibilities of each component

The tables below summarize what each tool does.

iPhone

Tool Role
Tailscale app Establishes a VPN tunnel, joins the tailnet, and enables access to the host computer
Browser Accesses the Claude Code UI web interface
ntfy app Subscribes to an ntfy topic and receives notifications from Claude Code

Host computer

Tool Role
Tailscale + tailscale serve Joins the host computer to the tailnet and exposes Claude Code UI over HTTPS within it using tailscale serve
Claude Code UI (Cloud CLI) Runs a web UI server that lets the browser control the Claude Code CLI
Claude Code CLI Performs the AI processing and stores session history under ~/.claude/
pm2 Keeps Claude Code UI running, restarts it after a crash, and restores the process after an OS reboot
Claude hooks + ntfy.sh Runs a script for events such as Stop, PermissionRequest, and Notification, and sends notifications to ntfy

Network design

Private network access with Tailscale

Tailscale is the central security component of this setup. It is a WireGuard-based mesh VPN service with a free plan for personal use.

When you install Tailscale, each device is assigned an IP address within the tailnet in the form 100.x.x.x. Here is an example of the assigned addresses.

Device Tailnet IP address (example)
Host computer 100.x.x.x
iPhone 100.y.y.y

This 100.x.x.x virtual IP address is reachable within the tailnet. It is not directly reachable from the public Internet, so no router port forwarding is required. Communication is restricted to devices within the tailnet that are permitted by its access policy, rather than being available to arbitrary third parties.

HTTPS access with tailscale serve

Claude Code UI listens on localhost:3001 by default (the port can be changed with --port), but the iPhone cannot reach that local address directly. This is where Tailscale Serve comes in.

tailscale serve is a reverse proxy feature that makes a locally running service available over HTTPS through a MagicDNS hostname within the tailnet. Running the following command makes the local Claude Code UI available over HTTPS inside the tailnet. This example uses the default port, 3001. If you changed it with --port, substitute the appropriate port number.

bash
tailscale serve --bg http://localhost:3001

After running the command, you will see a URL like the following.

text
https://<ホスト名>.tail<Tailnet ID>.ts.net/

This is the URL to open in the iPhone browser. Tailscale automatically provisions the HTTPS certificate, so you do not need to buy a domain or manage certificates manually. As long as Tailscale is running on both devices, you can reach the URL whether you are at home or away.

To stop tailscale serve, run the following command.

bash
tailscale serve --https=443 off

This removes the HTTPS proxy configured by tailscale serve and stops access through it from the tailnet.

What is Claude Code UI?

Overview

Claude Code UI (Cloud CLI) is an open-source tool that provides a web UI for the Claude Code CLI.

It supports Claude Code, Cursor CLI, and Codex, and lets you manage projects and sessions from a browser. It is more than a viewer: it acts as an orchestrator, spawning CLI processes on the backend and streaming responses over WebSockets.

Main features

The following table summarizes the features provided by Claude Code UI.

Feature Description
Responsive design Supports desktop, tablet, and mobile devices
Chat interface Displays code with syntax highlighting and shows conversation history
File explorer Browse and edit the project's file tree
Git integration Stage changes, commit, and switch branches in the UI
Session management Create and resume multiple sessions and manage their histories
Shell terminal Control the CLI directly from a shell built into the UI

How it works internally

Here is how the UI interacts with the CLI.

The UI looks at directories under ~/.claude/projects/ and lists existing sessions by project. When a user selects a new session or resumes one in the UI, the backend spawns a Claude Code CLI process and streams its responses to the browser over a WebSocket.

In other words, the UI server serves as middleware for launching and managing the CLI and handling communication with it.

Why it works well on an iPhone

You might wonder whether you could simply run the CLI directly over SSH. However, terminal interactions on an iPhone have more limitations than those on a desktop.

Limited scrollback can make conversation history difficult to review, tab completion and keyboard shortcuts are less convenient, and switching sessions requires typing commands.

With Claude Code UI, you can switch sessions by tapping a list, review conversation history by scrolling, and select projects entirely through touch controls. The UI makes interactions on an iPhone substantially easier, which is why I find the extra layer worthwhile.

Setup instructions

Prerequisites

You will need the following tools.

Tool Version Installation method
Node.js v22 or later Official website or nvm
Claude Code CLI Latest version npm install -g @anthropic-ai/claude-code
Tailscale Latest version Desktop and iOS versions from the official website
ntfy app Latest version Available from the App Store
jq Latest version brew install jq (used by the ntfy.sh script)

Enable remote login (SSH)

Enabling SSH on the host computer lets you connect directly from your iPhone for troubleshooting and maintenance. SSH is also useful for routine tasks such as checking pm2 status and logs, so I recommend setting it up first.

On macOS

  1. Open System Settings, then General, then Sharing.
  2. Turn on Remote Login.
  3. Specify which users are allowed to connect.

Verify the connection

Install an SSH client such as Termius on the iPhone and verify that you can connect using the host's tailnet IP address.

bash
# iPhoneのSSHクライアントから実行
ssh username@100.x.x.x

100.x.x.x is the host computer's IP address within the tailnet. You can find it in the Tailscale app's device information.

Once you have verified the connection, you can recover the host directly from your iPhone if you run into issues in the remaining steps.

Install Claude Code UI

Install it globally so you can use the cloudcli command.

bash
npm install -g @siteboon/claude-code-ui

This command installs Claude Code UI globally, making both the cloudcli and claude-code-ui commands available.

If you want to try it without installing it, you can run it directly with npx.

bash
npx @siteboon/claude-code-ui

After installation, start the server with the following command.

bash
cloudcli

By default, it listens at http://localhost:3001. Use the --port option if you want to change the port.

bash
cloudcli --port 8080

At this point the UI is still accessible only through localhost, so the next step is to configure Tailscale.

Immediately after installation, all Claude Code tools (including file reads, file writes, and command execution) are disabled in Claude Code UI. Open Tools Settings using the gear icon in the UI sidebar and manually enable only the tools you need.

Set up Tailscale

On the host computer

These instructions are for macOS. On Windows or Linux, install the corresponding version from the Tailscale website and sign in to your account in the same way.

  1. Install Tailscale from its official website.
  2. Open the Tailscale app and sign in to your account.
  3. Verify that the app shows Connected.

On the iPhone

  1. Install Tailscale from the App Store.
  2. Open the app and sign in with the same account used on the host computer.
  3. Approve the VPN permission dialog when it appears.

Configure tailscale serve

After starting Claude Code UI under pm2, use tailscale serve to make it available over HTTPS. Use the port on which Claude Code UI is listening (the default is 3001).

bash
tailscale serve --bg http://localhost:3001

You should see output like the following.

text
Available within your tailnet:

https://<ホスト名>.tail<Tailnet ID>.ts.net/
|-- proxy http://localhost:3001

Open the https://... URL in the iPhone browser. If Claude Code UI loads, the connection is working.

On your first run, Tailscale may display a URL for enabling the Serve feature. Visit that URL, enable the feature, and run the command again.

Keep the process running with pm2

Run Claude Code UI under pm2 so that the process automatically recovers if it crashes.

Install and start pm2

bash
npm install -g pm2
pm2 start cloudcli --name "claude-code-ui"

The first line installs pm2 globally. The second registers Claude Code UI with pm2 and starts it. The name specified with --name is used in commands such as pm2 restart and pm2 logs.

If you changed the port, pass the options after --.

bash
pm2 start cloudcli --name "claude-code-ui" -- --port 8080

Options written after -- are forwarded directly to cloudcli.

Restore the process after an OS reboot

pm2 has a startup feature that can restore its processes automatically after the operating system restarts.

bash
pm2 startup
pm2 save

Running pm2 startup displays another command. Copy and execute that command. Save the current process list with pm2 save, and pm2 will start Claude Code UI automatically the next time the OS boots.

Common pm2 commands

Command Purpose
pm2 status Check process status
pm2 restart claude-code-ui Restart Claude Code UI
pm2 logs claude-code-ui View logs in real time
pm2 stop claude-code-ui Stop the process

Send notifications with Claude hooks and ntfy

If you submit a task to Claude Code and leave it running, you may not notice when it finishes. Here we combine Claude Code's hooks with ntfy to send a push notification to the iPhone when a task completes.

What is ntfy?

ntfy (pronounced "notify") is a simple notification service that delivers push notifications when you send a message via HTTP PUT or POST.

Install the ntfy app on the iPhone and subscribe to a topic name to receive notifications. On the public service, you do not need to register or obtain an API key for an unprotected topic; anyone who knows the topic name can publish or subscribe to it.

Configure the ntfy app

Install ntfy from the iPhone's App Store and subscribe to a topic name of your choice. Use a random string that is difficult to guess. The free setup described here uses a public server, so anyone who knows an unprotected topic name can subscribe or post to it. Use a random value such as a UUID for the topic name and take care not to include confidential information in notifications. In particular, the sample script below includes tool inputs and conversation excerpts; avoid sending those fields to a public topic if they could contain secrets.

How Claude hooks work

Claude Code's hooks can run external commands when specific events occur. The hooks pass event information in JSON format to the script's standard input (stdin).

Several events can trigger notifications, including permission requests and tool execution as well as task completion. The following table lists the main events.

Event When it fires
Stop When Claude Code finishes responding and stops
PermissionRequest When permission to execute a tool is requested
PreToolUse Immediately before a tool is executed
Notification When a notification occurs, such as a permission prompt or an idle prompt

Hooks configuration file

Add the following hooks configuration to ~/.claude/settings.json. This example runs the notification script for three events: Stop, PermissionRequest, and Notification.

~/.claude/settings.json
{
  "hooks": {
    "Stop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/ntfy.sh"
          }
        ]
      }
    ],
    "PermissionRequest": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/ntfy.sh"
          }
        ]
      }
    ],
    "Notification": [
      {
        "matcher": "permission_prompt, idle_prompt, auth_success, elicitation_dialog",
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/ntfy.sh"
          }
        ]
      }
    ]
  }
}

Here is how the configuration is structured. Define matcher and hooks inside the array for each event name. matcher is the filter for the event; an empty string or * matches all applicable values. In the Notification matcher, the example configuration specifies notification types such as permission_prompt and idle_prompt as a comma-separated list. Verify the supported matcher syntax for your installed version.

You can add hooks for other events such as PreToolUse using the same structure. For example, configuring PreToolUse lets you receive a notification immediately before a tool is executed. Keep in mind that PreToolUse fires for each tool execution, which can result in a high volume of notifications.

Data passed from the hook to the script

Hooks pass different JSON payloads to stdin depending on the event.

Event Main JSON fields
Stop transcript_path (full path to the conversation log)
PreToolUse tool_name, tool_input
Notification message

The ntfy.sh script uses these differences to identify the event type and customize the notification.

The ntfy.sh script

Create a notification script on the host computer. The following script examines the fields in the JSON received on stdin to identify the event type and choose the notification title and body.

~/.claude/ntfy.sh
#!/bin/bash
set -euo pipefail

DEFAULT_TOPIC_NAME="your-random-topic-name"
TOPIC_NAME="${NTFY_TOPIC:-$DEFAULT_TOPIC_NAME}"

# stdinからhook情報取得
HOOK_DATA=$(cat)

# 各イベントのフィールドを取得
TOOL_NAME=$(echo "$HOOK_DATA" | jq -r '.tool_name // empty')
TRANSCRIPT=$(echo "$HOOK_DATA" | jq -r '.transcript_path // empty')
NOTIFICATION_MSG=$(echo "$HOOK_DATA" | jq -r '.message // empty')

if [ -n "$TOOL_NAME" ]; then
  # PreToolUse / PermissionRequest
  TITLE="🔧 Tool: ${TOOL_NAME}"
  BODY=$(echo "$HOOK_DATA" | jq -r '.tool_input // empty' | head -c 300)
  if [ -z "$BODY" ]; then
    BODY="Permission requested"
  fi

elif [ -n "$TRANSCRIPT" ] && [ -f "$TRANSCRIPT" ]; then
  # Stop
  TITLE=$(jq -r '
    select(.type=="human")
    | .message.content
    | select(type=="string")
  ' "$TRANSCRIPT" | tail -1)
  TITLE="${TITLE:0:100}"
  if [ -z "$TITLE" ]; then
    TITLE="✅ Task completed"
  else
    TITLE="✅ ${TITLE}"
  fi

  BODY=$(jq -r '
    select(.type=="assistant")
    | .message.content[]
    | select(.type=="text")
    | .text
  ' "$TRANSCRIPT" | tail -1)
  BODY="${BODY:0:800}"

elif [ -n "$NOTIFICATION_MSG" ]; then
  # Notification
  TITLE="💬 Claude Code"
  BODY="$NOTIFICATION_MSG"

else
  exit 0
fi

if [ -n "${BODY:-}" ]; then
  printf "%s" "$BODY" | \
  curl -sS \
    -H "Title: ${TITLE}" \
    -H "Priority: default" \
    --data-binary @- \
    "https://ntfy.sh/${TOPIC_NAME}" \
    >/dev/null
fi

Grant the script execute permission.

bash
chmod +x ~/.claude/ntfy.sh

Here is how the script works. set -euo pipefail enables stricter shell error handling so the script stops on errors under the applicable shell rules. The script reads the entire JSON payload from stdin into a variable and extracts three fields: tool_name, transcript_path, and message. It uses the fields that contain values to identify the event and choose the notification title and body.

Event Notification title Notification body
PreToolUse / PermissionRequest 🔧 Tool: tool name Tool input parameters (up to 300 bytes)
Stop ✅ Most recent user message Latest Claude response (up to 800 characters)
Notification 💬 Claude Code Notification message

Adding an emoji prefix to the title makes it easy to distinguish different events at a glance in the iPhone's notification list. The script uses --data-binary to transmit the message body without altering its bytes, including multibyte characters such as Japanese text.

End-to-end data flow

The Mermaid diagram below illustrates how a Stop event results in a push notification.

flowchart TD
    A[iPhoneのブラウザでUI操作] --> B[Tailscale VPN]
    B --> C[ホストPC]
    C --> D[Claude Code UI]
    D --> E[Claude Code CLIを起動]
    E --> F[Claudeが応答を生成]
    F --> G[transcriptへ保存]
    F --> H[Stopイベント発火]
    H --> I[hooksがntfy.sh起動]
    I --> J[stdinのJSONからtranscript_path取得]
    J --> K[transcriptから最新メッセージ抽出]
    K --> L[ntfyサーバーへPOST]
    L --> M[iPhone ntfyでPush通知]

When the user submits a task from the browser, it reaches Claude Code UI on the host computer through Tailscale. The UI starts the CLI, Claude generates a response, and the response is saved to the transcript. When Claude Code stops responding, the Stop event fires and the hook starts ntfy.sh. The script extracts the latest message from the transcript, sends it to ntfy via POST, and the ntfy app on the iPhone receives a push notification.

Day-to-day usage

Once setup is complete, this is how you can use it on a daily basis.

  1. Open Tailscale on your iPhone and verify that the VPN is on.
  2. Open the Claude Code UI URL in the browser.
  3. Select a project in Claude Code UI and either create a new session or resume an existing one.
  4. Submit a task, leave it running, and check the result when the ntfy notification arrives.
  5. Submit additional tasks as needed.

Adding a shortcut to the home screen lets you use the UI much like a PWA. With Claude Code UI open in the browser, use the Share button and select Add to Home Screen.

Troubleshooting

The browser cannot open the UI

If you cannot connect, troubleshoot in this order.

  1. Check that Tailscale is enabled on your iPhone.
  2. Try another browser.
  3. If it still does not work, connect to the host computer over SSH and run pm2 status.

The host computer is asleep

When the host computer goes to sleep, Tailscale and Claude Code UI become unavailable. If you want the host to remain available continuously on macOS, open the Energy settings in System Settings and enable the option to prevent automatic sleeping when the display is off.

As a temporary solution, you can connect over SSH and run the macOS caffeinate command to prevent sleep.

bash
caffeinate -s &

The -s option prevents system sleep while the computer is connected to AC power.

Security

This private network setup with Tailscale has the following security properties.

  • The web UI is not directly reachable from the public Internet.
  • Access is limited to authorized devices within the tailnet.
  • tailscale serve automatically provides HTTPS.
  • No router port forwarding is required, avoiding the risk of exposing the UI through a misconfigured port-forwarding rule.

I recommend enabling multi-factor authentication (MFA) for your Tailscale account and setting a strong passcode and biometric authentication on the iPhone.

Recovery over SSH

If a problem with Claude Code UI or pm2 prevents browser access, you can connect to the host computer over SSH to recover it. Since Remote Login was configured at the start of the setup instructions, you can connect from a mobile SSH client such as Termius.

Recovery steps

Once you have connected to the host over SSH, follow these steps.

  1. Run pm2 status to check the process status.
  2. If its status is not online, restart it with pm2 restart claude-code-ui.
  3. If the process does not exist at all, register it again.
bash
pm2 start cloudcli --name "claude-code-ui"
pm2 save

If it still does not start after you register it again, check for a port conflict. Specify the port you are using (the default is 3001) to check it.

bash
lsof -i :<ポート番号>

If another process is using the port, identify its PID, stop it if appropriate, and restart Claude Code UI.

Conclusion

This article covered how to control Claude Code on your PC directly from an iPhone, anywhere.

The setup uses tailscale serve to provide private HTTPS access, pm2 to keep Claude Code UI available, and Claude Code hooks to implement ntfy notifications. It combines convenient mobile access with safer operation and can be used with a Mac mini, MacBook, or other suitable computer.

If you want to use your home computer as a personal AI server inside a private network, this is a practical setup worth trying.

I also write articles elsewhere, so feel free to explore them.

References