OpenCode — AI Coding Agent

Complete guide to OpenCode, the terminal-based AI coding agent. Covers installation, prompt engineering, configuration, providers, skills, and best practices.

June 17, 2026
opencodeai-codingterminal-agentsetupprompt-engineering

OpenCode — AI Coding Agent

OpenCode is an open-source, terminal-based AI coding agent. It runs in your project directory, reads your codebase, writes and edits files, executes terminal commands, and can autonomously drive multi-step engineering tasks — all through an interactive CLI.

Its defining difference is provider freedom. Where most agents lock you into one vendor's model, OpenCode supports 75+ LLM providers and lets you switch models mid-session, so you can use the best (or cheapest) model for each part of a task — and run entirely on local models if you want.

How OpenCode Works

OpenCode is built around the same agent loop as other modern coding agents, but emphasizes configurability:

  • Interactive terminal UI — A TUI session where you steer the agent, see its plan, review diffs, and continue iterating.
  • AGENTS.md conventions — Project-level instruction files that define how OpenCode behaves in your repo: architecture, style, commands to use or avoid.
  • Provider flexibility — Bring your own API keys for Anthropic, OpenAI, Google, DeepSeek, and dozens more, or point it at local models via Ollama.
  • Skills system — Customizable, named skill configurations that bundle instructions and workflows for specialized tasks.
  • MCP support — Full Model Context Protocol integration for external tools and servers.

Because it's open source and provider-agnostic, OpenCode is a strong choice when you want the power of a terminal agent without vendor lock-in, model markup, or closed-source telemetry.

Core Features

  • Provider flexibility — 75+ LLM providers; switch models mid-session (e.g., Gemini for planning, DeepSeek for cost-sensitive edits).
  • Skills system — Customizable skill configurations that package specialized workflows for reuse across sessions.
  • MCP support — Full Model Context Protocol integration.
  • Custom rulesAGENTS.md conventions for project-specific instructions.
  • Local models — Run entirely offline with Ollama or other local providers.
  • Interactive TUI — Review plans, diffs, and command execution live before approving.
  • Open source — Fully inspectable and self-hostable; no vendor lock-in.

Quick Start

# Install globally
npm install -g opencode

# Run in your project directory
opencode

On first launch, OpenCode asks which provider and model to use. Then:

  1. Run opencode in your project root.
  2. Describe a task — OpenCode will read the repo, plan, and start working.
  3. Review its approach and approve commands as it executes.
  4. Switch providers mid-session if you want a different model for a subtask.

For a full walkthrough, see Getting Started with OpenCode.

Writing Effective Prompts

The same prompt discipline that works for other agents applies to OpenCode:

  • Give it a goal and a definition of done — "Add a /search endpoint with tests and docs" beats "implement search."
  • Reference your repo — Point it at existing patterns: "Mirror the auth middleware in src/middleware.ts."
  • Keep AGENTS.md current — Put stable conventions there so the agent doesn't re-derive them each session.
  • Use skills for repeatable work — If you run the same review or scaffolding task often, package it as a skill.

For conventions, slash commands, and provider guidance, see Prompt Engineering in OpenCode. For the full reference on opencode.json, skills, plugins, and MCP, see Configuration Reference.

OpenCode vs Claude Code vs Copilot

FeatureOpenCodeClaude CodeGitHub Copilot
Open source
Terminal agentCLI only
Provider choice75+ / localAnthropicGitHub-hosted
Switch models mid-task
Local models✓ (Ollama)
Custom rulesAGENTS.mdCLAUDE.mdcopilot-instructions.md
Skills systemPartial (subagents)
MCP support

Claude Code is the most polished terminal agent for Anthropic models; OpenCode is the most flexible — open source, model-agnostic, and local-first. Copilot remains the best choice for teams deeply embedded in the GitHub ecosystem.

Pricing

OpenCode offers free and paid tiers. The core agent is free to use with your own API keys (you pay the model provider directly). Paid tiers add convenience features and a managed gateway for provider access.

Frequently Asked Questions