Skip to main content

OpenCode: Comprehensive Reference & Cheat Sheet

This document serves as a high-density, comprehensive reference guide for OpenCode. It is intended for users who are familiar with the basic workflow and need a quick reference for specific commands, configuration details, advanced features, and provider-specific information.

Core Commands

These are the most common commands you will use when interacting with the OpenCode TUI.

CommandDescription
opencodeStarts the interactive TUI session in the current directory.
opencode [prompt]Executes a prompt in non-interactive "one-shot" mode and prints the result.
opencode auth loginInitiates the authentication flow to add or update provider API keys.
opencode configManages the local OpenCode configuration.
opencode helpDisplays help information for commands and flags.
opencode --versionShows the installed version of the OpenCode CLI.

In-Session Commands

These commands are used within the interactive TUI session.

CommandDescription
/plan [prompt]Describes a change you want to make. The AI will propose a plan.
/buildExecutes the approved plan and applies the code changes.
/undoReverts the last set of changes made by the agent.
/redoRe-applies the last set of changes that were undone.
/shareGenerates a shareable link to the current conversation.
/clearClears the current conversation history.
/exitExits the OpenCode TUI.

Configuration

OpenCode can be configured using the opencode config command.

  • Set a configuration value:
    • opencode config set [key] [value]
    • Example: opencode config set default.model openai/gpt-4o
  • Get a configuration value:
    • opencode config get [key]
    • Example: opencode config get default.model
  • List all configuration values:
    • opencode config list

Authentication

Manage API keys for different providers.

  • Login to a provider:
    • opencode auth login -p [provider]
    • Example: opencode auth login -p anthropic
  • List authenticated providers:
    • opencode auth list

Installation Methods

PlatformCommand
macOS (Homebrew)brew tap charmbracelet/tap && brew install opencode
Linux / macOS`curl -fsSL https://opencode.ai/install.sh
npmnpm install -g @opencode/cli
Arch Linux (Paru)paru -S opencode-bin
WindowsManual binary download from the releases page.

This reference covers the core functionalities and advanced features of OpenCode. For the most up-to-date information, always refer to the official documentation or use the opencode help command.