Command Palette

Search for a command to run...

GitHubGitHub

OpenCode Installation Guide

Install the open-source OpenCode terminal agent with the install script, npm or Homebrew, connect a model provider and bootstrap the project with an AGENTS.md file.

OpenCode is an open-source AI coding agent that runs in your terminal, as a desktop app or as an IDE extension. It works with any model provider and keeps the project context in a file you commit to Git.

System Requirements

  • A modern terminal emulator — WezTerm, Alacritty, Ghostty or Kitty are the best supported
  • macOS, Linux or Windows (WSL2 is recommended on Windows)
  • API keys for the model providers you want to use
  • git for the project workflows

Installation Instructions

curl -fsSL https://opencode.ai/install | bash
 
# Verify
opencode --version

Connecting a Provider

Run the /connect command in the TUI and pick a provider:

/connect

OpenCode Zen is a curated list of models that the OpenCode team has tested, and it is the easiest option if you do not already have a provider key.

You can also configure a provider directly — OpenCode reads the same environment variables the provider SDKs use:

export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...

Bootstrapping a Project

cd /path/to/project
opencode
/init

/init makes OpenCode analyse the project and write an AGENTS.md file in the project root. Commit that file — it is what makes the agent consistent across the team and across machines.

Working with OpenCode

# Ask about the codebase
How is authentication handled in @packages/functions/src/api/index.ts
ModeWhat it does
BuildReads, edits files and runs commands
PlanSuggests how to implement something, without changing anything (Tab to switch)

The Plan mode is worth using for anything that spans more than one file: write the request, read the plan, give feedback, then switch to Build.

Useful Commands

CommandWhat it does
/initCreate the AGENTS.md for the project
/undoRevert the last change and show the original message
/redoRe-apply an undone change
@Fuzzy search for a file to add to the context

Troubleshooting

Best Practices

  1. Commit AGENTS.md — it is the single highest-value file in the repository.
  2. Use Plan mode for multi-file work and read the plan before approving it.
  3. Reference files with @ instead of hoping the agent finds the right one.
  4. Keep the working tree clean so /undo stays meaningful.
  5. Use opencode in CI with a scoped provider key and a read-only checkout.
  6. Pin the version in CI images.
  7. Review diffs — the agent shows exactly what it changed.

Next Steps