noc2rnalnoc2rnal
May 2026
Opencode

OpenCode is an open-source AI coding agent that runs inside your terminal, IDE, desktop app, or browser-based workflow. Instead of only giving you code suggestions, OpenCode can inspect your project, read files, edit files, run commands, use agents, call custom slash commands, and connect to different AI models.

The best part is flexibility. You can use hosted models from providers like OpenAI, Anthropic, OpenRouter, or OpenCode Zen, but you can also connect local models running on your own machine through Ollama, LM Studio, or other OpenAI-compatible local servers.

That makes OpenCode a strong option if you want a coding agent that is customizable, model-flexible, and not locked into one provider.

Why This Over Typical AI Chat

  • Works Inside Your Project: OpenCode reads and edits your actual repo instead of only responding to pasted code.

  • Terminal Native: You can run it from your project folder and let it use your existing scripts.

  • VS Code Friendly: It can run inside the VS Code integrated terminal and install its IDE extension automatically.

  • Model Flexible: You can use cloud models, local Ollama models, OpenRouter models, LM Studio models, and other OpenAI-compatible APIs.

  • Agent System: You can switch between Build mode, Plan mode, and custom agents.

  • Custom Slash Commands: You can create project-specific commands like /test, /review, /fix-bug, or /release-notes.

  • Local Model Support: You can run models on your own machine with Ollama for privacy, experimentation, and lower recurring cost.

# Normal AI chat workflow
Paste code -> ask question -> copy answer -> manually edit files -> manually test

# OpenCode workflow
Open repo -> ask OpenCode -> review edits -> run tests -> commit changes

Prerequisites

  • Basic terminal knowledge.

  • Node.js, Bun, Homebrew, or another supported install method.

  • VS Code or another IDE with an integrated terminal.

  • Git installed.

  • A project repo to work inside.

  • Optional: Ollama installed if you want local models.

  • Optional: API keys for hosted providers like OpenAI, Anthropic, OpenRouter, or OpenCode Zen.

Install OpenCode

The fastest install method is the official install script.

# [Mac / Linux Terminal]
# This installs OpenCode using the official install script.
curl -fsSL https://opencode.ai/install | bash

You can also install it with npm.

# [Mac / Linux / Windows Terminal]
# This installs OpenCode globally using npm.
npm install -g opencode-ai

Or with Bun.

# [Mac / Linux / Windows Terminal]
# This installs OpenCode globally using Bun.
bun install -g opencode-ai

Or with pnpm.

# [Mac / Linux / Windows Terminal]
# This installs OpenCode globally using pnpm.
pnpm install -g opencode-ai

Or with Homebrew.

# [Mac / Linux Terminal]
# This installs OpenCode using the OpenCode Homebrew tap.
brew install anomalyco/tap/opencode

Check that it works:

# [Project Terminal]
# This verifies that the OpenCode CLI is available.
opencode --version

OpenCode Project Structure

A good OpenCode-friendly project should have clear scripts, docs, config, and agent instructions.

my-app/
├── client/
│   ├── src/
│   └── package.json
├── server/
│   ├── controllers/
│   ├── routes/
│   └── package.json
├── scripts/
│   ├── check.sh
│   ├── test.sh
│   └── deploy.sh
├── docs/
│   ├── architecture.md
│   └── api.md
├── .opencode/
│   ├── agents/
│   │   └── review.md
│   ├── commands/
│   │   ├── test.md
│   │   ├── review.md
│   │   └── fix-bug.md
│   └── plugins/
├── AGENTS.md
├── opencode.json
├── package.json
└── README.md

OVERVIEW :

  • client/ - Frontend application code.

  • server/ - Backend API code.

  • scripts/ - Repeatable project scripts that OpenCode can run.

  • docs/ - Architecture notes and project rules.

  • .opencode/agents/ - Custom project agents.

  • .opencode/commands/ - Custom slash commands.

  • .opencode/plugins/ - Project-level plugins.

  • AGENTS.md - Project instructions for OpenCode.

  • opencode.json - Project-specific OpenCode config.

  • package.json - Main dev, build, lint, and test scripts.

Initialize OpenCode In A Project

Navigate into your project and start OpenCode.

# [Project Terminal]
# This moves into your project folder.
cd /path/to/my-app
# [Project Terminal]
# This starts OpenCode inside the current project.
opencode

Inside the OpenCode TUI, initialize the project.

/init

This makes OpenCode analyze your project and create an AGENTS.md file in the project root.

You should commit AGENTS.md to Git because it tells OpenCode how your project works.

# [Project Terminal]
# This commits the generated OpenCode project instructions.
git add AGENTS.md && git commit -m "Add OpenCode project instructions"

AGENTS.md

AGENTS.md is where you tell OpenCode your project rules.

Example:

# AGENTS.md

## Project Rules

- Use the existing file structure.
- Do not add new dependencies unless necessary.
- Keep backend changes secure.
- Validate request data before saving to MongoDB.
- Use existing customFetch helpers on the frontend.
- Mark important changes with `//IMPORTANT`.
- Keep explanations short.
- Run tests or lint checks after changing logic.

## Frontend

- React components live in `client/src/components`.
- Pages live in `client/src/pages`.
- Styling uses styled-components.
- Avoid changing unrelated styles.

## Backend

- Express controllers live in `server/controllers`.
- Routes live in `server/routes`.
- Mongoose models live in `server/models`.
- Always sanitize user input.
- Do not expose internal errors to users.

## Commands

- Run `npm run lint` after frontend changes.
- Run `npm run test` after backend logic changes.
- Run `npm run build` before deployment-related changes.

This saves you from repeating the same instructions every time.

Using OpenCode In VS Code

OpenCode works well inside VS Code because you can run it directly from the integrated terminal.

Step one: open your project in VS Code.

# [Mac Terminal]
# This opens the current project folder in VS Code.
code .

Step two: open the VS Code integrated terminal.

# [VS Code]
# Use this shortcut to open the integrated terminal.
Ctrl + `

Step three: run OpenCode.

# [VS Code Integrated Terminal]
# This starts OpenCode inside your VS Code project terminal.
opencode

OpenCode can install its VS Code extension automatically when you run opencode from the integrated terminal.

You can also manually install the extension by searching for OpenCode in the VS Code Extension Marketplace.

VS Code Hotkeys

Useful OpenCode VS Code shortcuts:

Cmd + Esc

> Opens OpenCode in a split terminal view on macOS, or focuses an existing OpenCode session.

Ctrl + Esc

> Opens OpenCode in a split terminal view on Windows/Linux.

Cmd + Shift + Esc

> Starts a new OpenCode terminal session on macOS.

Ctrl + Shift + Esc

> Starts a new OpenCode terminal session on Windows/Linux.

Cmd + Option + K

> Inserts file references on macOS, such as @File#L37-42.

Alt + Ctrl + K

> Inserts file references on Windows/Linux.

Configure VS Code As The External Editor

If you want OpenCode commands like /editor or /export to open VS Code, set your EDITOR.

# [Mac / Linux Terminal]
# This tells terminal tools to use VS Code and wait until the file is closed.
export EDITOR="code --wait"

To make it permanent on zsh:

# [Mac Terminal]
# This saves VS Code as your default terminal editor for future zsh sessions.
echo 'export EDITOR="code --wait"' >> ~/.zshrc

Reload your shell:

# [Mac Terminal]
# This reloads your zsh config.
source ~/.zshrc

Essential OpenCode Slash Commands

OpenCode has built-in slash commands and also lets you create your own.

Important built-in commands:

/init

> Initializes OpenCode for the project and creates AGENTS.md.

/connect

> Connects OpenCode to a model provider.

/models

> Opens the model picker so you can select the active model.

/undo

> Reverts the last OpenCode change.

/redo

> Re-applies an undone change.

/share

> Creates a shareable link to the current session.

/help

> Shows available help and commands.

Special Input Syntax

OpenCode has a few important symbols that make it faster.

Use @ To Reference Files

Explain how auth works in @server/controllers/authController.js

> The @ symbol lets you fuzzy-search and reference files from your project.

You can also reference specific lines from VS Code:

Review @server/controllers/trendController.js#L40-120 for security issues

Use @agent To Invoke Subagents

@explore find every place where bookmarks are saved
@general inspect the auth flow and summarize what needs to change
@scout check how the library handles this pattern upstream

> Subagents are useful when you want research, code exploration, or parallel investigation without polluting the main task too much.

Use Tab To Switch Primary Agents

OpenCode has primary agents like Build and Plan.

> Switches between primary agents.

Use Plan when you want analysis first.

Use Build when you want OpenCode to actually edit files.

Build Agent vs Plan Agent

OpenCode ships with two important primary agents.

Build

Build is the default development agent. It can edit files, run commands, and make actual changes.

Use Build for:

  • Implementing features.

  • Fixing bugs.

  • Refactoring files.

  • Writing tests.

  • Updating docs.

Example:

Use Build mode. Update the bookmark flow so guest users see "Create account to bookmark" instead of the generic error. Inspect the frontend save handler and backend auth response before editing.

Plan

Plan is restricted and better for thinking before changing files.

Use Plan for:

  • Reviewing architecture.

  • Explaining code.

  • Creating implementation plans.

  • Checking risky changes before editing.

Example:

Use Plan mode. Inspect the trend approval flow and explain the safest way to add manual approval without breaking the existing auto approval logic.

This is where OpenCode gets useful. You can make it think first, then switch to Build when the plan looks good.

Built-In Subagents

OpenCode also includes subagents.

General

Useful for broad research and multi-step tasks.

@general inspect the repo and find the best place to add this feature

Explore

Useful for read-only codebase exploration.

@explore find all files related to saved trends and bookmarks

Scout

Useful for external dependency research.

@scout check the official docs for this package and compare it with our current usage

Subagents are especially helpful when your project is large and you do not want your main conversation filled with every search result.

Custom Agents

You can create your own agents globally or per project.

Project-level agents go here:

.opencode/agents/

Global agents go here:

~/.config/opencode/agents/

Example custom review agent:

---
description: Reviews code for security, bugs, performance, and maintainability
mode: subagent
model: ollama/qwen3-coder
temperature: 0.1
permission:
  edit: deny
  bash:
    "*": ask
    "git diff": allow
    "git log*": allow
    "grep *": allow
---

You are a code review agent.

Focus on:
- Security issues
- Broken logic
- Performance problems
- Missing validation
- Risky database queries
- Bad error handling

Do not edit files. Only report findings and suggest fixes.

Save it as:

.opencode/agents/review.md

Then use it:

@review check the latest changes and look for security or logic problems

Custom Slash Commands

Custom commands are one of OpenCode’s best features.

You can create reusable commands inside:

.opencode/commands/

Example:

.opencode/commands/test.md
---
description: Run project checks and explain failures
agent: build
---

Run the project checks.

Use this command:

!`npm run check`

If anything fails:
- Explain the exact failure.
- Identify the likely file.
- Suggest the smallest safe fix.

Now inside OpenCode you can run:

/test

That is much faster than typing the same task every time.

Custom Command With Arguments

Create this file:

.opencode/commands/component.md
---
description: Create a React component
agent: build
---

Create a new React component named $ARGUMENTS.

Requirements:
- Use styled-components.
- Keep the component small.
- Export it as default.
- Add short comments only where useful.

Run it like this:

/component TrendCard

$ARGUMENTS becomes TrendCard.

Custom Command With Positional Arguments

Create this file:

.opencode/commands/create-route.md
---
description: Create a backend route and controller method
agent: build
---

Create a new Express route.

Route file: $1
Controller file: $2
Endpoint name: $3

Follow existing project patterns.
Validate input.
Do not add unnecessary dependencies.

Run it:

/create-route server/routes/trendRouter.js server/controllers/trendController.js saveTrend

This gives you reusable project automation without needing to create a full plugin.

Custom Command That Reads Git Changes

Create:

.opencode/commands/review-changes.md
---
description: Review recent Git changes
agent: plan
---

Review the current changes.

Git status:

!`git status --short`

Git diff:

!`git diff`

Look for:
- Broken logic
- Security problems
- Missing validation
- Bad async handling
- Unrelated file changes
- Missing tests

Do not edit files. Only report findings.

Run it:

/review-changes

This is very useful before commits.

Custom Command For Bug Fixing

Create:

.opencode/commands/fix-bug.md
---
description: Investigate and fix a bug safely
agent: build
---

Bug description:

$ARGUMENTS

Steps:
1. Inspect the relevant files first.
2. Explain the likely cause.
3. Make the smallest safe change.
4. Do not refactor unrelated code.
5. Run the most relevant test or lint command.
6. Summarize the changed files.

Run it:

/fix-bug guest user gets generic error when bookmarking a trend

This turns bug fixing into a repeatable workflow.

Essential Project Scripts For OpenCode

OpenCode is better when your project has predictable scripts.

Example root package.json:

{
  "scripts": {
    "dev": "concurrently \"npm run dev --prefix client\" \"npm run dev --prefix server\"",
    "client": "npm run dev --prefix client",
    "server": "npm run dev --prefix server",
    "lint": "eslint .",
    "test": "npm test",
    "build": "npm run build --prefix client",
    "check": "npm run lint && npm run test && npm run build"
  }
}

Good scripts to have:

  • npm run dev - Start local development.

  • npm run lint - Check code quality.

  • npm run test - Run tests.

  • npm run build - Verify production build.

  • npm run check - Run lint, tests, and build together.

OpenCode can run these through its bash tool when permissions allow it.

Configure Permissions

By default, OpenCode can use tools like file reading, editing, writing, bash commands, grep, glob, LSP, patching, web fetch, and web search depending on your configuration.

For safer work, you can require approval for edits and terminal commands.

Create or update:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "edit": "ask",
    "bash": "ask",
    "webfetch": "allow"
  }
}

This means OpenCode asks before editing files or running shell commands.

For stricter backend projects, you can block dangerous commands:

{
  "$schema": "https://opencode.ai/config.json",
  "agent": {
    "build": {
      "permission": {
        "bash": {
          "*": "ask",
          "git status *": "allow",
          "git diff *": "allow",
          "npm run lint": "allow",
          "npm run test": "allow",
          "git push": "ask",
          "rm -rf *": "deny"
        }
      }
    }
  }
}

This is smart because agents are useful, but letting any agent run destructive commands with no friction is how you summon production goblins.

Connect Hosted Models

To connect a hosted provider, start OpenCode.

# [Project Terminal]
# This starts OpenCode in your current project.
opencode

Then run:

/connect

Choose your provider, for example:

  • OpenCode Zen

  • OpenAI

  • Anthropic

  • OpenRouter

  • Gemini

  • Groq

  • Cerebras

  • LLM Gateway

After adding credentials, choose a model:

/models

You can also set a default model in opencode.json.

{
  "$schema": "https://opencode.ai/config.json",
  "model": "openai/gpt-5.1-codex"
}

The format is:

provider_id/model_id

Examples:

openai/gpt-5.1-codex
anthropic/claude-sonnet-4-5-20250929
openrouter/moonshotai/kimi-k2

Use the exact provider/model IDs shown by /models.

Add Existing Provider Models Manually

If a provider exists but one model does not show up yet, you can add it manually.

Example with OpenRouter:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "openrouter": {
      "models": {
        "moonshotai/kimi-k2": {
          "name": "Kimi K2"
        }
      }
    }
  },
  "model": "openrouter/moonshotai/kimi-k2"
}

Then restart OpenCode and run:

/models

Install Ollama For Local Models

If you want models hosted on your own machine, install Ollama.

# [Mac / Linux Terminal]
# This installs Ollama using the official install script.
curl -fsSL https://ollama.com/install.sh | sh

On macOS with Homebrew:

# [Mac Terminal]
# This installs Ollama using Homebrew.
brew install ollama

Start Ollama if it is not already running:

# [Mac / Linux Terminal]
# This starts the Ollama local server.
ollama serve

In another terminal, pull a coding model.

# [Mac / Linux Terminal]
# This downloads a local coding model into Ollama.
ollama pull qwen2.5-coder:7b

You can also use a bigger model if your machine can handle it.

# [Mac / Linux Terminal]
# This downloads a larger local coding model, which needs more RAM or VRAM.
ollama pull deepseek-coder-v2:16b

List installed models:

# [Mac / Linux Terminal]
# This shows the models currently installed in Ollama.
ollama list

Test a model directly:

# [Mac / Linux Terminal]
# This starts a local chat session with the model.
ollama run qwen2.5-coder:7b

Fastest Ollama + OpenCode Setup

Ollama can configure OpenCode automatically.

# [Mac / Linux Terminal]
# This launches OpenCode with Ollama configuration passed in automatically.
ollama launch opencode

To configure OpenCode for Ollama without launching immediately:

# [Mac / Linux Terminal]
# This writes or prepares OpenCode configuration for Ollama without starting a full session.
ollama launch opencode --config

This is the easiest path if you already use Ollama.

Manual Ollama Provider Setup

You can also configure Ollama manually in OpenCode.

Create or update:

~/.config/opencode/opencode.json

Or per project:

opencode.json

Example:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen2.5-coder:7b": {
          "name": "Qwen 2.5 Coder 7B"
        },
        "deepseek-coder-v2:16b": {
          "name": "DeepSeek Coder V2 16B"
        }
      }
    }
  },
  "model": "ollama/qwen2.5-coder:7b"
}

Important pieces:

  • ollama - Your custom provider ID.

  • @ai-sdk/openai-compatible - Used because Ollama exposes an OpenAI-compatible endpoint.

  • baseURL - Ollama’s local API endpoint.

  • models - The exact models you have installed with ollama pull.

  • model - The default OpenCode model.

After saving config, start OpenCode:

# [Project Terminal]
# This starts OpenCode with your local Ollama model config.
opencode

Then select the model:

/models

Choose:

ollama/qwen2.5-coder:7b

Important Ollama Context Note

For coding agents, local models need enough context to handle tool calls, file reads, and project instructions.

If tool calling acts weird, create an Ollama model variant with larger context.

Create a Modelfile:

FROM qwen2.5-coder:7b
PARAMETER num_ctx 32768

Create the model:

# [Mac / Linux Terminal]
# This creates a local Ollama model variant with a larger context window.
ollama create qwen2.5-coder-32k -f Modelfile

Add it to OpenCode config:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen2.5-coder-32k": {
          "name": "Qwen 2.5 Coder 32K"
        }
      }
    }
  },
  "model": "ollama/qwen2.5-coder-32k"
}

Now OpenCode can use the larger-context local model.

Local Model Workflow

A good local OpenCode workflow looks like this:

# [Project Terminal]
# This starts your project in VS Code.
code .
# [VS Code Integrated Terminal]
# This confirms Ollama is running and available.
ollama list
# [VS Code Integrated Terminal]
# This starts OpenCode inside your project.
opencode

Inside OpenCode:

/models

Choose your Ollama model.

Then ask:

Use Plan mode first. Inspect the auth flow and explain where guest users are blocked from saving bookmarks. Do not edit files yet.

Then switch to Build mode with Tab and say:

Now make the smallest safe change. Update the frontend toast for guest users only. Do not change backend auth behavior.

Configure Local + Hosted Models Together

You can keep both local and hosted models in one config.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen2.5-coder:7b": {
          "name": "Qwen 2.5 Coder 7B"
        }
      }
    }
  },
  "model": "ollama/qwen2.5-coder:7b",
  "small_model": "ollama/qwen2.5-coder:7b"
}

Then use /models when you want to switch.

Recommended pattern:

  • Use local Ollama for simple edits, code search, docs, and private experiments.

  • Use stronger hosted models for large refactors, complicated debugging, deep reasoning, and multi-file architecture changes.

Example OpenCode Config For MERN Projects

{
  "$schema": "https://opencode.ai/config.json",
  "model": "ollama/qwen2.5-coder:7b",
  "small_model": "ollama/qwen2.5-coder:7b",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen2.5-coder:7b": {
          "name": "Qwen 2.5 Coder 7B"
        }
      }
    }
  },
  "permission": {
    "edit": "ask",
    "bash": "ask",
    "webfetch": "allow"
  },
  "watcher": {
    "ignore": ["node_modules/**", "dist/**", ".git/**", "client/dist/**"]
  },
  "instructions": ["AGENTS.md", "README.md", "docs/*.md"]
}

This config gives you:

  • A local Ollama model.

  • Safer permissions.

  • Ignored noisy folders.

  • Project instruction files.

Project Work Automation With OpenCode

You can automate repeated development workflows with commands and agents.

Example automation structure:

.opencode/
├── agents/
│   ├── review.md
│   ├── security.md
│   └── planner.md
├── commands/
│   ├── check.md
│   ├── review-changes.md
│   ├── fix-bug.md
│   ├── create-component.md
│   └── release-notes.md
└── plugins/

/check

---
description: Run lint, tests, and build
agent: build
---

Run the full project check.

!`npm run check`

If anything fails:
- Explain the failure.
- Identify the file.
- Suggest a minimal fix.

/security

---
description: Review code for security issues
agent: plan
---

Review the current code and Git diff for security problems.

Git diff:

!`git diff`

Focus on:
- Auth bypass
- Missing validation
- Unsafe query usage
- CORS mistakes
- CSP mistakes
- Leaking tokens
- Bad cookie settings
- Mongo injection risks

Do not edit files.

/release-notes

---
description: Generate release notes from recent commits
agent: plan
---

Generate short release notes from the recent commits.

Recent commits:

!`git log --oneline -20`

Group the notes by:
- Added
- Changed
- Fixed
- Security

Now your workflow becomes:

/review-changes
/check
/security
/release-notes

That is project automation without building a full custom app. Lazy in a good way, not lazy like “ship it and pray.”

Plugins

Plugins let you extend OpenCode with hooks, tools, and integrations.

Project plugins go here:

.opencode/plugins/

Global plugins go here:

~/.config/opencode/plugins/

You can also load npm plugins in opencode.json.

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-helicone-session", "opencode-wakatime", "@my-org/custom-plugin"]
}

Plugins are useful for:

  • Logging sessions.

  • Sending notifications.

  • Protecting .env files.

  • Injecting environment variables.

  • Adding custom tools.

  • Connecting to internal systems.

  • Tracking usage.

  • Adding team-specific workflow behavior.

Local Plugin Example: Protect .env

Create:

.opencode/plugins/protect-env.js

Example concept:

export default async function protectEnvPlugin({ app }) {
  app.on("tool:before", async (event) => {
    const input = JSON.stringify(event.input || "");

    if (input.includes(".env")) {
      throw new Error("Blocked access to .env files for safety");
    }
  });
}

This kind of plugin can stop agents from touching sensitive files.

Keep plugins small and specific. Do not turn one plugin into a haunted mansion of side effects.

Useful Keybinds

OpenCode uses a leader key for many terminal shortcuts.

Default leader:

ctrl+x

Example:

ctrl+x then n

> Starts a new session if using the default keybind behavior.

Useful navigation:

Right

> Cycle to next child/subagent session.

Left

> Cycle to previous child/subagent session.

Up

> Return to parent session.

Useful prompt editing shortcuts:

ctrl+a

> Move to start of line.

ctrl+e

> Move to end of line.

ctrl+k

> Delete from cursor to end of line.

ctrl+u

> Delete from cursor to start of line.

ctrl+w

> Delete previous word.

ctrl+g

> Cancel popovers or abort a running response.

Recommended Daily OpenCode Workflow

# [Project Terminal]
# This opens your project in VS Code.
code .
# [VS Code Integrated Terminal]
# This starts OpenCode in your current project.
opencode

Inside OpenCode:

/init

Then ask:

Use Plan mode first. Inspect this project and summarize the frontend, backend, scripts, and risky areas.

Then:

@explore find all files related to user bookmarks

Then:

/review-changes

Then:

/check

For actual work:

Use Build mode. Make the smallest safe change to fix the bug. Do not refactor unrelated files. Mark the important change with //HERE.

Best Use Cases

OpenCode is especially good for:

  • Fixing small bugs.

  • Understanding unfamiliar repos.

  • Writing tests.

  • Reviewing diffs.

  • Creating components.

  • Updating backend routes.

  • Refactoring carefully.

  • Running project scripts.

  • Generating release notes.

  • Using local models for private code experiments.

  • Creating reusable team commands.

Local Ollama vs Hosted Models

Use Ollama when:

  • You want local/private model usage.

  • You are experimenting.

  • The task is smaller.

  • You want no per-request hosted API cost.

  • You are okay with slower or weaker results depending on your machine.

Use hosted models when:

  • The task is complex.

  • The repo is large.

  • You need better reasoning.

  • You need stronger tool calling.

  • You are debugging weird multi-file issues.

Best practical setup:

Local Ollama model = daily small edits and exploration
Hosted strong model = hard debugging, planning, and big refactors

Why OpenCode Over Claude Code

Claude Code is powerful, especially if you already live fully in Anthropic’s ecosystem.

OpenCode makes more sense when you want:

  • Open-source tooling.

  • More control over configuration.

  • More model flexibility.

  • Local Ollama support.

  • OpenAI-compatible provider support.

  • Custom agents.

  • Custom slash commands.

  • Plugin-based workflow customization.

  • Less provider lock-in.

The biggest reason to choose OpenCode is control. You can wire it into your project the way you want, choose the model you want, run local models when needed, and create repeatable commands for your own dev loop.

Production Notes

  • Commit AGENTS.md so project rules stay consistent.

  • Use Plan mode first for risky changes.

  • Use Build mode only when you are ready for edits.

  • Require approval for bash and edit tools on important repos.

  • Keep custom commands small and focused.

  • Use local Ollama for safe/private exploration.

  • Use stronger hosted models for complicated work.

  • Ignore noisy folders like node_modules, dist, .git, and build output.

  • Review every diff before committing.

  • Do not let agents touch secrets like .env, private keys, or production credentials.

TL;DR

  • OpenCode is an open-source AI coding agent for terminal, IDE, desktop, and browser workflows.

  • It works well in VS Code through the integrated terminal and extension.

  • /connect adds providers.

  • /models selects models.

  • /init creates project instructions.

  • @file references project files.

  • @agent invokes subagents.

  • Tab switches between Build and Plan.

  • .opencode/commands/ lets you create custom slash commands.

  • .opencode/agents/ lets you create custom agents.

  • Ollama lets you run local models through http://localhost:11434/v1.

  • OpenCode is great if you want control, local model support, and less provider lock-in.

Conclusion

OpenCode is not just another AI chat tool. It is a coding agent system that can live inside your project, use your scripts, switch agents, run local or hosted models, and automate repeatable workflows with custom slash commands.

For developers who care about control, privacy, customization, and model flexibility, OpenCode is a very strong option. The real power is not only asking it to write code. The power is building a repeatable development loop around it: plan, inspect, edit, test, review, and ship.

Use hosted models when you need power. Use Ollama when you want local control. Use commands and agents when you want your workflow to stop being a chaotic soup bowl.