用于远程访问 OpenCode CLI 的 Discord 机器人
Control your AI coding assistant from anywhere — your phone, tablet, or another computer.
Used by developers worldwide — 2,000+ weekly downloads on npm
New in v1.5! Session management — browse, attach, and manage OpenCode CLI sessions from Discord with
/session. Plus: model autocomplete for/model set. See changelogv1.4: Voice message support — send voice messages that are automatically transcribed and processed. See demo
remote-opencode is a Discord bot that bridges your local OpenCode CLI to Discord, enabling you to interact with your AI coding assistant remotely. Perfect for developers who want to:
flowchart LR
A[" Your Phone / Other Device"] |"Discord API"| B[" Discord Bot"]
subgraph Workflow
direction TB
B --> C[" OpenCode CLI"]
C --> D[" Your Codebase"]
endThe bot runs on your development machine alongside OpenCode. When you send a command via Discord, it's forwarded to OpenCode, and the output streams back to you in real-time.
https://github.com/user-attachments/assets/b6239cb6-234e-41e2-a4d1-d4dd3e86c7b9
https://github.com/user-attachments/assets/59cf162a-ec86-41b5-a1f3-9b1379acd9fd
# Global installation (recommended)
npm install -g remote-opencode
# Or run directly with npx
npx remote-opencodegit clone https://github.com/RoundTable02/remote-opencode.git
cd remote-opencode
npm install
npm run build
npm link # Makes 'remote-opencode' available globally# Step 1: Run the interactive setup wizard
remote-opencode setup
# Step 2: Start the Discord bot
remote-opencode startThat's it! Now use Discord slash commands to interact with OpenCode.
remote-opencode supports HTTP proxy environments for Discord and other external API requests.
Supported environment variables:
HTTP_PROXYHTTPS_PROXYALL_PROXYNO_PROXYProxy settings are applied app-wide. Local OpenCode traffic is kept direct automatically, so localhost, 127.0.0.1, and ::1 are always excluded from proxying.
export HTTPS_PROXY=http://proxy.company.local:8080
export NO_PROXY=internal.company.local
remote-opencode startIf your network uses a single proxy for everything, ALL_PROXY is also supported:
export ALL_PROXY=http://proxy.company.local:8080
remote-opencode startThe setup wizard (remote-opencode setup) guides you through the entire process interactively:
Just run remote-opencode setup and follow the prompts — no manual URL copying needed!
Manual setup reference (click to expand)
If you prefer manual setup or need to troubleshoot:
https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=2147534848&scope=bot+applications.commands| Command | Description |
|---|---|
remote-opencode |
Start the bot (shows setup guide if not configured) |
remote-opencode setup |
Interactive setup wizard — configures bot token, IDs |
remote-opencode start |
Start the Discord bot |
remote-opencode deploy |
Deploy/update slash commands to Discord |
remote-opencode undeploy |
Remove slash commands from Discord |
remote-opencode config |
Display current configuration info |
remote-opencode allow add |
Add a Discord user ID to the allowlist |
remote-opencode allow remove |
Remove a Discord user ID from the allowlist |
remote-opencode allow list |
List all user IDs in the allowlist |
remote-opencode allow reset |
Clear the entire allowlist (removes access control) |
remote-opencode voice set |
Set OpenAI API key for voice message transcription |
remote-opencode voice remove |
Remove the stored OpenAI API key |
remote-opencode voice status |
Show voice transcription status and API key source |
Once the bot is running, use these commands in your Discord server:
/setpath — Register a ProjectRegister a local project path with an alias for easy reference.
/setpath alias:myapp path:/Users/you/projects/my-app| Parameter | Description |
|---|---|
alias |
Short name for the project (e.g., myapp, backend) |
path |
Absolute path to the project on your machine |
/projects — List Registered ProjectsView all registered project paths and their aliases.
/projects/use — Bind Project to ChannelSet which project a Discord channel should interact with.
/use alias:myappAfter binding, all /opencode commands in that channel will work on the specified project.
/opencode — Send Command to AIThe main command — sends a prompt to OpenCode and streams the response.
/opencode prompt:Add a dark mode toggle to the settings pageFeatures:
/work — Create a Git WorktreeStart isolated work on a new branch with its own worktree.
/work branch:feature/dark-mode description:Implement dark mode toggle
/work branch:feature/dark-mode # description defaults to the branch name| Parameter | Description |
|---|---|
branch |
Git branch name (will be sanitized) |
description |
Optional. Defaults to the branch name when omitted. |
Features:
This is perfect for working on multiple features simultaneously without branch switching.
/code — Toggle Passthrough ModeEnable passthrough mode in a thread to send messages directly to OpenCode without slash commands.
/codeHow it works:
/code in any thread to enable passthrough mode/code again to disableExample:
You: /code
Bot: ✅ Passthrough mode enabled for this thread.
Your messages will be sent directly to OpenCode.
You: Add a dark mode toggle to settings
Bot: Prompt: Add a dark mode toggle to settings
[streaming response...]
You: Now add a keyboard shortcut for it
Bot: Prompt: Now add a keyboard shortcut for it
[streaming response...]
You: /code
Bot: ❌ Passthrough mode disabled.Features:
/autowork — Toggle Automatic Worktree CreationEnable automatic worktree creation for a project. When enabled, new /opencode sessions will automatically create isolated git worktrees.
/autoworkHow it works:
/autowork in a channel bound to a projectauto/abc12345-1738600000000Features:
/work with branch names/autocode — Toggle Automatic Passthrough ModeEnable automatic passthrough mode for a project. When enabled, every new thread the bot creates (via /work or /opencode) will already have passthrough mode on, so plain messages are sent to OpenCode without needing to run /code first.
/autocodeHow it works:
/autocode in a channel bound to a project/code stepFeatures:
/code still toggles it within a thread/queue — Manage Message QueueControl the automated job queue for the current thread.
/queue list
/queue clear
/queue pause
/queue resume
/queue settings continue_on_failure:True fresh_context:FalseHow it works:
/opencode multiple times)Settings:
continue_on_failure: If True, the bot moves to the next task even if the curr暂无开放 Issues,或尚未同步最近议题。