AI & LLMs · Guide · AI & Prompt Tools
How to Use OpenCode
Install SST's open-source terminal agent, connect Claude or local providers, navigate the TUI, and review diffs with plan mode. Free to use instantly.
OpenCode is an open-source terminal AI coding agent from the sst team. It runs in your shell, reads and edits files in your repo, runs commands, and brings its own TUI so you can keep coding without leaving the terminal.
Advertisement
What OpenCode actually is
OpenCode is a standalone, model-agnostic agent. It is not a VS Code extension and it is not a wrapper around someone else’s CLI. You point it at a directory, give it a task, and it plans, edits files, and executes shell commands inside that working tree. It supports Anthropic, OpenAI, Google, and local providers via their own keys or a gateway, so you pay the model vendor directly instead of a middleman.
Installing
# macOS / Linux curl -fsSL https://opencode.ai/install | bash # or via npm npm install -g opencode-ai
After install, run opencode auth login and pick a provider. Anthropic and OpenRouter are the two most common paths; OpenRouter is useful if you want to flip between Claude, GPT, and Gemini without juggling three billing dashboards.
A first session
cd ~/code/my-app opencode
That drops you into the TUI. Type your request in plain English — “add a health check endpoint at /healthz that returns 200 and the git sha” — and OpenCode will read relevant files, propose edits, and ask before running shell commands. Use /model to switch models mid-session and /init to have it generate an AGENTS.md that captures your build/test commands so future sessions boot faster.
Configuration that matters
Drop an opencode.json at the repo root to pin the default model, register MCPservers, and declare allowed shell commands. The biggest win is the permission config: set permission.edit to ask for a new codebase and allow once you trust the loop. Also add an AGENTS.md — OpenCode reads it automatically and it is how you teach the agent “always run pnpm typecheck before you claim you’re done.”
Where OpenCode shines
Multi-file refactors where you want the agent to grep the repo, edit five files, run tests, and iterate until green — all without leaving tmux. The TUI’s diff view is genuinely good, and because it is provider-agnostic you can keep your existing API keys. It also plays well with SSH sessions on a remote dev box, which is something most editor-bound agents handle poorly.
When not to reach for it
If your workflow is “autocomplete while I type” you want Copilot or Cursor Tab, not OpenCode. And if you hate the idea of an agent running shell commands on your machine, set permissions to ask everywhere or pick a reviewer-style tool instead. Finally, bills get real — a single big refactor can burn a few dollars of Claude Sonnet tokens, so keep an eye on the provider dashboard for the first week.
Use these while you read
Tools that pair with this guide
- System Prompt BuilderCompose a focused system prompt from a role, tone, constraints, and output format — copy-ready for any LLM.AI & Prompt Tools
- AI Prompt GeneratorTurn a vague idea into a structured prompt. Pick role, task, context, constraints, and output format. Works with ChatGPT, Claude, and Gemini.AI & Prompt Tools
- AI Token CounterEstimate tokens, characters, words, and approximate API cost for GPT-4o, GPT-4, Claude, and Gemini — before you hit send.AI & Prompt Tools
- AI Prompt LibraryBrowse a curated catalog of prompt templates for writing, coding, marketing, and research. One click to copy.AI & Prompt Tools
Advertisement
Continue reading
- AI & LLMsGitHub Copilot Pricing and ComparisonCompare free vs paid GitHub Copilot tiers and analyze it against ChatGPT, Cursor, and Tabnine. Find the best value plan instantly with this free online guide.
- AI & LLMsGitHub Copilot Features and CapabilitiesTest what Copilot really does — code accuracy, scope limits, debugging, web dev, legacy code, tests, docs, team customization. Free guide, no sign-up.
- AI & LLMsGitHub Copilot Security and Data HandlingAudit where your code goes, who sees it, training-data policy, network needs, and what happens when Copilot suggests broken code. Free, no sign-up.
- AI & LLMsAI Fluency SkillsThe 8 sub-skills of AI fluency: prompt structure, model selection, tool use, quality calibration, iteration, context management, cost awareness, privacy.
- AI & LLMsAnthropic Skills ExplainedSkills as Anthropic's answer to Custom GPTs — markdown-defined, version-controlled in git, work in terminal. Anatomy + Skills vs Custom GPTs.
- AI & LLMsKimi K2 vs DeepSeek V3Two open-weight Chinese flagships. Kimi K2 = 1M context, DeepSeek V3.2 = top-tier reasoning + coding. Pick by use case.