OpenCode.ai — AI Coding Agent (Open Source)
A terminal-first, model-agnostic AI agent that plans, runs shell commands, edits files, and integrates with local LSPs while prioritizing privacy.
What is OpenCode
OpenCode is an open-source, terminal-first AI coding agent that runs where developers already work: the terminal, a local web UI, or a native desktop app. Unlike inline completion tools, OpenCode can plan multi-step tasks, run shell commands, edit files programmatically, and consult local Language Server Protocol (LSP) data to improve code understanding.
Key features
- Model-agnostic: use your own API keys (OpenAI, Anthropic, Ollama/local models) or managed Zen/Black services.
- Terminal-first UX: TUI for interactive sessions, CLI for scripting, and a local web UI for headless usage.
- Agent loop: supports Plan → Act → Verify workflows and subagents for focused tasks (e.g.,
@explore). - File & shell tools: can run
bash, search withgrep/glob, and perform preciseeditoperations. - LSP integration: leverages local language servers to locate definitions and references for safer edits.
- Permission controls: granular allow/ask/deny settings for shell and file operations.
Practical commands
# initialize project context (creates AGENTS.md)
opencode init
# run a one-off prompt non-interactively
opencode run --prompt "Explain the authentication flow in src/auth.ts"
# launch local web interface (headless server)
opencode web
Usage tips
- Plan before acting: start long or risky tasks in Plan mode so the agent outlines steps before modifying files.
- Start conservative: set
bashand other powerful tools toaskuntil you trust the agent’s behavior. - Use subagents: try
@explorefor repository search or@generalfor focused research without polluting the main context.
Privacy & security
OpenCode emphasizes local execution and privacy. When used with BYO keys or local models, source code and prompts remain on your machine. Review permission settings before granting shell or write rights in unfamiliar repositories.
Comparison (short)
- OpenCode: terminal/TUI, autonomous loops, full-shell access, model choice, local-first privacy.
- IDE assistants (Copilot/Cursor): editor-embedded, inline completions, limited shell access, vendor-hosted models.
Resources
- Official site: https://opencode.ai/
- Docs: https://opencode.ai/docs
- Download / install: https://opencode.ai/download
- GitHub: https://github.com/anomalyco/opencode
Ready to try OpenCode? Start with opencode init in a copy of your repository and keep sandboxed branches for agent-driven edits.