| name | opencode-cli |
| description | Reference for using OpenCode CLI to handle complex coding tasks. Use when Research-Claw needs to delegate multi-file projects, code generation, or iterative debugging to a multi-provider AI coding tool. Trigger words: opencode, coding CLI, delegate coding, multi-provider agent.
|
OpenCode CLI
Terminal-based AI coding agent supporting multiple LLM providers (OpenAI, Anthropic, Google, local models). Features a TUI for interactive use and run command for automation.
Detect Installation
which opencode
opencode --version
Install
curl -fsSL https://opencode.ai/install | bash
npm install -g opencode-ai
brew install anomalyco/tap/opencode
pnpm install -g opencode-ai
Requires API keys for your chosen LLM provider (configured via /init on first run).
Non-Interactive Usage (run)
For programmatic invocation from Research-Claw, use opencode run:
opencode run "Refactor the auth module to use dependency injection"
opencode run -m anthropic/claude-sonnet-4-20250514 "Fix all type errors"
opencode run -f src/config.ts -f README.md "Update the config schema"
opencode run --format json "List all exported functions"
opencode run -c "Now add tests for what you just implemented"
opencode run -s <session-id> "Fix the remaining issues"
Key Flags
| Flag | Description |
|---|
-m, --model <provider/model> | Model in provider/model format |
-f, --file <path> | Attach file(s) to the message (repeatable) |
--format <fmt> | Output format: default or json |
-c, --continue | Continue last session |
-s, --session <id> | Continue a specific session by ID |
--fork | Fork session when continuing (new branch) |
--share | Share the session |
--agent <name> | Specify which agent to use |
--attach <url> | Connect to running server (e.g. http://localhost:4096) |
--log-level <level> | DEBUG / INFO / WARN / ERROR |
Research-Claw exec Patterns
exec("opencode run -m anthropic/claude-sonnet-4-20250514 'Implement the feature described in TODO.md'")
exec("opencode run -f README.md -f src/schema.ts 'Add validation based on the schema'")
exec("opencode run --format json 'List all API endpoints in this project'")
exec("opencode run --attach http://localhost:4096 'Run the test suite and fix failures'")
Docs