This guide is for day-to-day users. It covers startup, common commands, configuration, and troubleshooting.
The project is named RustingOpenCode (short: ROCode). The CLI command is still opencode.
Use this project's opencode. If you have another OpenCode (e.g. npm/global) on your PATH, the shell may run that instead. From the RustingOpenCode repo root use one of:
./target/debug/opencode— aftercargo build -p opencode-clicargo run -p opencode-cli --— always uses this repo's version
Example: ./target/debug/opencode tui or cargo run -p opencode-cli -- tui.
In the commands below, opencode means this local binary (run from repo root).
From the RustingOpenCode repo root:
cargo run -p opencode-cli -- --helpStart TUI by default:
cargo run -p opencode-cli --Same as:
cargo run -p opencode-cli -- tuiSingle non-interactive run:
cargo run -p opencode-cli -- run "Summarise the current risks in this repo"Start HTTP server:
cargo run -p opencode-cli -- serve --port 3000 --hostname 127.0.0.1Run these from the RustingOpenCode repo root; use ./target/debug/opencode or cargo run -p opencode-cli --.
./target/debug/opencode session list
./target/debug/opencode session list --format json
./target/debug/opencode session show <SESSION_ID>
./target/debug/opencode session delete <SESSION_ID>./target/debug/opencode models
./target/debug/opencode models --refresh --verbose
./target/debug/opencode config./target/debug/opencode auth list
./target/debug/opencode auth login --help
./target/debug/opencode auth logout --helpNote: For auth login / auth logout options, use the --help output.
./target/debug/opencode mcp list
./target/debug/opencode mcp connect <NAME>
./target/debug/opencode mcp disconnect <NAME>
./target/debug/opencode mcp add --help
./target/debug/opencode mcp auth --helpIf the local server is not at the default address:
./target/debug/opencode mcp --server http://127.0.0.1:3000 list./target/debug/opencode debug paths
./target/debug/opencode debug config
./target/debug/opencode debug skill
./target/debug/opencode debug agentShow full options:
./target/debug/opencode tui --help
./target/debug/opencode run --helpFrequently used (both TUI and run):
-m, --model <MODEL>– Set model-c, --continue– Continue latest session-s, --session <SESSION>– Continue specific session--fork– Fork session--agent <AGENT>– Set agent (default:build)--port <PORT>/--hostname <HOSTNAME>– Server address
Additional common options for run:
--format default|json-f, --file <FILE>--thinking
The program merges config from multiple locations by priority (searching upward):
opencode.jsoncopencode.json.opencode/opencode.jsonc.opencode/opencode.json
Global config default:
~/.config/opencode/opencode.jsonc(or.json)
Recommendation: Start with a minimal project-level config, then add provider/mcp/agent/lsp as needed.
Claude is supported via the anthropic provider. You can run interactive coding in the TUI or a one-off task with run.
Option A – Environment variable (easiest):
export ANTHROPIC_API_KEY="sk-ant-your-key-here"Get a key at Anthropic Console.
Option B – Config file:
Create or edit opencode.jsonc in your project (or ~/.config/opencode/opencode.jsonc):
Do not commit real API keys; use env vars or a local config that’s in .gitignore.
./target/debug/opencode auth list
./target/debug/opencode models --refreshYou should see anthropic and Claude models in the list.
Interactive TUI (recommended for coding):
./target/debug/opencode tui -m anthropic/claude-sonnet-4-20250514Or with default model from config:
./target/debug/opencode tuiIn the TUI you can type prompts, use slash commands, and let the agent edit files and run tools.
Single task (no TUI):
./target/debug/opencode run "Add a unit test for the login function in src/auth.rs"With a specific model:
./target/debug/opencode run -m anthropic/claude-sonnet-4-20250514 "Review this repo for security issues"anthropic/claude-sonnet-4-20250514– Claude Sonnet 4anthropic/claude-3-5-sonnet-20241022– Claude 3.5 Sonnetanthropic/claude-3-opus-20240229– Claude 3 Opus
Use ./target/debug/opencode models to see the full list for your setup.
cargo run -p opencode-cli --or./target/debug/opencode tui- Run tasks in the TUI
- Use
./target/debug/opencode session list/showto review history
./target/debug/opencode serve --port 3000- Use
./target/debug/opencode run ... --format jsonor the server API for integration - Use
./target/debug/opencode statsto track token/cost
- Use another port:
./target/debug/opencode serve --port 3001
./target/debug/opencode auth list./target/debug/opencode models --refresh./target/debug/opencode configto check that provider config is applied
./target/debug/opencode debug paths– see config search paths./target/debug/opencode debug config– see final merged config
./target/debug/opencode mcp list./target/debug/opencode mcp debug <NAME>./target/debug/opencode mcp connect <NAME>
- Project overview:
README.md - Docs index:
docs/README.md - CLI:
docs/opencode-cli.md - TUI:
docs/opencode-tui.md - Config:
docs/opencode-config.md
{ "model": "anthropic/claude-sonnet-4-20250514", "provider": { "anthropic": { "api_key": "sk-ant-your-key-here" } } }