OpenCode CLI reference - Slash commands
OpenCode slash commands
OpenCode documents 15 slash commands, including /connect, /compact and /details. You type these inside an interactive OpenCode session. Each row gives the docs' description, accepted values and an example where one is documented.
Last verified 1 official pageFull OpenCode reference
| Command | Description | Example |
|---|---|---|
/connect | Adds a provider to OpenCode by selecting from available providers and adding their API keys. Docs: /connect | /connect |
/compact | Compacts the current session. Alias: /summarize. Keybind: ctrl+x c Docs: /compact | /compact |
/details | Toggles tool execution details. Docs: /details | /details |
/editor | Opens an external editor (from EDITOR) for composing messages. Keybind: ctrl+x e Docs: /editor | /editor |
/exit | Exits OpenCode. Aliases: /quit, /q. Keybind: ctrl+x q Docs: /exit | /exit |
/export | Exports the current conversation to Markdown and opens it in the editor set in EDITOR. Keybind: ctrl+x x Docs: /export | /export |
/help | Shows the help dialog. Docs: /help | /help |
/init | Guided setup for creating or updating AGENTS.md; scans the repo and may ask targeted questions. Docs: /init | /init |
/models | Lists available models. Keybind: ctrl+x m Docs: /models | /models |
/new | Starts a new session. Alias: /clear. Keybind: ctrl+x n Docs: /new | /new |
/redo | Redoes a previously undone message, restoring file changes; only available after /undo and requires a Git repository. Keybind: ctrl+x r Docs: /redo | /redo |
/sessions | Lists and switches between sessions. Aliases: /resume, /continue. Keybind: ctrl+x l Docs: /sessions | /sessions |
/themes | Lists available themes. Keybind: ctrl+x t Docs: /themes | /themes |
/thinking | Toggles visibility of thinking/reasoning blocks; does not change the model's reasoning (use ctrl+t to cycle variants). Docs: /thinking | /thinking |
/undo | Undoes the last message, removing the latest user message, subsequent responses and file changes; requires a Git repository. Keybind: ctrl+x u Docs: /undo | /undo |
The rest of the OpenCode reference
FAQ
How many slash commands does OpenCode have?
The official OpenCode docs list 15 slash commands, including /connect, /compact and /details. All of them are in the table above, in the docs' order.
What does /connect do in OpenCode?
Adds a provider to OpenCode by selecting from available providers and adding their API keys.
Where are OpenCode slash commands documented?
On 1 official docs page at opencode.ai, last read on October 17, 2026. Every row in the table links the exact section it came from.
More on OpenCode
- OpenCode in the tools directoryWhat it is, who makes it and how it fits next to other coding agents.
- OpenCode errors and fixes17 error messages, quoted verbatim, with the documented fix for each.
Use other models in OpenCode
Setup guides from the model-in-tool directory, each with the env vars and base URL from official docs.
Sources
Last verified . Names and examples are copied verbatim from the official page below, and every row above links the exact section it came from.
- opencode.ai/docs/tui/15 items
Newsletter
Know when your tools change
One email per week. New coding agent releases, the flags and commands they add, and what they mean for how you work.