Back to the tools

Coding agents

opencode

opencode is an open source terminal AI coding agent with a client and server split, 75+ model providers and MCP tools. We use it for scripted code work.

3 min read

opencode is an open source AI coding agent that runs primarily in the terminal. It is not a plugin inside an editor: started in a project directory it reads, edits and runs the code there. Desktop and editor variants exist as well; the source is MIT licensed at github.com/anomalyco/opencode.

Two design decisions matter for us. The core is not tied to a single model provider, and the interface and the engine run as separate processes.

Install and first run

Install channels include a shell script, an npm package, Homebrew, Arch packages, Nix and a container image. Windows is covered by Scoop, Chocolatey, npm and mise; Bun-based installation is still in progress per the docs.

The first useful command is /init: it reads the project and writes an AGENTS.md file into the repository root, so the agent picks up the project structure and coding patterns. Tab switches between the built-in agents: build works with full access, plan is read only, does not edit files and asks before running shell commands. For larger work, ask for a plan, review it, then allow the change.

Models and providers

The tool uses the AI SDK and the Models.dev catalogue, supports 75+ providers according to the docs, and can run local models. Credentials are collected by /connect and stored in a local auth file. An OpenAI-compatible endpoint can be added as a custom provider with its own baseURL and apiKey, and with declared context and output limits; blacklist and whitelist narrow the model picker.

Swapping the model therefore does not mean swapping the tool.

Client and server

Starting opencode brings up a terminal interface and a server. The server publishes an OpenAPI 3.1 spec on its /doc endpoint for client generation. A standalone server starts with opencode serve, by default on 127.0.0.1:4096, with flags for port, hostname and allowed origins. Password protection uses an environment variable, with opencode as the default user name.

The API covers projects, sessions, providers and agents, and events arrive over a server-sent stream. The interface itself can be driven through its own endpoints, which is what the editor extensions use and what lets us start the agent from our own scripts. A Docker container is one option when the server should not run on the workstation.

Tools and permissions

opencode accepts MCP servers, local and remote, configured under the mcp section. Remote servers get an automatic OAuth flow, and the token is stored by the tool. The docs warn that every MCP server consumes context, and with a large tool set that budget runs out quickly.

Permissions are set in the permission section: each action can be allowed, prompted or denied, rules match by pattern and the last matching rule wins. Shell commands accept separate patterns, so git can be allowed while deletion is blocked. Defaults are permissive: most actions run without approval, reading .env files is denied, and approval is required outside the project directory and for a repeated identical call. Auto approval passes everything not explicitly denied, so it belongs in a controlled environment.

What to watch

  • Quality depends on the chosen model, not on the tool.
  • Permission defaults are permissive: write narrow rules before handing over a large task.
  • Many MCP tools eat context, and the budget can run out.
  • Custom provider setup can fail when the package name and the endpoint do not match the provider.
  • The desktop application is marked beta in the repository.

Further reading

We use opencode to hand over well-bounded, recurring code work in a way that a script can start, as the second terminal agent next to Claude Code.

Tags
  • AI coding agent
  • terminal
  • MCP
  • open source
  • client-server