
Moshi with OpenCode
Run OpenCode on your own machine, with whichever model provider you like, and drive it from your phone: permissions that reach your lock screen, AGENTS.md, plan vs build, Chat View, and sessions that survive the subway.
OpenCode is the open-source coding agent that doesn't care whose model you use: Anthropic, OpenAI, Google, open-weight models, or a GLM, Kimi, or MiniMax coding plan, all from one TUI. That independence also makes it a good fit for a phone. You want the agent to run on your own machine with your own keys, and you want to check in on it from wherever you are.
This guide covers what's specific to OpenCode. The Claude Code guide does the full Moshi tour (connections, voice, the diff viewer), and almost all of it applies here unchanged.
Mental model. Moshi is the control surface, not the compute. Your repo, provider API keys, and the opencode process all stay on your host. Moshi is the window into that host, plus the doorbell that rings when OpenCode needs a decision.
OpenCode on mobile: what's possible
OpenCode ships a headless server (opencode serve) and a web UI, and you could expose those to your phone yourself. That route gives you OpenCode's own interface in a mobile browser, but it's yours to secure: the server runs with your user's full shell authority, and the docs recommend setting OPENCODE_SERVER_PASSWORD before you expose it.
The Moshi route keeps OpenCode bound to the host and reaches it over SSH or Mosh instead:
- The real TUI in a terminal on your phone, inside tmux so it survives disconnects.
- Push notifications when OpenCode asks for permission, asks a question, or goes idle.
- Chat View, a native transcript and composer for OpenCode sessions, read from the host through your SSH tunnel.
- The same inbox for Claude Code, Codex, and the rest, if you run more than one agent.
Nothing listens on a public port, and nothing new needs securing.
What you'll learn
- Install the moshi-hook plugin so OpenCode events reach your phone
- Write permission rules that decide what reaches your phone
- Use AGENTS.md and the plan agent to keep phone prompts short
- Answer approvals and questions from the lock screen, the inbox, or Chat View
- Keep sessions alive in tmux and get back to them later
Before you start
Install OpenCode itself from its docs (for example curl -fsSL https://opencode.ai/v2/install | bash or brew install anomalyco/tap/opencode-v2), run opencode once at your desk, and add a provider with /connect.
Set up the host
Install moshi-hook
moshi-hook is a small daemon that installs Moshi's OpenCode plugin, serves a local gateway for diffs and previews, and keeps a connection open to Moshi so events reach your phone. Install it once per host. The pairing token comes from the Moshi app:
$brew tap rjyo/moshi$brew trust rjyo/moshi$brew install moshi-hook$moshi-hook pair --token <token from Moshi>$moshi-hook install$brew services start moshi-hook
$curl -fsSL https://getmoshi.app/install.sh | sh$moshi-hook pair --token <token from Moshi>$moshi-hook install$moshi-hook service install
On Linux, moshi-hook service install runs the daemon as a systemd user service. If your WSL distro has systemd disabled, run moshi-hook serve from your shell startup instead.
For OpenCode, install writes a plugin to ~/.config/opencode/plugins/moshi-hooks.ts (or $OPENCODE_CONFIG_DIR/plugins/). Run moshi-hook install --local --target opencode inside a project to scope it to that repo's .opencode/plugins/ instead. Then restart OpenCode. Plugins load at startup.
OpenCode 2.x runs sessions in one shared background service. The install also adds a small TUI plugin that tells Moshi which session each terminal pane is showing, so Chat View and Stop target the right one. After upgrading moshi-hook, run moshi-hook install --target opencode again and restart both halves: your OpenCode TUIs and opencode service restart.
Run moshi-hook doctor to confirm the daemon, pairing, and OpenCode plugin all show as ready. The full reference is in the hooks doc.
Connect and start OpenCode in tmux
Add the host in Moshi (the Easy Pair QR flow checks prerequisites and saves it for you), preferring an SSH key and the Mosh transport. The session picker's Recent tab lists directories OpenCode recently worked in, so getting back to a project is one tap. Start OpenCode inside a named tmux session:
$moshi ~/projects/app# attach-or-create a tmux session named after the project$opencode
That tmux session lets OpenCode keep working after your phone locks. Herdr works too: it recognizes OpenCode panes and shows whether each one is blocked, working, or done.
Permissions that suit a phone
OpenCode decides per tool whether to allow, ask, or deny, using rules in opencode.json (or opencode.jsonc) in the project, or globally in ~/.config/opencode/. Every ask becomes a push notification once moshi-hook is installed, so these rules set how often your phone buzzes.
A setup that works well remotely is to let read-only commands through, ask for everything else, and deny what you never want done from a phone:
{
"$schema": "https://opencode.ai/config.json",
"permissions": [
{ "action": "shell", "resource": "*", "effect": "ask" },
{ "action": "shell", "resource": "git status *", "effect": "allow" },
{ "action": "shell", "resource": "git diff *", "effect": "allow" },
{ "action": "shell", "resource": "git push *", "effect": "deny" }
]
}
The last matching rule wins, and anything without a rule defaults to ask. This is OpenCode 2.x syntax; 1.x used a permission object with bash keys instead. See OpenCode's permissions docs for your version.
Teach the repo with AGENTS.md
Phone prompts should be short, so put the project context in a file instead of your thumbs. Run /init in OpenCode once at your desk. It scans the repo and writes (or improves) an AGENTS.md with build commands, conventions, and layout. OpenCode also reads an existing CLAUDE.md, so a repo already set up for Claude Code works as-is.
With that in place, "fix the failing auth test and show me the diff" is a complete prompt, and it's quick to dictate with voice.
Plan first, then build
OpenCode ships a plan agent that can read and reason but can't edit your project, alongside the default build agent. Plan is a good fit for phones: ask for a plan from the train, read it in Chat View, then switch to build when you're happy with it. Nothing touches the working tree until you say so.
Answer from wherever you are
With moshi-hook running, OpenCode events land in Moshi's inbox, one row per session:
| OpenCode event | What you get |
|---|---|
| Session starts or gets busy | Session card moves to Working |
| Permission request | Approval card and push notification |
| Question for you | Push notification; answer from Chat View or the terminal |
| Session goes idle | Done, with a Live Activity update on iPhone |
Approve from the notification, the inbox, Chat View, or the TUI itself. All four reach the same session. On iPhone, the active task also appears as a Live Activity and on Apple Watch.
Chat View for OpenCode
Chat View renders the OpenCode session as a native conversation with tool cards and a composer, which is easier to read on a small screen than a TUI. The transcript is read from OpenCode's local server on the host and streamed through your SSH tunnel. It never passes through Moshi's servers. Chat View is experimental, and it needs Pro once the free trial uses run out.
One limit: after OpenCode compacts a session (/compact), the summarized history is no longer available to Chat View. The terminal scrollback still has it.
Long runs and picking sessions back up
- Keep the TUI in tmux. The phone connection can drop; the agent keeps running.
- Switch or resume sessions with
/sessionsin OpenCode (also/resume). - Undo a bad turn with
/undo, which also reverts its file changes (requires a git repo)./redobrings it back.
Run OpenCode next to Claude and Codex
Because the inbox is per session rather than per vendor, an OpenCode session on a GLM coding plan can sit next to Claude Code and Codex on the same host, each in its own tmux window. Moshi's Usages tab also tracks coding-plan quotas OpenCode uses, including Z.ai GLM, MiniMax, and Kimi. The fleet guide covers running several agents at once.
Troubleshooting
No notifications from OpenCode
Restart OpenCode after installing the plugin; it isn't loaded into sessions that were already running. Then run moshi-hook doctor. If it reports the OpenCode plugin as missing or outdated, run moshi-hook install --target opencode on that host and restart OpenCode (and opencode service restart on 2.x).
Chat View shows the wrong session
On OpenCode 2.x, a pane follows the TUI that most recently opened a session, and a TUI sitting on its home screen after /new owns no session until its first prompt. Send a prompt, or reopen the session from /sessions.
My phone buzzes constantly
Add allow rules for the commands you trust (test runners, git status, git diff), or move exploratory work to the plan agent.
FAQ
Is there an OpenCode mobile app?
OpenCode has no native phone app. You can serve its web UI with opencode serve / opencode web and open it in a mobile browser, or use a mobile terminal like Moshi to run the real TUI on your own host over SSH or Mosh, with push notifications and Chat View on top.
Can I approve OpenCode permission requests from my phone?
Yes. With moshi-hook installed, OpenCode's permission requests become approval cards and push notifications in Moshi. The terminal prompt keeps working too, so you can answer wherever is convenient.
Does it work with OpenCode 1.x and 2.x?
Yes. The generated plugin includes entry points for both versions. On 2.x, also restart the shared background service after reinstalling (opencode service restart).
Does my code or API key go through Moshi?
No. OpenCode, your repo, and your provider keys stay on the host. Moshi's server sees only what shows up in a notification or inbox row, such as the event type, project name, approval text, and a short snippet of the prompt and reply, and with end-to-end encryption on it sees even less.