A reliable Discord remote-control system for OpenCode. Run the OpenCode agent on your Windows PC and drive it from Discord: send prompts, review diffs, commit and push work, manage sessions and queues, and control the machine — all through slash commands.
- Remote OpenCode control —
/opencodecreates a dedicated thread, runs your prompt through a managed OpenCode server, streams live status, and posts the result. - Thread & session model — every prompt runs in its own Discord thread tied to an OpenCode session. Continue, diff, or reset the context per thread.
- Passthrough / voice mode —
/codeturns a thread into a plain-message pipe to OpenCode;/autocodesets it for whole projects;/voiceadds optional voice-message transcription (Whisper). - Queue — prompts queue when OpenCode is busy;
/queuelets you inspect, pause, resume, clear, or cancel items. - Tasks —
/taskruns long-lived, multi-step OpenCode jobs per project (start / status / stop / cancel), with continuation across multiple prompts. - Git & GitHub —
/diff,/git(status/commit/push/pull/branches/worktrees),/github(PR list/create, repo create/view). Usesghwhen available. - PC control — owner-only
/pc(sleep, restart, shutdown) with a 30-second in-Discord confirmation. - Reliability — automatic OpenCode server start, health checks, restart with back-off, queue persistence (SQLite), and graceful shutdown.
- Security — Discord allowlist (owner always authorized), HTTP-Basic auth to the OpenCode server with a generated password, secret redaction in logs, owner-only destructive commands.
- Windows (primary target) or macOS/Linux
- Node.js 22+
- Git (for
/diff,/git) - OpenCode installed and on
PATH(e.g.npm i -g opencode-ai) - A Discord bot token with these privileges in the Developer Portal:
- Server Members Intent
- Message Content Intent
- Bot invited to your server with
Send Messages,Create Public Threads,Send Messages in Threads,Manage Threads,Read Message History,Add Reactions, andUse Slash Commandspermissions.
npm install -g . # from the project directory
ocr setup # interactive setup wizard
ocr startDevelopment:
npm install
npm run build
npm run dev # tsx: hot start of `ocr start`ocr setup walks through:
- Discord bot token — validated against the Discord API (bot must be invited to your server).
- Server (guild) ID — verified the bot can see the guild.
- Owner — the account that will own the machine (gets full rights).
- Default project directory — used by
/setpathand project discovery. - OpenCode port & host — defaults
127.0.0.1:4096, generated server password. - GitHub & voice options — optional.
Everything is stored in %USERPROFILE%\.opencode-remote\config.json; runtime state lives in data.db (SQLite). Secrets are never displayed again (ocr config redacts them).
| Command | Description |
|---|---|
/opencode <prompt> [project] |
Send a prompt to OpenCode in a new thread. |
/code <mode> |
Set passthrough mode for the current thread (inherit / enabled / disabled). |
/autocode <mode> [apply_to_threads] |
Set passthrough mode for a whole project (threads inherit by default). |
/setpath |
Register a local project by alias (path autocomplete). |
/projects |
List registered projects. |
/use |
Bind this channel to a project. |
/session |
list / new / attach / detach / info / delete / rename sessions. |
/model <model> |
Set the model for the current project (autocomplete from the server). |
/queue |
status / list / clear / remove / pause / resume / settings. |
/task |
Start long-lived OpenCode jobs: start / status / stop / cancel. |
/diff [type] |
Show a git diff of the project. |
/work |
Create a worktree + branch for focused OpenCode work. |
/allow |
Manage the Discord allowlist (owner only). |
/setports <min> <max> |
Restrict the OpenCode port range. |
/voice |
status / enable / disable voice transcription. |
/status |
Overall status (OpenCode, queue, git, memory). |
/doctor |
On-demand diagnostics. |
/git |
status / diff / commit / push / pull / branches / log / worktrees. |
/github |
create-repo / pr / check / auth. |
/files |
Browse files in the bound project. |
/logs [lines] |
Recent bot logs (redacted). |
/memory |
View / add / clear per-project notes included in prompts. |
/remote |
Show the machine's remote-access info (owner only). |
/stop |
Cancel the running OpenCode task. |
/help |
Command reference. |
/pc |
sleep / restart / shutdown (owner only, confirmed in Discord). |
| Command | Description |
|---|---|
ocr setup |
Interactive setup wizard. |
ocr start |
Start the bot (default command). |
ocr stop |
Graceful stop. |
ocr restart |
Restart. |
ocr status |
Show bot, OpenCode, project, and queue status. |
ocr doctor |
Run diagnostics. |
ocr deploy / ocr undeploy |
Register / remove slash commands on the guild. |
ocr config |
Show configuration (values redacted). |
ocr autostart |
Install / remove the Windows scheduled task (run on login). |
ocr update |
Check for updates. |
- Allowlist: only users in the allowlist can control the machine.
/allowand/pcare owner-only, as are destructive PC actions. - Server auth: the app sets
OPENCODE_SERVER_PASSWORDand authenticates to the OpenCode API with HTTP Basic (opencode:<password>). The password is auto-generated during setup. - Log redaction: Discord tokens, API keys, GitHub tokens, Bearer tokens, and passwords are scrubbed from every log line.
- Windows safety: commands are launched as argument arrays (never shell-joined), paths with spaces are supported, and
.cmd/.batnpm shims are resolved and executed throughcmd.exewith fully escaped arguments (no bare shell execution or injection surface).
- Config:
%USERPROFILE%\.opencode-remote\config.json - Database:
%USERPROFILE%\.opencode-remote\data.db - State/diff files:
%USERPROFILE%\.opencode-remote\state\ - Logs:
%USERPROFILE%\.opencode-remote\logs\(rotated, redacted)
- "You are not authorized" — add the user with
/allow add user. - OpenCode not reachable — run
/doctororocr doctor; confirm the server starts withocr start. - Port already in use —
netstat -ano | findstr :4096, then change the port or use/setports. - Commands missing / stale in Discord — run
ocr deployto push the current command definitions (needed after command or option changes; the bot needs theapplications.commandsscope). - "Required option not found" — the deployed command is stale; run
ocr deploy. - Nothing posted to the thread on completion — the result embed should post automatically; if not, check the log for a
Thread message failedline and report it. - Voice transcription —
/voice enablewith an OpenAI API key.
npm install
npm run build # tsc
npm run test # vitest (config, auth, storage, process-arg safety, git, confirmations)
npm run lint # eslintMIT