Complete toolkit for configuring and extending OpenCode: agent creation, custom slash commands, configuration management, plugin development, and SDK usage.
98
98%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Advisory
Suggest reviewing before use
Navigation hub for OpenCode configuration tasks.
Add a provider — create/edit opencode.json in your project root:
{
"providers": [
{
"id": "anthropic",
"baseEnv": "ANTHROPIC_API_KEY",
"models": [
{ "id": "claude-sonnet-4-5", "default": true }
]
}
]
}Add project instructions — create AGENTS.md in project root:
## Workflow Rules
- Run `npm test` after every code change.
- Never modify `package.json` without user confirmation.Validate config:
jq . opencode.json && opencode run "test"opencode.json.AGENTS.md instructions.| File | Purpose |
|---|---|
opencode.json | Main OpenCode runtime configuration |
AGENTS.md | Project-level behavior and workflow rules |
.env/shell env | Provider keys and environment-backed configuration |
references/*.md | Deep configuration guidance |
Out of scope: plugin authoring and custom tool SDK development.
jq . opencode.json >/dev/null && rg -n "API_KEY|baseEnv|permission" opencode.json .env*opencode run "test"rg -n "model|provider|permission|instructions" opencode.json AGENTS.mdopencode run "test"jq . opencode.json >/dev/nullrg -n "API_KEY|baseEnv|permission" opencode.json .env*opencode.json — provider with baseEnv pattern{
"providers": [
{
"id": "openai",
"baseEnv": "OPENAI_API_KEY",
"models": [
{ "id": "gpt-4o-2024-08-06", "default": true }
]
}
],
"permissions": {
"filesystem": { "read": ["./src", "./docs"], "write": ["./src"] },
"shell": { "allow": ["npm test", "jq"] }
},
"formatter": { "enabled": true }
}AGENTS.md template# Project Agent Instructions
## Scope
- Work only within `src/` and `docs/` unless explicitly told otherwise.
## Workflow Rules
- Run `npm test` after every code change.
- Never modify `opencode.json` directly; propose changes for human review.
## Constraints
- Do not execute destructive shell commands (rm -rf, git push --force).
- Prefer read operations before any write or delete action."apiKey": "sk-..."."baseEnv": "OPENAI_API_KEY"."model": "gpt-4".opencode run "test" and validate behavior.opencode.json is runtime config (providers, permissions, tools). AGENTS.md is behavioral guidance for the agent. Mixing them causes ignored instructions or broken config parsing.instructions: blocks inside opencode.json, or adding JSON config snippets inside AGENTS.md.opencode.json; workflow rules, constraints, conventions → AGENTS.md.~/.config/opencode/opencode.json) bleeds into unrelated projects, causing unexpected behavior across your entire environment.npm test to the global shell allowlist, or setting a project-specific model globally.opencode.json. Reserve global config for cross-project defaults (personal API keys via baseEnv, editor preferences).models with only default: true and no IDdefault: true without a model id field is silently ignored or resolves to provider defaults, which may change between releases.{ "default": true } with no id key.default: true with a fully-qualified id: { "id": "claude-sonnet-4-5", "default": true }..env loader > project opencode.json > global opencode.json. Debugging config mismatches without knowing this order leads to wasted time.opencode.json to fix an issue caused by a shell env override.echo $OPENAI_API_KEY), then work downward.| Topic | Reference |
|---|---|
| Provider setup and model mapping | references/provider-configuration.md |
| Permission structure and patterns | references/permission-schema.md |
| Full config field reference | references/config-schema.md |