Control your AI coding assistant from anywhere — your phone, tablet, or another computer.
📦 Used by developers worldwide — 1000+ weekly downloads on npm
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:
- 📱 Code from mobile — Send coding tasks from your phone while away from your desk
- 💻 Access from any device — Use your powerful dev machine from a laptop or tablet
- 🌍 Work remotely — Control your home/office workstation from anywhere
- 👥 Collaborate — Share AI coding sessions with team members in Discord
- 🤖 Automated Workflows — Queue up multiple tasks and let the bot process them sequentially
┌─────────────────┐ Discord API ┌─────────────────┐
│ Your Phone / │ ◄──────────────► │ Discord Bot │
│ Other Device │ │ (this project) │
└─────────────────┘ └────────┬────────┘
│
▼
┌─────────────────┐
│ OpenCode CLI │
│ (your machine) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Your Codebase │
└─────────────────┘
The 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.
remote-opencode.mp4
- Installation
- Quick Start
- Discord Bot Setup
- CLI Commands
- Discord Slash Commands
- Usage Workflow
- Access Control
- Configuration
- Troubleshooting
- Development
- Changelog
- License
- Node.js 22+ — Download
- OpenCode CLI — Must be installed and working on your machine
- Discord Account — With a server where you have admin permissions
# 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.
The setup wizard (remote-opencode setup) guides you through the entire process interactively:
- Opens Discord Developer Portal in your browser
- Walks you through creating an application, enabling intents, and getting your bot token
- Generates the invite link automatically and opens it in your browser
- Deploys slash commands to your server
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:
- Create Application: Go to Discord Developer Portal, create a new application
- Enable Intents: In "Bot" section, enable SERVER MEMBERS INTENT and MESSAGE CONTENT INTENT
- Get Bot Token: In "Bot" section, reset/view token and copy it
- Get Guild ID: Enable Developer Mode in Discord settings, right-click your server → Copy Server ID
- Invite Bot: Use this URL format:
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 config |
Display current configuration info |
remote-opencode allow add <userId> |
Add a Discord user ID to the allowlist |
remote-opencode allow remove <userId> |
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) |
Once the bot is running, use these commands in your Discord server:
Register 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 |
View all registered project paths and their aliases.
/projects
Set which project a Discord channel should interact with.
/use alias:myapp
After binding, all /opencode commands in that channel will work on the specified project.
The main command — sends a prompt to OpenCode and streams the response.
/opencode prompt:Add a dark mode toggle to the settings page
Features:
- 🧵 Auto-creates a thread for each conversation
- ⚡ Real-time streaming — see output as it's generated (1-second updates)
- ⏸️ Interrupt button — stop the current task if needed
- 📝 Session persistence — continue conversations in the same thread
Start isolated work on a new branch with its own worktree.
/work branch:feature/dark-mode description:Implement dark mode toggle
| Parameter | Description |
|---|---|
branch |
Git branch name (will be sanitized) |
description |
Brief description of the work |
Features:
- 🌳 Creates a new git worktree for isolated work
- 🧵 Opens a dedicated thread for the task
- 🗑️ Delete button — removes worktree and archives thread
- 🚀 Create PR button — automatically creates a pull request
This is perfect for working on multiple features simultaneously without branch switching.
Enable passthrough mode in a thread to send messages directly to OpenCode without slash commands.
/code
How it works:
- Run
/codein any thread to enable passthrough mode - Type messages naturally — they're sent directly to OpenCode
- Run
/codeagain to disable
Example:
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:
- 📱 Mobile-friendly — no more typing slash commands on phone
- 🧵 Thread-scoped — only affects the specific thread, not the whole channel
- ⏳ Busy indicator — shows ⏳ reaction if previous task is still running
- 🔒 Safe — ignores bot messages (no infinite loops)
Enable automatic worktree creation for a project. When enabled, new /opencode sessions will automatically create isolated git worktrees.
/autowork
How it works:
- Run
/autoworkin a channel bound to a project - The setting toggles on/off for that project
- When enabled, new sessions automatically create worktrees with branch names like
auto/abc12345-1738600000000
Features:
- 🌳 Automatic isolation — each session gets its own branch and worktree
- 📱 Mobile-friendly — no need to type
/workwith branch names - 🗑️ Delete button — removes worktree when done
- 🚀 Create PR button — easily create pull requests from worktree
- ⚡ Per-project setting — enable/disable independently for each project
Control the automated job queue for the current thread.
/queue list
/queue clear
/queue pause
/queue resume
/queue settings continue_on_failure:True fresh_context:True
How it works:
- Send multiple messages to a thread (or use
/opencodemultiple times) - If the bot is busy, it reacts with
📥and adds the task to the queue - Once the current job is done, the bot automatically picks up the next one
Settings:
continue_on_failure: IfTrue, the bot moves to the next task even if the current one fails.fresh_context: IfTrue(default), the AI forgets previous chat history for each new queued task to improve performance, while maintaining the same code state.
Manage the user allowlist directly from Discord. This command is only available when the allowlist has already been initialized (at least one user exists).
/allow action:add user:@username
/allow action:remove user:@username
/allow action:list
| Parameter | Description |
|---|---|
action |
add, remove, or list |
user |
Target user (required for add and remove) |
Behavior:
- Requires authorization — only users already on the allowlist can use this command
- Cannot remove last user — prevents accidental lockout
- Disabled when allowlist is empty — initial setup must be done via CLI or setup wizard (see Access Control)
-
Register your project:
/setpath alias:webapp path:/home/user/my-webapp -
Bind to a channel:
/use alias:webapp -
Start coding remotely:
/opencode prompt:Refactor the authentication module to use JWT -
Continue the conversation in the created thread:
/opencode prompt:Now add refresh token support
Perfect for when you're away from your desk:
- 📱 Open Discord on your phone
- Navigate to your bound channel
- Use
/opencodeto send tasks - Watch real-time progress
- Use the Interrupt button if needed
Pro tip: Enable passthrough mode with /code in a thread for an even smoother mobile experience — just type messages directly without slash commands!
Share AI coding sessions with your team:
- Create a dedicated Discord channel for your project
- Bind the project:
/use alias:team-project - Team members can watch sessions in real-time
- Discuss in threads while AI works
Perfect for "setting and forgetting" several tasks:
-
Send multiple instructions:
You: Refactor the API Bot: [Starts working] You: Add documentation to the new methods Bot: 📥 [Queued] You: Run tests and fix any issues Bot: 📥 [Queued] -
The bot will finish the API refactor, then automatically start the documentation task, then run the tests.
-
Monitor progress: Use
/queue listto see pending tasks.
remote-opencode supports an optional user allowlist to restrict who can interact with the bot. This is essential when your bot runs in a shared Discord server where untrusted users could otherwise execute commands on your machine.
- No allowlist configured (default): All Discord users in the server can use the bot. This preserves backward compatibility for existing installations.
- Allowlist configured (1+ user IDs): Only users whose Discord IDs are in the allowlist can use slash commands, buttons, and passthrough messages. Unauthorized users receive a rejection message.
⚠️ SECURITY WARNING: If your bot operates in a Discord channel accessible to untrusted users, you MUST configure the allowlist before starting the bot. The initial allowlist setup can ONLY be done via the CLI or the setup wizard — NOT from Discord. This prevents unauthorized users from adding themselves to an empty allowlist.
remote-opencode setupStep 5 of the wizard prompts you to enter your Discord user ID. This becomes the first entry in the allowlist.
# Add your Discord user ID
remote-opencode allow add 123456789012345678
# Verify
remote-opencode allow listOnce at least one user is on the allowlist, authorized users can manage it from Discord:
/allow action:add user:@teammate
/allow action:remove user:@teammate
/allow action:list
Or via CLI at any time:
remote-opencode allow add <userId>
remote-opencode allow remove <userId>
remote-opencode allow list
remote-opencode allow reset # Clears entire allowlist (disables access control)- Cannot remove the last user via Discord
/allowor CLIallow remove— prevents accidental lockout allow resetis the only way to fully clear the allowlist (intentional action to disable access control)- Discord
/allowis disabled when allowlist is empty — prevents bootstrap attacks - Config file permissions are set to
0o600(owner-read/write only)
All configuration is stored in ~/.remote-opencode/:
| File | Purpose |
|---|---|
config.json |
Bot credentials (token, client ID, guild ID) |
data.json |
Project paths, channel bindings, session data |
{
"discordToken": "your-bot-token",
"clientId": "your-application-id",
"guildId": "your-server-id",
"allowedUserIds": ["123456789012345678"]
}
allowedUserIdsis optional. When omitted or empty, access control is disabled and all users can use the bot.
{
"projects": [
{ "alias": "myapp", "path": "/Users/you/projects/my-app", "autoWorktree": true }
],
"bindings": [
{ "channelId": "channel-id", "projectAlias": "myapp" }
],
"threadSessions": [ ... ],
"worktreeMappings": [ ... ]
}| Field | Description |
|---|---|
projects[].autoWorktree |
Optional. When true, new sessions auto-create worktrees |
- Check bot is online: Look for the bot in your server's member list
- Verify permissions: Bot needs these permissions:
- Send Messages
- Create Public Threads
- Send Messages in Threads
- Embed Links
- Read Message History
- Redeploy commands:
remote-opencode deploy
You need to bind a project to the channel:
/setpath alias:myproject path:/path/to/project
/use alias:myproject
Slash commands can take up to an hour to propagate globally. For faster updates:
- Kick the bot from your server
- Re-invite it
- Run
remote-opencode deploy
- Verify OpenCode is installed:
opencode --version
- Check if another process is using the port
- Ensure the project path exists and is accessible
The bot maintains persistent sessions. If you encounter issues:
- Start a new thread with
/opencodeinstead of continuing in an old one - Restart the bot:
remote-opencode start
- Check Node.js version:
node --version # Should be 22+ - Verify configuration:
remote-opencode config
- Re-run setup:
remote-opencode setup
git clone https://github.com/RoundTable02/remote-opencode.git
cd remote-opencode
npm install
# Development mode (with ts-node)
npm run dev setup # Run setup
npm run dev start # Start bot
# Build and run production
npm run build
npm startnpm testsrc/
├── cli.ts # CLI entry point
├── bot.ts # Discord client initialization
├── commands/ # Slash command definitions
│ ├── opencode.ts # Main AI interaction command
│ ├── code.ts # Passthrough mode toggle
│ ├── work.ts # Worktree management
│ ├── allow.ts # Allowlist management
│ ├── setpath.ts # Project registration
│ ├── projects.ts # List projects
│ └── use.ts # Channel binding
├── handlers/ # Interaction handlers
│ ├── interactionHandler.ts
│ ├── buttonHandler.ts
│ └── messageHandler.ts # Passthrough message handling
├── services/ # Core business logic
│ ├── serveManager.ts # OpenCode process management
│ ├── sessionManager.ts # Session state management
│ ├── queueManager.ts # Automated job queuing
│ ├── executionService.ts # Core prompt execution logic
│ ├── sseClient.ts # Real-time event streaming
│ ├── dataStore.ts # Persistent storage
│ ├── configStore.ts # Bot configuration
│ └── worktreeManager.ts # Git worktree operations
├── setup/ # Setup wizard
│ ├── wizard.ts # Interactive setup
│ └── deploy.ts # Command deployment
└── utils/ # Utilities
├── messageFormatter.ts
└── threadHelper.ts
See CHANGELOG.md for a full history of changes.
- Owner/Admin Authentication: User allowlist system to restrict bot access to authorized Discord users only.
/allowSlash Command: Manage the allowlist directly from Discord (add, remove, list users).- CLI Allowlist Management:
remote-opencode allow add|remove|list|resetcommands for managing access control from the terminal. - Setup Wizard Integration: Step 5 prompts for owner Discord user ID during initial setup.
- Initial allowlist setup is restricted to CLI and setup wizard only — prevents bootstrap attacks from Discord.
- Config file permissions hardened to
0o600(owner-read/write only). - Discord user ID validation enforces snowflake format (
/^\d{17,20}$/). - Cannot remove the last authorized user via Discord or CLI
remove— prevents lockout.
- Automated Message Queuing: Added a new system to queue multiple prompts in a thread. If the bot is busy, new messages are automatically queued and processed sequentially.
- Queue Management: New
/queueslash command suite to list, clear, pause, resume, and configure queue settings.
- New
/setportsslash command to configure the port range for OpenCode server instances.
- Fixed Windows-specific spawning issue (targeting
opencode.cmd). - Resolved
spawn EINVALerrors on Windows. - Improved server reliability and suppressed
DEP0190security warnings.
- New
/modelslash command to set AI models per channel. - Support for
--modelflag in OpenCode server instances.
- Fixed connection timeout issues.
- Standardized internal communication to use
127.0.0.1.
MIT
Contributions are welcome! Please read our Contributing Guide before submitting a Pull Request.
