Skip to content

@tank/opencode-config-mastery

0.1.0
Skill

Description

Expert OpenCode configuration. Covers opencode.json schema, MCP server setup (local/remote/OAuth), provider and model configuration (75+ providers, custom/local), plugin management, custom commands, rules/instructions, keybinds, permission system, trusted MCP server catalog, and security best practices..

Download
Unsafe
tank install @tank/opencode-config-mastery

OpenCode Configuration Mastery

Core Principles

  1. Start minimal, add complexity โ€” A valid config is just { "$schema": "https://opencode.ai/config.json", "model": "anthropic/claude-sonnet-4-5" }. Add more only when you need it.
  2. Configs deep-merge โ€” Global + project configs combine. Arrays concatenate. Objects merge with project-level winning conflicts.
  3. OpenCode MCP โ‰  Claude Desktop MCP โ€” Different format. Root key "mcp", command as array, "environment" not "env", explicit "type" required.
  4. Context budget is finite โ€” Every MCP tool costs tokens. 50+ tools โ‰ˆ 67k tokens. Scope tools per-agent, use lazy loading, disable unused servers.

Quick-Start Recipes

"Set up OpenCode from scratch"

  1. Create opencode.json in project root:
    { "$schema": "https://opencode.ai/config.json" }
    
  2. Run opencode โ†’ use /connect to authenticate a provider
  3. Pick your model: set "model": "provider/model-id" โ†’ See references/providers-and-models.md for all providers

"Add an MCP server"

Local (subprocess): "mcp": { "name": { "type": "local", "command": ["npx", "-y", "@pkg/name"] } }

Remote (HTTP): "mcp": { "name": { "type": "remote", "url": "https://mcp.example.com/mcp" } }

โ†’ See references/mcp-servers.md for OAuth, tool management, all options โ†’ See references/plugins-and-ecosystem.md for trusted server catalog

"Add a custom/local model (Ollama, LM Studio)"

{
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "options": { "baseURL": "http://localhost:11434/v1" },
      "models": { "llama2": { "name": "Llama 2" } }
    }
  },
  "model": "ollama/llama2"
}

โ†’ See references/providers-and-models.md for all local setups

"Add a plugin"

{
  "plugin": ["oh-my-opencode", "opencode-morph-fast-apply"]
}

โ†’ See references/plugins-and-ecosystem.md for trusted plugin list

"Create a custom slash command"

Create .opencode/commands/my-command.md:

---
description: What this command does
input: optional
---
Instructions for the agent. User input available as $INPUT.

โ†’ See references/agents-commands-rules.md for full format

"Lock down permissions"

{
  "permission": {
    "edit": "ask",
    "bash": { "*": "ask", "rm *": "deny", "git push *": "deny" },
    "webfetch": "deny"
  }
}

โ†’ See references/agents-commands-rules.md for permission patterns

"Reduce context usage from MCP tools"

  1. Disable tools globally, enable per-agent:
    {
      "tools": { "github_*": false },
      "agent": { "pr-reviewer": { "tools": { "github_*": true } } }
    }
    
  2. Install lazy loader: "plugin": ["opencode-mcp-tool-search"]
  3. Disable unused servers: "mcp": { "unused": { "enabled": false } }

Decision Trees

What to Configure

NeedConfig KeyReference
Pick a modelmodel, small_modelproviders-and-models.md
Add LLM providerproviderproviders-and-models.md
Connect external toolmcpmcp-servers.md
Install pluginpluginplugins-and-ecosystem.md
Control what agents can dopermissionagents-commands-rules.md
Add reusable commands.opencode/commands/agents-commands-rules.md
Set project conventionsinstructionsagents-commands-rules.md
Override agent model/behavioragentagents-commands-rules.md
Customize keybindskeybindsagents-commands-rules.md

MCP: Local vs Remote

SignalUse LocalUse Remote
npx/uvx package availableโœ“
Vendor provides hosted endpointโœ“
Need OAuth authenticationโœ“
Air-gapped environmentโœ“
Docker-based serverโœ“
Want zero local installโœ“

Provider Selection

NeedProviderAuth
Best coding qualityAnthropic/connect or API key
Budget-consciousOpenCode Zen/connect
Enterprise/complianceAzure OpenAI, BedrockIAM + config
Offline/air-gappedOllama, llama.cppLocal, no auth
Multi-model accessOpenRouterAPI key
Existing subscriptionGitHub Copilot/connect

Security Checklist (Before Adding MCP Server)

โ˜ Known vendor or significant GitHub stars ยท โ˜ Filesystem scoped to specific dirs ยท โ˜ API keys use {env:VAR} ยท โ˜ Unused servers disabled ยท โ˜ Versions pinned (no @latest) ยท โ˜ Permissions restrict dangerous tools โ†’ See references/plugins-and-ecosystem.md for OWASP MCP Top 10

Anti-Patterns

PatternFix
"mcpServers" root keyUse "mcp" (OpenCode format)
"command": "npx" + "args"Use "command": ["npx", ...] array
"env": {} for MCPUse "environment": {}
Missing "type" on MCPAdd "type": "local" or "remote"
API keys in configUse "{env:VAR_NAME}" substitution
50+ MCP tools globallyPer-agent scoping or lazy loading
@latest in MCP commandsPin specific versions

Reference Files

FileContents
references/config-schema.mdFull opencode.json schema, all top-level keys, file locations, precedence, merging, variable substitution, LSP/formatter config
references/mcp-servers.mdLocal/remote MCP setup, OAuth, tool naming, per-agent scoping, CLI commands, quick-start examples for popular servers
references/providers-and-models.mdProvider setup, credentials, all major providers, custom/local providers (Ollama, LM Studio, llama.cpp), model selection
references/plugins-and-ecosystem.mdOpenCode plugins (oh-my-opencode, morph, etc.), MCP registries, community servers by category, OWASP security, context budget
references/agents-commands-rules.mdAgent config in JSON, custom commands, rules/instructions, keybinds, permission system, common profiles

Command Palette

Search packages, docs, and navigate Tank