← 返回命令列表

Linux command

opencode 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Launch the interactive TUI

opencode

Open a specific project directory

opencode [path/to/project]

Run a prompt non-interactively

opencode run "[fix the bug in main.go]"

Use a specific model

opencode --model [anthropic/claude-sonnet-4]

Continue the last session

opencode --continue

Resume a specific session

opencode --session [session_id]

Start the web interface

opencode web

List available models

opencode models

说明

OpenCode is an open-source AI coding agent that runs in your terminal, desktop, or IDE. It provides Claude-Code-level capabilities without locking you to a single model or platform, supporting over 75 AI models including Claude, GPT, Gemini, and local models. The default TUI mode offers an interactive chat interface with two built-in agents: build (full access for development) and plan (read-only for analysis). Switch between them with the Tab key. OpenCode integrates with Language Server Protocol for code intelligence and connects to your GitHub workflow for CI/CD automation. Unlike cloud-based assistants, OpenCode gives you control over your data. You choose the model provider and what gets shared. Running a local model keeps your entire workflow private.

参数

--model, -m _PROVIDER/MODEL_
Specify the AI model to use (e.g., anthropic/claude-sonnet-4, openai/gpt-4o)
--continue, -c
Resume the last session
--session, -s _ID_
Continue a specific session by ID
--prompt _TEXT_
Provide an initial prompt when launching
--agent _NAME_
Select a specific agent (build, plan, or custom)
--port _NUMBER_
Server port for web or serve commands
--help, -h
Display help information
--version, -v
Show version number

FAQ

What is the opencode command used for?

OpenCode is an open-source AI coding agent that runs in your terminal, desktop, or IDE. It provides Claude-Code-level capabilities without locking you to a single model or platform, supporting over 75 AI models including Claude, GPT, Gemini, and local models. The default TUI mode offers an interactive chat interface with two built-in agents: build (full access for development) and plan (read-only for analysis). Switch between them with the Tab key. OpenCode integrates with Language Server Protocol for code intelligence and connects to your GitHub workflow for CI/CD automation. Unlike cloud-based assistants, OpenCode gives you control over your data. You choose the model provider and what gets shared. Running a local model keeps your entire workflow private.

How do I run a basic opencode example?

Run `opencode` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --model, -m _PROVIDER/MODEL_ do in opencode?

Specify the AI model to use (e.g., anthropic/claude-sonnet-4, openai/gpt-4o)