Working with AI on Mobile Phone
A practical guide to remote AI agents, mobile terminal workflows, SSH tunneling, and running small language models directly on your phone.
Introduction
Your phone is the most powerful computer you carry every day. Modern flagship phones pack 12-16 GB of RAM, neural processing units (NPUs) capable of trillions of operations per second, and always-on connectivity. Yet most developers treat them as consumption devices. This guide changes that.
Whether you want to supervise an AI coding agent on your commute, run a small language model fully offline on your phone, or pipe data from mobile apps directly into your remote development workflow, there is a mature ecosystem of tools waiting for you. This page covers five distinct patterns for working with AI from a mobile device, from SSH terminal setups to on-device SLM inference using Google AI Edge Gallery.
1. The Mobile Terminal Architecture
The foundation of any mobile AI workflow is a reliable terminal connection to a remote machine with real GPU or CPU power. Here is how to build that pipeline from scratch.
The Mobile Shell Environment
Android (Termux): Termux is the gold standard for Android terminals. It provides a Linux environment without root, with access to apt package management, Python, Node.js, SSH, and even GPU compute via OpenCL. Install it from F-Droid (the Play Store version is outdated). Pair it with Acode for a full code editor with syntax highlighting, file tree, and built-in terminal.
iOS (iSH / Blink Shell): iSH provides an Alpine Linux environment that runs as a usermode x86 emulator on iOS. It is slower than native but sufficient for SSH, git, and scripting. For a more polished experience, Blink Shell is a native terminal with built-in SSH key management, Mosh support, and a local AI copilot feature. It supports multiple sessions, split panes, and even GPU-accelerated rendering via Metal.
SSH Keys on Mobile: Generate ed25519 keys directly in Termux (ssh-keygen -t ed25519) or use Blink Shell's built-in key manager. Copy public keys to your remote server's ~/.ssh/authorized_keys. For extra security, encrypt your private key with a passphrase and use ssh-agent with ssh-add -L to verify loaded keys.
Persistent Mobile Sessions with tmux / screen
Cellular signals drop. Trains enter tunnels. You lock your phone. Without a session manager, a single disconnection kills your long-running script, model inference, or agent loop. tmux solves this. Start a session with tmux new -s ai-work, detach with Ctrl+B d, and reconnect later with tmux attach -t ai-work. Your processes survive disconnections, roam across network changes, and persist even if the terminal app is killed. For power users, configure tmux with mouse mode and 256-color support for a more visual experience on mobile.
The Mobile-to-Host Pipeline: Reverse Tunnels
Your remote machine may be behind a NAT, a VPN, or a corporate firewall. To reach it from your phone, you need a reverse tunnel:
- Tailscale - The simplest option. Install Tailscale on both your phone and server. They join the same tailnet, and you get a private IP (100.x.x.x) with WireGuard encryption. No port forwarding needed. SSH directly to the Tailscale IP from your mobile terminal.
- Cloudflare Tunnel (cloudflared) - Run
cloudflared tunnelon your server to expose SSH or a web UI through Cloudflare's edge. Your phone connects via cloudflared access or the public hostname. Great for HTTP-based tools like Open WebUI or Jupyter. - ngrok - Quickest for ad-hoc access. Run
ngrok tcp 22on the server to get a public TCP endpoint. Use it for short sessions, but be aware of bandwidth limits on the free tier.
2. Remote Control AI Agents
The most practical mobile AI workflow is controlling a remote coding agent from your phone. You do not need to run models locally -- you just need a solid SSH connection to where the models run.
OpenCode Headless Mode
OpenCode can run in headless server mode with opencode go --port 8080 on your remote workstation. This exposes an OpenAI-compatible API that you can call from mobile shell scripts, or you can connect the OpenCode Mobile app (available for iOS and Android) to manage the entire agentic loop. The mobile app provides real-time streaming of file diffs, terminal output, and approval buttons for shell tool calls. You can review a diff, approve a git commit, or reject a destructive command -- all from your phone screen.
Supervising Agents on the Commute
The killer use case for mobile AI is asynchronous supervision. Start a complex refactoring task on your desktop, then walk away. The agent continues working on your remote machine. From your phone, you can:
- SSH in with tmux to check real-time progress
- Review streaming diffs as the agent writes code
- Approve or deny shell commands via touch inputs in OpenCode Mobile
- Copy error output from the mobile terminal, paste it into a note, and feed it back as a new prompt
- Use
/compressremotely to manage context window on long-running sessions
Terminal-Bound Coding Agents
For a lighter setup, run Claude Code, OpenCode CLI, or Roo Code over a plain SSH session. Termux and Blink Shell support full terminal escape sequences, so agent output with syntax-highlighted diffs, progress bars, and colored output renders correctly on mobile. Keep sessions alive with tmux, and use opencode -r SESSION_ID to resume specific conversations.
3. High-Throughput Remote Prompting
The Claude Mobile Power-User Setup
Anthropic's mobile app supports project knowledge bases, custom instructions, and context caching. For power users on the go: pre-load your project's architecture docs and coding conventions as project knowledge, then paste code snippets or error logs directly into the mobile interface. Use voice input (iOS dictation) for rapid prototyping of prompts while walking or commuting. The mobile app also supports image uploads -- snap a whiteboard, a buggy UI, or handwritten notes and let Claude analyze them.
Raw API Clients: Bypassing Web Wrappers
For maximum throughput, skip the app entirely and call LLM APIs directly from your mobile terminal. A single curl wrapper in Termux or iSH can hit OpenAI, Anthropic, or OpenRouter APIs:
#!/bin/bash
# ~/bin/ask - simple API caller from mobile
curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "'"$*"'"}]
}' | jq -r '.choices[0].message.content'
Pair this with Acode's built-in terminal or Blink's editor to write prompts in a file, then pipe them into the API. For complex multi-turn sessions, use NotebookLM or AnythingLLM running on your server and access them through a reverse tunnel web interface.
Code Review on the Go
Mobile code review is surprisingly viable with the right workflow. Use git on your phone (via Termux or Working Copy on iOS) to fetch the latest PR branch, pipe the diff into Claude or GPT via the API, and get a structured review back. The mobile clipboard becomes your most powerful tool: copy a database migration schema from a Slack message, inject it into Claude's mobile app, and get a refactored migration in seconds. For larger reviews, SSH into the server, run git diff main...HEAD, capture the output to a file, and feed it to the agent.
4. Native Local Sandbox: On-Device SLMs
The most private way to work with AI on mobile is to run models entirely on-device. Modern phone hardware (Apple A17+/M-series, Snapdragon 8 Gen 3, MediaTek Dimensity 9300) includes dedicated NPUs that can run small language models (SLMs) at usable speeds with no internet connection.
Google AI Edge Gallery
Google's AI Edge Gallery (available on Android) provides a curated runtime for running open-source SLMs directly on-device using the Google AI Edge API. It supports models from the Gemma family, including Gemma 4, optimized for mobile NPUs. The runtime handles model download, quantization, and hardware acceleration automatically. You get:
- 100% offline inference - No data leaves your device. Models run via XNNPACK or GPU Delegate on the NPU.
- Function-tuned models (FunctionGemma) - These models can trigger local OS actions: read a file, set an alarm, compose a message, or execute a shell command in Termux -- all without cloud dependencies.
- Local multimodal scribing - The "Ask Image" feature runs OCR and visual Q&A entirely on-device. "Audio Scribe" provides private voice-to-text transcription using the phone's microphone and local NPU inference.
Running Models via MLX, MNN, and ExecuTorch
Beyond Edge Gallery, several frameworks bring local models to mobile:
- MLX (Apple Silicon) - Apple's MLX framework runs on iPhone and iPad via the ANE (Apple Neural Engine). Models like Gemma 4, Phi-3, and Llama 3.2 1B run at 30-50 tokens/second on an iPhone 15 Pro.
- MNN (Alibaba) - Alibaba's mobile inference engine powers Qwen models on Android and iOS. Includes NPU acceleration for Qualcomm and MediaTek chips.
- ExecuTorch (Meta) - Meta's on-device inference runtime supports Llama 3.2 1B/3B on mobile with quantization and custom operators. Integrates with Android NNAPI and iOS CoreML.
- llama.cpp via Termux - For Android users who want full control, compile llama.cpp in Termux with OpenBLAS support. Run GGUF-quantized models (Qwen 0.5B, Gemma 2B, Phi-3 Mini) at interactive speeds on flagship chips.
Agent Skills and Mobile Actions
FunctionGemma and similar function-tuned SLMs unlock agentic workflows on mobile without cloud connectivity. A model running on your phone can:
- Trigger Tasker profiles on Android for automation routines
- Read and summarize notification content privately
- Process screenshots with local OCR to extract text and URLs
- Transcribe meeting audio in real-time with no data leaving the device
- Route structured data (JSON, CSV) from mobile sensors or apps into a remote agent pipeline
5. Mobile Data and Context Injection
The missing link in most mobile AI workflows is getting data from standard phone apps into your agent's context. Here is how to bridge that gap.
The Mobile Clipboard Engine
The system clipboard is the universal bridge. Copy a JSON error from a browser's console, switch to Termux, and paste it into a curl command that sends it to your agent. Copy a SQL query from a notes app and pipe it directly into a remote database via SSH. The workflow is: copy in any app, paste in terminal. This works on both Android (shared clipboard between apps) and iOS (Universal Clipboard between devices).
Automating Context Retrieval
For recurring workflows, automate the data pipeline:
- Tasker (Android) - Create profiles that watch for specific triggers (a notification from your monitoring app, a screenshot of a bug) and automatically format and transmit the data via SSH or HTTP to your remote agent. Example: screenshot an error -> Tasker runs OCR on the image -> extracts text -> sends it as a prompt to your agent API.
- Shortcuts (iOS) - Build shortcuts that grab the current Safari URL and page text, format it into a markdown block, and copy it to the clipboard ready for pasting into Claude or GPT. Another shortcut could capture a voice memo, transcribe it via Whisper (running on a remote server), and return the text.
- Remote Clipboard Sync - Use a tool like
clipboard-syncover Tailscale to share clipboard contents between your phone and desktop. Copy a git diff on your desktop, paste it into Claude on your phone. Reverse the pipeline to copy an AI-generated code snippet from your phone directly into your desktop editor.
Structured Data Injection
Raw logs, SQL output, JSON payloads -- these are the lifeblood of debugging. On mobile, capture them efficiently:
- Use Termux:API (Android) to access the phone's clipboard, sensors, camera, and notifications directly from shell scripts.
termux-clipboard-getreads the current clipboard;termux-notification-listdumps recent notifications as JSON. - Pipe structured data into
jqfor formatting, then inject it into an agent prompt:termux-clipboard-get | jq . | ssh server "cat > /tmp/input.json && opencode 'analyze this data'" - For iOS, use a-Shell or Blink with Python scripts that read the pasteboard via
pbpasteequivalents, format the data, and pipe it to your remote agent or API.
Tying It All Together: A Day in the Life
Here is what a practical mobile AI workflow looks like for a developer:
- Morning commute: Open Blink Shell on iOS. SSH into your home server via Tailscale. Reattach a tmux session where an OpenCode agent has been running overnight. Review the diffs, approve the refactoring, and start a new task (add unit tests to the new module).
- Mid-day alert: Your monitoring app sends a push notification about a production error. Tap it. Tasker captures the notification, runs a script that SSHs into the server, greps the logs for the error pattern, and sends the context to your mobile Claude app.
- Lunch break: Open the AI Edge Gallery. Snap a photo of a whiteboard sketch. The on-device Gemma model reads the handwritten notes, extracts action items, and saves them to your notes app -- all offline.
- Afternoon review: A colleague sends a PR link on Slack. Copy the URL. Your Shortcuts automation fetches the diff via the GitHub API, injects it into a mobile Claude session, and returns a structured review with suggested changes.
- Evening: On the train home, open Termux. Run a Qwen 0.5B model locally via llama.cpp GGUF for some offline experimentation. Later, reconnect to the home server to check on the unit tests the agent wrote during the day.