Note
Fork of now archived https://github.com/opencode-ai/opencode The focus is changed towards headless experience oriented towards autonomous agents.
OpenCode brings AI coding agents to your terminal. Run it as an interactive TUI, as a headless CLI for scripts and autonomous agents, as an HTTP API server, or as an ACP server for editors.
- Four ways to run: interactive TUI, headless
-pmode, HTTP REST API with SSE, and ACP for Zed, JetBrains and AionUI - Flows: deterministic multi-step agent workflows defined in YAML (guide)
- Agents and subagents: built-in and custom agents, defined in JSON or markdown (guide)
- Chat bridge: Telegram, Slack and Mattermost adapters with interactive questions and multi-reviewer fan-out (guide)
- Many providers: Anthropic, OpenAI, Gemini, AWS Bedrock, VertexAI, YandexCloud, Kimi and self-hosted (guide)
- Tools: files, shell, search, LSP, web fetch (guide), MCP servers, and host CLIs wrapped as workspace tools
- Tool control: allow-lists, granular permissions (guide) and on-demand deferred tools
- Structured output: enforce an agent's final answer with a JSON schema (guide)
- Skills, commands and hooks: skills, custom commands and Claude-Code-compatible hooks
- Long-running sessions: auto-compaction, background tasks, cron jobs and project memory
- Observability: Langfuse tracing of LLM calls, tools, tokens and cost (guide)
- Storage: sessions in SQLite or MySQL (guide)
# Install script (add VERSION=0.3.0 before bash for a specific version)
curl -fsSL https://raw.githubusercontent.com/obukhovaa/opencode/refs/heads/main/install | bash
# Homebrew
brew install obukhovaa/tap/opencode
# Go
go install github.com/obukhovaa/opencode@latestopencode # Start the TUI
opencode -a hivemind # Start with a specific agent
opencode -s <session-id> # Resume or create a session
opencode -p "Explain context in Go" # Single prompt, non-interactive
opencode -p "Refactor this module" -f json -q -t 5m
opencode -p "Review it" -F review-code -A hash=93706ee # Run a flow with args
opencode serve --port 8080 # HTTP API server (docs/server.md)
opencode acp # ACP server over stdioAll permissions are auto-approved in non-interactive mode.
| Flag | Short | Description |
|---|---|---|
--help |
-h |
Display help |
--version |
-v |
Print the version |
--debug |
-d |
Enable debug mode |
--cwd |
-c |
Set working directory |
--prompt |
-p |
Non-interactive single prompt |
--agent |
-a |
Agent ID to use (e.g. coder, hivemind) |
--session |
-s |
Session ID to resume or create |
--delete |
-D |
Delete the session specified by --session before starting |
--output-format |
-f |
Output format: text (default), json |
--quiet |
-q |
Hide spinner in non-interactive mode |
--timeout |
-t |
Timeout for non-interactive mode (e.g. 10s, 30m, 1h) |
--max-turns |
Maximum tool-use turns per request (overrides agent config) | |
--auto-approve |
Start TUI with auto-approve enabled (skip permission dialogs) | |
--flow |
-F |
Flow ID to execute (guide) |
--arg |
-A |
Flow argument as key=value (repeatable) |
--args-file |
JSON file with flow arguments | |
--project-id |
-P |
Custom project ID to group sessions (overrides detected Git/basename) |
opencode serve, opencode acp and opencode tools have their own flags: see --help, docs/server.md and docs/cli-tools.md.
OpenCode reads .opencode.json from the project directory, then $XDG_CONFIG_HOME/opencode/, then $HOME. A minimal config:
{
"providers": {
"anthropic": { "apiKey": "..." }
},
"agents": {
"coder": { "model": "claude-4-5-sonnet[1m]", "maxTokens": 5000 }
}
}See docs/configuration.md for a full example, permissions and environment variables. Your editor can validate the file against opencode-schema.json.
| Topic | Guide |
|---|---|
| Getting set up | |
| Configuration, permissions, environment variables | docs/configuration.md |
${VAR} environment references in config values |
docs/config-env.md |
| Providers and supported models | docs/providers.md |
| TUI keyboard shortcuts and auto-approve | docs/tui.md |
| Agents | |
| Built-in and custom agents | docs/agents.md |
Context files (AGENTS.md, CLAUDE.md) |
docs/context.md |
| Skills | docs/skills.md |
| Custom commands | docs/custom-commands.md |
| Compaction and self-compaction | docs/compaction.md |
| Project memory | docs/memory.md |
| Tools | |
| Built-in tools, shell, tool environment | docs/tools.md |
Tool permissions (tools vs allowTools) |
docs/tool-permissions.md |
| MCP servers | docs/mcp.md |
| Workspace CLI tools | docs/cli-tools.md |
| Deferred tools and tool search | docs/deferred-tools.md |
| Structured output | docs/structured-output.md |
| LSP servers | docs/lsp.md |
| Hooks (Claude-Code-compatible) | docs/hooks.md |
| Automation | |
| Flows | docs/flows.md |
| Background tasks | docs/background-tasks.md |
| Cron and heartbeat | docs/cron-and-heartbeat.md |
| Running as a service | |
| HTTP server and ACP mode | docs/server.md |
| Chat bridge (Slack, Telegram, Mattermost) | docs/bridge.md |
| Session storage (SQLite, MySQL) | docs/session-providers.md |
| Telemetry and Langfuse | docs/telemetry.md |
| Contributing | |
| Building, testing, Docker, releases | docs/development.md |
git clone https://github.com/obukhovaa/opencode.git
cd opencode
make build # build
make test # lint and run all testsDocker images, end-to-end tests and releases are covered in docs/development.md.
- Fork the repository
- Create a feature branch
- Commit your changes
- Open a Pull Request
- @isaacphi — mcp-language-server, foundation for the LSP client
- @adamdottv — Design direction and UI/UX architecture
- @kujtimiihoxha – Original OpenCode implementation
MIT — see LICENSE.