5.5 KiB
5.5 KiB
OpenCode Spec (Config, Agents, Plugins)
Last verified: 2026-04-19
Primary sources
https://opencode.ai/docs/config/
https://opencode.ai/docs/tools
https://opencode.ai/docs/permissions
https://opencode.ai/docs/plugins/
https://opencode.ai/docs/agents/
https://opencode.ai/docs/commands/
https://opencode.ai/docs/skills
https://opencode.ai/config.json
Config files and precedence
- OpenCode supports JSON and JSONC configs.
- Config sources are merged rather than replaced, with global and project config both participating in the final config.
- Global config is stored at
~/.config/opencode/opencode.json, and project config isopencode.jsonin the project root. - Custom config file and directory can be provided via
OPENCODE_CONFIGandOPENCODE_CONFIG_DIR. - The
.opencodeand~/.config/opencodedirectories use plural subdirectory names (agents/,commands/,modes/,plugins/,skills/,tools/,themes/).
Core config keys
modelandsmall_modelset the primary and lightweight models;providerconfigures provider options.toolsis still supported but deprecated as of OpenCode v1.1.1; permissions are now the canonical control surface.permissioncontrols tool approvals and can be configured globally or per tool, including pattern-based rules.mcp,instructions,disabled_providers,enabled_providers, andpluginare supported config sections.plugincan list npm packages to load at startup.skills.pathsandskills.urlscan add extra skill discovery locations, but CE should not depend on them until the layout is smoke-tested locally with OpenCode.
Tools
- OpenCode ships with built-in tools, and permissions determine whether each tool runs automatically, requires approval, or is denied.
- Tools are enabled by default; permissions provide the gating mechanism.
Permissions
- Permissions resolve to
allow,ask, ordenyand can be configured globally or per tool, with pattern-based rules. - Defaults are permissive, with special cases such as
.envfile reads. - Agent-level permissions override the global permission block.
Agents
- Agents can be configured in
opencode.jsonor as markdown files in~/.config/opencode/agents/or.opencode/agents/. - Agent config supports
mode,model,variant,temperature,top_p,hidden,steps,options,permission, and other schema fields.toolsstill exists but is deprecated. modecan beprimary,subagent, orall; omitted mode defaults toall.hidden: truehides subagents from the@autocomplete menu.permission.taskcontrols which subagents an agent may invoke.- Model IDs use the
provider/model-idformat.
Skills
- Skills are reusable
SKILL.mddefinitions loaded on demand through OpenCode's nativeskilltool. - OpenCode searches direct child skill directories in its built-in roots:
.opencode/skills/<name>/SKILL.md~/.config/opencode/skills/<name>/SKILL.md.claude/skills/<name>/SKILL.md~/.claude/skills/<name>/SKILL.md.agents/skills/<name>/SKILL.md~/.agents/skills/<name>/SKILL.md
- The config schema also exposes
skills.pathsandskills.urlsfor extra skill sources. Do not switch CE to those until tested against a local OpenCode install; direct~/.config/opencode/skills/<name>/SKILL.mdremains the stable writer shape. - Skill frontmatter recognizes
name,description,license,compatibility, andmetadata; unknown fields are ignored. - Skill names must be lowercase alphanumeric with single hyphen separators and must match the directory name.
Commands
- Commands can be configured in
opencode.jsonor as Markdown files in~/.config/opencode/commands/or.opencode/commands/. - Markdown command frontmatter can include fields such as
description,agent,model, andsubtask; the body becomes the prompt template. - If a command targets an agent whose mode is
subagent, OpenCode invokes it as a subagent by default.subtask: truecan force subagent invocation.
Plugins and events
- Local plugins are loaded from
.opencode/plugins/and~/.config/opencode/plugins/. npm plugins can be listed inplugininopencode.json. - Plugins are JavaScript/TypeScript modules. Each exported plugin function receives OpenCode context and returns hooks/event handlers.
- Local plugins and custom tools can use npm dependencies declared in a
package.jsonin the OpenCode config directory; OpenCode runsbun installat startup.
Notes for this repository
- The current documented global CE install root should stay
~/.config/opencode, not~/.agents, to avoid conflicts with harnesses that also read~/.agents. - The current CE writer shape is still appropriate in April 2026:
~/.config/opencode/opencode.json~/.config/opencode/agents/*.md~/.config/opencode/commands/*.mdonly when a source plugin ships commands~/.config/opencode/plugins/*.ts~/.config/opencode/skills/*/SKILL.md
- OpenCode's plugin system is useful for JS/TS hooks and custom tools, but current docs do not describe a native marketplace command that consumes CE's
.claude-plugin/marketplace.jsonand installs the full skills/agents/commands payload. - Keep the custom Bun writer until OpenCode documents a native distribution path for packaged skills and agents.
- The
compound-engineeringplugin currently emits skills and subagent Markdown files for OpenCode. It should not emit deprecatedtoolsconfig; permission config is enough for non-default permission modes.