How to install and use OpenCode CLI: configure a provider, first coding task in the terminal
Install opencode, connect a provider and pick a model, run /init in your project, then finish one small coding task you can verify with git diff.
To run your first job with OpenCode CLI, finish four steps: official install, configure a provider with /connect or opencode auth login, launch opencode in a repo (optionally /init), then review and accept a small change.
Facts follow opencode.ai/docs install and Configure sections plus dev.opencode.ai/docs/cli auth and Providers pages. Queries: OpenCode CLI install, OpenCode configure provider. For a short huddle see sitdraw and create and join a room.
TUI connect vs CLI auth
/connect
Interactive picker for OpenCode Zen, Anthropic, OpenAI, OAuth, or API keys—best for first setup.
auth login
opencode auth login anthropic --method key stores credentials in ~/.local/share/opencode/auth.json without opening the full TUI flow.
| Goal | Entry | First-hour check |
|---|---|---|
| Install | install script / npm / Homebrew | opencode starts |
| Provider | /connect or opencode auth login | /models lists selectable models |
| Project context | /init at repo root | AGENTS.md created |
| First task | @file read-only or tiny diff | git diff matches intent |
Install, provider, first task
- 01Install OpenCode CLI
curl -fsSL https://opencode.ai/install | bash, ornpm install -g opencode-ai, orbrew install anomalyco/tap/opencode. On Windows, prefer WSL per docs. - 02Connect provider and model
Run
opencode, type/connect(try OpenCode Zen if you are new), oropencode auth loginfrom the shell. Then/modelsto choose a default. Protectauth.json. - 03Initialize the repo
cdproject root →opencode→/initforAGENTS.md. Ask a read-only question with@file search first. - 04First coding task
Request a one-line README update or comment-only edit. Use Tab for Plan mode if you want a plan first. Accept changes only after review;
/undoif needed.
# First hour · OpenCode CLI · 2026-09
# curl -fsSL https://opencode.ai/install | bash
# opencode → /connect → /models
# cd my-repo && opencode → /init
# opencode.ai/docs · dev.opencode.ai/docs/cli- Compare Codex CLI or Gemini CLI?
- OpenCode is a multi-provider open-source terminal agent; see our Codex CLI guide and Gemini CLI guide.
- No models after /connect?
- Run
/models, verify billing/API key, and check project.envif you rely on environment variables. - Is /init required?
- Not strictly, but docs recommend
/initto generate committableAGENTS.md. - Whiteboard?
- No—open sitdraw for diagrams.
Connect first, keep diffs small
Treat auth.json like a password file; read every change before accepting.