~/.config/opencode/)~/.config/opencode/
├── opencode.json # Global config
├── AGENTS.md # Auto-loaded instructions
├── CLAUDE.md # Auto-loaded instructions
├── agent/ # Custom agents
│ ├── my-agent.md
│ └── category/
│ └── nested-agent.md
├── command/ # Custom commands
│ └── my-command.md
└── plugin/ # Custom plugins
└── my-plugin.ts
.opencode/)your-repo/
├── opencode.json # Repo config
├── .opencode/
│ ├── AGENTS.md # Auto-loaded instructions
│ ├── agent/ # Project-specific agents
│ │ └── my-agent.md
│ ├── command/ # Project-specific commands
│ │ └── my-command.md
│ └── plugin/ # Project-specific plugins
│ └── my-plugin.ts
└── src/
Instruction files (loaded automatically as system prompts):
AGENTS.md - Custom instructions (global or local)CLAUDE.md - Legacy Claude instructionsCONTEXT.md - Deprecated, but still worksConfig files (merged in order):
~/.config/opencode/opencode.json (global)opencode.json files from repo root up to current directory.opencode/ folders in hierarchy| Folder | Files | Purpose |
|---|---|---|
agent/ |
*.md |
Custom agents with system prompts |
command/ |
*.md |
Custom slash commands |
plugin/ |
*.ts, *.js |
Custom tools and extensions |
⚠️ Use singular names only: agent/, NOT agents/
@ SymbolIn commands and templates:
# Relative to repo root
@README.md
@src/main.ts
# Home directory
@~/my-file.txt
# Absolute path
@/absolute/path/file.txt
# If file doesn't exist, looks for agent
@my-agent
Resolution order:
~/ → resolve to home directoryInstance.worktree)For arbitrary paths, use instructions field:
{
"instructions": [
"~/opencode/context/my-context.md",
"docs/**/*.md",
".opencode/context/**/*.md"
]
}
Paths can be:
/path/to/file.md~/path/to/file.mddocs/instructions.md**/*.mdConfigs merge with priority (later overrides earlier):
~/.config/opencode/).opencode/ folders)OPENCODE_CONFIG)Agents, commands, and plugins from all locations are merged together.
| What | Where | How |
|---|---|---|
| Global agent | ~/.config/opencode/agent/name.md |
Auto-loaded |
| Local agent | .opencode/agent/name.md |
Auto-loaded |
| Global command | ~/.config/opencode/command/name.md |
Auto-loaded |
| Local command | .opencode/command/name.md |
Auto-loaded |
| Global instructions | ~/.config/opencode/AGENTS.md |
Auto-loaded |
| Local instructions | .opencode/AGENTS.md or AGENTS.md |
Auto-loaded |
| Custom files | Anywhere | Use instructions config or @ symbol |