Common Commands
TUI Slash Commands
| Command | Alias | Description |
|---|---|---|
/init | - | Initialize project with AGENTS.md |
/connect | - | Add or update provider credentials |
/models | - | List and select active models |
/undo | - | Undo last AI-generated changes (uses git snapshots) |
/redo | - | Redo previously undone changes |
/share | - | Create a share link for the current conversation |
/unshare | - | Remove share link and delete remote data |
/compact | /summarize | Compact session context window |
/new | /clear | Start a fresh session |
/sessions | /resume, /continue | List and switch between sessions |
/help | - | Open the help dialog |
/exit | /quit, /q | Exit OpenCode |
/editor | - | Open the current message in an external editor |
/export | - | Export the conversation as Markdown |
/details | - | Toggle display of tool execution details |
/themes | - | List available TUI themes |
/thinking | - | Toggle visibility of model thinking blocks |
CLI Commands
| Command | Description |
|---|---|
opencode | Launch the interactive TUI |
opencode run "prompt" | Run a prompt non-interactively, output to stdout |
opencode serve | Start headless HTTP API server |
opencode web | Start server with web UI |
opencode attach <url> | Connect TUI to a running server |
opencode run --attach <url> "prompt" | Run prompt through server, captures full agent workflow |
opencode connect <provider> | Add provider credentials from CLI |
opencode models [provider] | List available models, optionally filter by provider |
opencode agent list | List defined agents |
opencode auth list | List configured providers and auth status |
opencode plugin <module> | Install or list plugins |
opencode plug <module> | Alias for opencode plugin |
opencode stats | Show usage statistics |
opencode debug | Print system information for troubleshooting |
opencode mcp debug <name> | Run diagnostics on an MCP server |
opencode --version | Print version and exit |
opencode --help | Print help and exit |
opencode --print-logs | Show all log output on stdout |
opencode --log-level <level> | Set minimum log level (error, warn, info, debug, trace) |
TUI Input Shortcuts
| Input | Description |
|---|---|
@ | Activate file reference fuzzy search |
/ | Activate slash command selector |
! | Prefix a line with ! to run as a bash command |
Tab | Switch between primary agents (Build/Plan) |
ctrl+p | Open command palette |
CLI Examples
# Run a quick prompt
opencode run "Write a Python script to sort a list of dictionaries by a key"
# Run in a specific directory
opencode run "Initialize a new Node.js project" --cwd /path/to/project
# Attach to a remote server and run a task
opencode run --attach http://server:4096 "Review the latest commit" --cwd /workspace
# List models from a specific provider
opencode models anthropic
# Install a plugin globally
opencode plugin opencode-helicone-session -g
# Start server on a custom port
opencode serve --port 8080
# Debug an MCP server
opencode mcp debug filesystem