Configure OpenCode via opencode.json and AGENTS.md with deterministic provider setup, model selection, permission policies, formatter behavior, and environment variable handling; use when editing opencode configuration, setting model/provider defaults, tightening agent permissions, or troubleshooting OpenCode config behavior.
70
86%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
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.a1083f4
Also appears in
since Jun 29, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.