CLI commands
Stable commands documented for launch, automation, sessions, MCP, providers, servers, and maintenance.
A practical map of OpenCode's complete command surface: documented CLI commands, interactive TUI actions, advanced dev-source features, and dynamic commands supplied by Skills, MCP, project configuration, and plugins.
$ opencode
Interactive coding agent ready.
› /models
› /skills
› /review
Docs and current dev source are labeled separately.
The essential mental model
A single help screen cannot show the entire surface. The installed TUI also merges commands discovered from the current project and connected systems.
Stable commands documented for launch, automation, sessions, MCP, providers, servers, and maintenance.
Slash commands and terminal actions available after OpenCode starts.
Advanced or newly added commands present on the dev branch but not always documented as stable.
Commands assembled at runtime from project config, Skills, MCP prompts, and installed extensions.
Complete overview
The tree combines the documented CLI with commands registered by the current dev entrypoint. Source-only and internal commands can change before a stable release.
opencode [project]
├── agent
│ ├── create
│ └── list
├── attach [url]
├── providers # alias: auth
│ ├── list / ls
│ ├── login [url]
│ └── logout [provider]
├── github
│ ├── install
│ └── run
├── mcp
│ ├── add
│ ├── list / ls
│ ├── auth [name]
│ ├── logout [name]
│ └── debug <name>
├── models [provider]
├── run [message...]
├── serve
├── session
│ ├── list
│ └── delete <sessionID>
├── stats
├── export [sessionID]
├── import <file>
├── web
├── acp
├── uninstall
├── upgrade [target]
├── completion
├── generate # advanced
├── pr <number> # dev source
├── plugin <module> # alias: plug
├── db [query]
│ └── path
├── console # hidden / internal
│ ├── login [url]
│ ├── logout [email]
│ ├── switch
│ ├── orgs
│ └── open
└── debug
├── config ├── lsp ├── rg
├── file ├── scrap ├── skill
├── snapshot ├── startup ├── agent
├── v2 ├── info ├── paths
└── waitQuick start
These six cover interactive work, automation, continuation, server reuse, Skills, and MCP diagnostics.
Open the TUI
opencodeStart an interactive OpenCode session in the current directory.
One-shot automation
opencode run "Fix the failing tests"Run a non-interactive task from a terminal, script, or CI job.
Continue a session
opencode run -c "Continue the implementation"Continue the most recent session without reopening the full TUI.
Reuse a backend
opencode run --attach http://localhost:4096 "Review this repo"Attach automation to a running server and avoid repeated startup costs.
Inspect loaded Skills
opencode debug skillConfirm which Skills OpenCode discovered for the current project.
Debug an MCP server
opencode mcp debug githubTroubleshoot an MCP connection, OAuth flow, or transport problem.
CLI reference
Use the badges to distinguish public documentation from capabilities currently visible only in the dev source.
Start the TUI, run headless tasks, or separate the OpenCode client from its backend.
opencode [project]Start the TUI in the current directory or a project path.
opencode run [message...]Run OpenCode non-interactively for scripts, CI, or one-shot tasks.
opencode serveStart a headless HTTP server for API access.
opencode attach [url]Attach the TUI to an existing OpenCode server.
opencode webStart the OpenCode server with its web interface.
opencode acpRun the Agent Client Protocol server for editor and client integrations.
Connect model providers, inspect model identifiers, and manage reusable agents.
opencode providers listAliases: auth list, providers ls, auth ls
List configured credentials and provider environment variables.
opencode providers login [url]Aliases: auth login
Add provider credentials or authenticate through a provider URL.
opencode providers logout [provider]Aliases: auth logout
Remove stored provider credentials.
opencode models [provider]List available models, optionally filtered by provider.
opencode models --refreshRefresh the cached catalog from models.dev.
opencode agent createCreate an agent configuration interactively or with source-supported flags.
opencode agent listList the available agents.
Connect external tools and move from issues or pull requests into an agent workflow.
opencode mcp addAdd an MCP server through the interactive setup.
opencode mcp listAliases: mcp ls
List configured MCP servers and connection state.
opencode mcp auth [name]Run OAuth for an MCP server or inspect MCP auth status.
opencode mcp logout [name]Remove OAuth credentials for an MCP server.
opencode mcp debug <name>Print detailed MCP connection and OAuth diagnostics.
opencode github installInstall the OpenCode GitHub integration.
opencode github runRun the GitHub integration for an event payload.
opencode pr <number>Fetch or check out a GitHub pull request and enter an OpenCode workflow.
Inspect history, move sessions between installations, and query local OpenCode data.
opencode session listList sessions as a table or JSON.
opencode session delete <sessionID>Delete a stored session by ID.
opencode export [sessionID]Export a session as JSON; prompts for a session when no ID is provided.
opencode import <file>Import an exported session file or supported share URL.
opencode statsShow token, cost, tool, model, and project usage statistics.
opencode db [query]Open sqlite3 or execute a SQL query against the local OpenCode database.
opencode db pathPrint the path to the local OpenCode database.
Install OpenCode extensions, update the CLI, or use development-oriented generators.
opencode plugin <module>Aliases: plug <module>
Install a plugin package and update local or global configuration.
opencode completionGenerate shell completion output.
opencode upgrade [target]Upgrade OpenCode, optionally to a selected version.
opencode uninstallRemove OpenCode, with options to preserve config or data.
opencode generateGenerate the OpenAPI specification for development workflows.
Deep inspection tools for configuration, LSP, file search, Skills, snapshots, and local paths.
opencode debug configPrint the final resolved OpenCode configuration.
opencode debug lsp ...Inspect diagnostics, workspace symbols, and document symbols.
opencode debug rg ...Use OpenCode's internal ripgrep-backed file and text search.
opencode debug file ...Search, read, or list files through OpenCode's file layer.
opencode debug skillList Skills discovered by the current OpenCode instance.
opencode debug snapshot ...Track, patch, or diff internal snapshots.
opencode debug startupInspect startup timing and initialization behavior.
opencode debug infoShow version, OS, terminal, and plugin information.
opencode debug pathsPrint data, config, cache, and state paths.
opencode console ...Hidden account and organization console commands; not a stable public API.
Important options
Startup flags control the interactive client. Run flags are designed for scripts, CI, attached servers, and repeatable automation.
--continue, -cDocsContinue the latest session.
--session, -s <id>DocsContinue a specific session.
--forkDocsFork the continued session; requires --continue or --session.
--prompt <text>DocsSend an initial prompt when the TUI starts.
--model, -m <provider/model>DocsSelect the starting model.
--agent <name>DocsSelect the starting agent.
--autoDev sourceAuto-approve permissions that are not explicitly denied.
--miniDev sourceStart the minimal interactive interface.
--no-replayDev sourceDisable mini-session history replay.
--replay-limit <number>Dev sourceLimit visible replay to the newest N messages in mini mode.
--pureDev sourceRun without external plugins.
--port / --hostname / --mdns / --corsDocsExpose or configure the TUI's backend server transport.
--print-logs / --log-levelDocsDEBUG | INFO | WARN | ERROR
Print logs and choose their verbosity.
--command <name>DocsRun a named OpenCode command and pass the message as its arguments.
--continue, -cDocsContinue the latest session.
--session, -s <id>DocsContinue a specific session.
--forkDocsFork the session being continued.
--shareDocsShare the created or continued session.
--model, -m <provider/model>DocsChoose the model for this run.
--agent <name>DocsChoose the agent for this run.
--file, -f <path>DocsAttach one or more files to the message.
--format <default|json>DocsUse formatted output or raw JSON events.
--title [text]DocsSet a session title, or derive one from the prompt.
--attach <url>DocsConnect to an already running OpenCode server.
--username, -u / --password, -pDocsSupply basic-auth credentials for an attached server.
--dir <path>DocsSet the local working directory or remote directory when attaching.
--variant <name>DocsChoose a provider-specific model variant or reasoning effort.
--thinkingDocsShow thinking blocks in command output when available.
--autoDocsAuto-approve permissions that are not explicitly denied.
--port <number>DocsSet the local server port instead of using a random one.
It auto-approves permissions that are not explicitly denied. Review project configuration and avoid using it in untrusted repositories unless the surrounding environment provides appropriate isolation.
Interactive TUI
Type / in the prompt to see the exact list for your installed version, current project, connected MCP servers, and discovered Skills.
Create, switch, share, rename, fork, compact, and navigate sessions without leaving the TUI.
/sessionsAliases: /resume, /continue
List and switch sessions.
/newAliases: /clear
Start a new session.
/shareShare the current session or copy its existing share URL.
/unshareDisable sharing for the current session.
/renameRename the current session.
/timelineJump to a specific message in the session timeline.
/forkFork the current session from a selected point.
/compactAliases: /summarize
Summarize old context and free context-window space.
/undoUndo the latest interaction and its file changes.
/redoRestore a previously undone interaction and file changes.
/copyCopy the current session transcript.
/exportExport the conversation to Markdown through your configured editor.
Control what the terminal interface shows and how you move through the current conversation.
/timestampsAliases: /toggle-timestamps
Show or hide message timestamps.
/thinkingAliases: /toggle-thinking
Expand or collapse visible thinking blocks; it does not enable reasoning by itself.
/detailsToggle tool execution details in versions that expose the documented command.
/editorOpen the configured $EDITOR to compose a longer prompt.
/themesOpen the theme selector.
/helpOpen TUI help for the installed version.
/exitAliases: /quit, /q
Exit OpenCode.
Switch the active model or agent and control connected providers, MCP servers, and Skills.
/modelsAliases: /mo
Open the model selector.
/agentsSwitch the active agent.
/variantsSelect a model variant when the current model provides variants.
/mcpsToggle MCP servers for the current TUI session.
/connectAdd or connect a model provider.
/skillsOpen the Skill selector and insert a selected Skill command.
/statusShow current OpenCode status.
/debugOpen the TUI debug-information dialog.
Prompt commands come from the shared registry; workspace and organization commands appear only when their conditions are met.
/initRun guided AGENTS.md setup for the current project.
/review [commit|branch|pr]Review a target, defaulting to uncommitted changes.
/workspacesManage experimental workspaces.
/warpChange the workspace used by the current session.
/moveMove the session to another project directory.
/orgAliases: /orgs, /switch-org
Switch organizations when more than one organization is available.
@src/app.tsType @ to fuzzy-search files and add their contents to the conversation.
!npm testStart the prompt with ! to execute a shell command and add its output to the session.
exit · quit · :qThe current prompt handler also recognizes these direct exit forms without a leading slash.
No fixed command count
Built-in commands are only the starting point. OpenCode combines project commands, global commands, Skills, and MCP prompts at runtime.
Markdown files in .opencode/commands/ or ~/.config/opencode/commands/ become reusable slash commands.
.opencode/commands/test.md
→ /testSkills are merged into the command registry when their names do not collide with an existing command.
frontend-design
→ /frontend-designPrompts exposed by connected MCP servers can appear as slash commands with positional argument hints.
review_pr
→ /review_pr 123Plugins can extend OpenCode behavior and TUI actions, so two installations may not expose the same surface.
opencode plugin <module>$ARGUMENTS · $1 · $2Pass the complete argument string or address parsed positional arguments.
!`git log --oneline -10`Run a shell command and inject its output into the command prompt.
@src/auth.tsInclude a project file in the generated prompt context.
Practical combinations
The highest-value patterns combine CLI automation with session continuity, a reusable server, and in-TUI project commands.
Open the repository and let OpenCode create or update its project instructions.
cd project
opencode
# In the TUI:
/initChoose an agent and run a task without opening the interactive interface.
opencode run --agent build \
"Implement the feature described in issue.md"Use JSON output when another script or CI step needs to consume the run.
opencode run --format json \
"Review the repository for TypeScript errors"Start one backend, then attach runs or another terminal to it.
opencode serve --port 4096
opencode run --attach http://localhost:4096 \
"Explain the authentication flow"Inspect resolved config, paths, Skills, and a problematic MCP server.
opencode debug config
opencode debug paths
opencode debug skill
opencode mcp debug <name>Launch without external plugins to determine whether a plugin causes startup failure.
opencode --pureOpenCode changes quickly. Use the installed binary and TUI autocomplete as the final authority for your machine.
opencode --helpopencode run --helpopencode debug --helpopencode providers --helpopencode db --help/help/Sources and version notes
This page is an English quick reference, not a promise that every dev-source command ships in the latest stable package. Check local --help output before automating source-only features.
Docs and dev can diverge briefly. A Dev source badge means the command was verified in the current source tree but may not exist in an older installed release. Conditional commands depend on feature flags, workspace state, or account state. Internal commands should not be treated as stable automation APIs.