OpenCode Crash Course
The fully open-source AI coding agent that runs in your terminal and supports 75+ LLM providers — Anthropic, OpenAI, Ollama, DeepSeek, and more. No lock-in.
What Is OpenCode?
OpenCode is an AI-powered coding agent that lives inside your terminal (or IDE). Unlike cloud-locked tools, it lets you bring your own model from 75+ providers — Anthropic, OpenAI, Google, DeepSeek, Ollama (local), xAI, and dozens more — and gives the AI direct access to your codebase through a rich set of built-in tools.
The core workflow is simple: describe what you want in natural language, and OpenCode's agent reads your code, plans changes, edits files, runs commands, and iterates — all inside your project directory. No copy-pasting, no switching tabs.
The fastest way to get started is OpenCode Zen — a curated set of tested models hosted by the OpenCode team. Run /connectinside the TUI, select "OpenCode Zen", sign in, create a Pi key, and paste it. You can also connect any other provider from the same menu.
Key Characteristics
Fully Open Source
No vendor lock-in. Self-host, fork, extend — the entire codebase is yours.
Provider-Agnostic
Use any LLM via API key or local inference. Switch models without changing your workflow.
Multi-Interface
TUI, CLI, Web UI, Desktop app, and IDE extension — work however you prefer.
Agent Architecture
Plan mode and Build mode work together. Plan first, then let the agent execute changes automatically.
Built-in Undo/Redo
Snapshots before every change. Revert with /undo if something goes wrong.
MCP Support
Connect external tools like Notion, GitHub, and databases via Model Context Protocol.
Installation
Pick any one method — all install the same OpenCode CLI.
Recommended — curl
npm
Homebrew (macOS / Linux)
Chocolatey (Windows)
Docker
Connect a Provider
Alternatively, pick any provider (Anthropic, OpenAI, etc.) from the /connect menu and paste your API key.
Initialize a Project
The /init command generates an AGENTS.mdfile in your project root. This file helps OpenCode understand your project's structure, stack, and conventions. Commit it to Git so the whole team benefits.
The Two Modes — Build & Plan
Switch between modes with the Tab key. The current mode is always shown in the lower corner of the TUI.
Build Mode (default)
All tools enabled. The agent can read files, write files, run shell commands, and make real changes to your codebase. This is where actual development happens.
Plan Mode
File edits and bash commands require explicit approval. Use this to analyze code, suggest implementation plans, and reason about architecture — without touching anything.
Recommended Workflow
Tab → Plan mode
Describe the feature. Let OpenCode create a detailed implementation plan. Iterate on it until it looks right.
Refine the plan
Add constraints like "use the same card layout from the main list" or drop in a screenshot as a design reference.
Tab → Build mode
Tell it to execute. OpenCode makes all the changes automatically.
Review & undo if needed
If something is off, /undo reverts everything from the last set of changes.
Core Tools & Daily Usage
OpenCode gives the LLM access to these tools automatically — no configuration needed.
bashExecute shell commands (npm install, git status, tests, etc.)
readRead file contents with optional line ranges for large files.
editModify existing files via exact string replacement.
writeCreate new files or overwrite existing ones.
grepRegex search across your codebase powered by ripgrep.
globFind files by pattern — **/*.ts, src/**/*.jsx, etc.
webfetchFetch and read web pages for docs and references.
websearchSearch the web via Exa AI.
todowriteManage task lists during complex multi-step operations.
lspGo-to-definition and find-references via LSP integration.
Everyday Commands
@file.tsAttach a file directly to your prompt for targeted context.
/undoRevert the last set of changes. Repeatable — keep undoing to go further back.
/redoRe-apply reverted changes.
/shareCreate a shareable link to this conversation for your team to interact with.
/modelsSwitch to a different model mid-session.
/connectAdd or change providers and API keys.
/initRe-analyze project and regenerate AGENTS.md.
/compactManually compress context when it gets long.
Mentioning Subagents
Type @ followed by a subagent name to invoke specialized helpers — e.g. @general help me search for this function or @explore find all files related to authentication.
Configuration Deep Dive
Create opencode.json in your project root. OpenCode works with defaults — add only what you need.
Minimal — just set a model
Full production config
Config Precedence (lowest → highest)
Agents & Customization
Agent Types
Primary agents
The main assistants you interact with. Build and Plan are built-in primary agents. Switch with Tab.
Subagents
Specialized helpers invoked by primary agents or via @mention. Built-ins: General (full tools), Explore (read-only), Scout (external docs research).
Creating Custom Agents
Define agents as markdown files — globally in ~/.config/opencode/agents/ (all projects) or project-specific in .opencode/agents/. The filename becomes the agent name.
Ready to go provider-agnostic?
Watch the full crash course above — installation, Plan & Build workflow, custom agents, MCP servers, and GitHub Actions CI/CD, all in one video.
Watch the Full TutorialRecommended Blogs
Read Our Blogs

Best Screen Recorder Tools: What to Look For in 2026
What makes a screen recorder good in 2026: recording quality, AI transcription, editing, and privacy — plus a checklist before you choose one.

How to Get Your First 10 Paying Users: A Step-by-Step Playbook for B2B and B2C SaaS Founders
Why the first ten matter more than the next ten thousand - and exactly how to find them.

