CLI ToolsApr 9, 2026·3 min read

OpenCode — Open-Source AI Coding Agent for Terminal

Open-source AI coding agent with 140K+ stars. TUI-first design, LSP integration, works with Claude, OpenAI, Google, or local models. Two built-in agents: build and plan. MIT license.

TL;DR
OpenCode is an open-source terminal AI coding agent with TUI design, LSP integration, and multi-provider LLM support.
§01

What it is

OpenCode is an open-source AI coding agent designed for terminal-first workflows. It features a TUI (terminal user interface) for interactive coding sessions, LSP (Language Server Protocol) integration for code intelligence, and support for multiple LLM providers including OpenAI, Anthropic, and local models. The project provides a free alternative to commercial terminal coding agents.

Developers who prefer working in the terminal and want an AI coding assistant that integrates with their existing command-line workflow benefit most. OpenCode brings code understanding, generation, and review capabilities without leaving the terminal.

§02

How it saves time or tokens

OpenCode's LSP integration provides the AI with type information, definitions, and references from your project without sending entire files into context. This targeted context injection reduces token usage while improving code suggestion accuracy. The TUI provides a persistent session with history, so you avoid re-explaining context across separate prompts. Multi-provider support lets you choose the most cost-effective model for each task.

§03

How to use

  1. Install OpenCode:
# Via Go
go install github.com/opencode-ai/opencode@latest

# Or download binary from releases
curl -sSL https://github.com/opencode-ai/opencode/releases/latest/download/opencode-linux-amd64 -o opencode
chmod +x opencode
  1. Configure your LLM provider:
export OPENAI_API_KEY='sk-...'
# Or
export ANTHROPIC_API_KEY='sk-ant-...'
  1. Start an interactive session in your project directory:
cd my-project
opencode

The TUI launches with your project context loaded. Start asking questions or requesting code changes.

§04

Example

# Non-interactive mode for one-shot tasks
opencode 'Add error handling to all HTTP handlers in cmd/api/'

# Review a specific file
opencode 'Review src/auth/jwt.go for security issues'

# Generate tests
opencode 'Write table-driven tests for the ParseConfig function in config.go'

# Interactive TUI session
opencode
> /diff   # Show pending changes
> /apply  # Apply suggested changes
> /undo   # Revert last change
§05

Related on TokRepo

§06

Common pitfalls

  • OpenCode requires an LLM API key. Without one, the agent cannot function. Local model support (Ollama) is available but requires separate setup.
  • LSP integration depends on having the appropriate language server installed (gopls for Go, typescript-language-server for TypeScript, etc.). Without it, OpenCode falls back to file-based context.
  • The TUI uses terminal features that may not render correctly in all terminal emulators. Use modern terminals (iTerm2, Alacritty, WezTerm) for the best experience.

Frequently Asked Questions

Is OpenCode free?+

Yes. OpenCode is open source and free to use. You pay only for the LLM API usage from your chosen provider (OpenAI, Anthropic, etc.). Local model support via Ollama eliminates API costs entirely.

How does OpenCode compare to Claude Code?+

Both are terminal-based AI coding agents. Claude Code is Anthropic's official tool with deep Claude integration. OpenCode is open source and supports multiple providers. Claude Code has more polished workflows; OpenCode offers provider flexibility and community contributions.

Does OpenCode support local models?+

Yes. OpenCode supports Ollama and other OpenAI-compatible local model servers. Point the configuration to your local endpoint and use any model available on your machine.

What is LSP integration?+

LSP (Language Server Protocol) provides OpenCode with code intelligence -- type information, function signatures, references, and diagnostics. This gives the AI more precise context about your code without sending entire files, reducing token usage and improving suggestions.

Can OpenCode edit files directly?+

Yes. In both interactive and non-interactive modes, OpenCode can read, create, and modify files. It shows diffs before applying changes and supports undo. Changes are applied to your working directory but not committed automatically.

Citations (3)
🙏

Source & Thanks

Created by anomalyco. Licensed under MIT.

OpenCode — ⭐ 140,000+

Thanks to the Anomaly team for building a truly open alternative for AI-assisted coding.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets