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.

Install/connect · model/init · first task

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.

/connectProvider setup
/modelsPick model
/initAGENTS.md
GoalEntryFirst-hour check
Installinstall script / npm / Homebrewopencode starts
Provider/connect or opencode auth login/models lists selectable models
Project context/init at repo rootAGENTS.md created
First task@file read-only or tiny diffgit diff matches intent

Install, provider, first task

  1. 01
    Install OpenCode CLI

    curl -fsSL https://opencode.ai/install | bash, or npm install -g opencode-ai, or brew install anomalyco/tap/opencode. On Windows, prefer WSL per docs.

  2. 02
    Connect provider and model

    Run opencode, type /connect (try OpenCode Zen if you are new), or opencode auth login from the shell. Then /models to choose a default. Protect auth.json.

  3. 03
    Initialize the repo

    cd project root → opencode → /init for AGENTS.md. Ask a read-only question with @ file search first.

  4. 04
    First 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; /undo if 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 .env if you rely on environment variables.
Is /init required?
Not strictly, but docs recommend /init to generate committable AGENTS.md.
Whiteboard?
No—open sitdraw for diagrams.

Connect first, keep diffs small

Treat auth.json like a password file; read every change before accepting.

Start the picture