Complete reference for JOC file and directory conventions
- Overview
- User-wide Configuration
- Project-level Configuration
- State Directory
- Search Order
- Configuration Files
- Environment Variables
- Best Practices
JOC uses a hierarchical configuration system with two main locations:
| Location | Path | Purpose |
|---|---|---|
| User-wide | ~/.config/opencode/ |
Shared across all projects |
| Project-level | ./.opencode/ |
Project-specific configuration |
| State | ./.opencode/state/ |
Session data (gitignored) |
~/.config/opencode/
├── opencode.jsonc # Global settings
├── AGENTS.md # Global agent instructions
├── agent/ # Shared agents
│ ├── executor.md
│ ├── architect.md
│ └── ...
├── skills/ # Shared skills
│ ├── autopilot/SKILL.md
│ ├── ralph/SKILL.md
│ └── ...
├── commands/ # Shared commands
│ ├── commit.md
│ ├── pr.md
│ └── ...
├── tools/ # Shared tools
│ ├── loadSkill.ts
│ └── ...
├── plugins/ # Shared plugins
│ └── my-plugin.ts
└── rules/ # Shared rules
└── coding-standards.md
Use user-wide configuration for:
- Agents you use in all projects
- Skills you use frequently
- Personal preferences and settings
- Shared commands
- Global tool configurations
<!-- ~/.config/opencode/agent/my-global-agent.md -->
---
name: my-global-agent
description: Agent I use everywhere
model: ollama/glm-5.1:cloud
mode: subagent
---
## Purpose
This agent is available in all my projects.# Override global config location
export OPENCODE_CONFIG_DIR="$HOME/.opencode-config"./.opencode/
├── opencode.jsonc # Project settings
├── AGENTS.md # Project instructions
├── agent/ # Project agents
│ ├── project-specific.md
│ └── ...
├── skills/ # Project skills
│ ├── project-workflow/SKILL.md
│ └── ...
├── commands/ # Project commands
│ ├── build-project.md
│ └── ...
├── tools/ # Project tools
│ ├── project-tool.ts
│ └── ...
├── plugins/ # Project plugins
│ └── project-plugin.ts
├── rules/ # Project rules
│ └── project-conventions.md
└── state/ # Session state (gitignored)
├── ralph-state.json
├── todos.json
└── ...
Use project configuration for:
- Project-specific agents
- Project-specific skills
- Project-specific commands
- Project overrides
- Project state
<!-- .opencode/agent/project-specific.md -->
---
name: project-building-agent
description: Agent specific to this project's build system
model: ollama/glm-5.1:cloud
mode: subagent
---
## Purpose
This agent knows the specific build system of this project.
## Project Context
- Build system: Custom webpack
- Test framework: Jest with custom matcher
- Deployment: Kubernetes./.opencode/state/
├── ralph-state.json # Ralph mode state
├── autopilot-state.json # Autopilot mode state
├── ultrawork-state.json # Ultrawork mode state
├── team-state.json # Team coordination state
├── ultraqa-state.json # QA cycling state
├── todos.json # Task list state
├── project-memory.json # Cross-session knowledge
├── notepad.md # Session notes
├── plans/ # Planning documents
│ └── sprint-5.md
├── logs/ # Audit logs
│ └── 2025-04-18.log
└── artifacts/ # Skill outputs
├── autopilot/
│ └── session-abc/
└── planning/
└── session-def/
State should be gitignored:
# .gitignore
.opencode/state/| File | Purpose |
|---|---|
*-state.json |
Mode state (iteration, status, etc.) |
todos.json |
Task list |
project-memory.json |
Project knowledge (tech stack, notes) |
notepad.md |
Session notes |
plans/ |
Planning documents |
logs/ |
Audit logs |
artifacts/ |
Skill outputs |
When looking for configuration, JOC searches:
1. Project-level: ./.opencode/
2. User-wide: ~/.config/opencode/
User invokes: my-agent
Search order:
1. ./.opencode/agent/my-agent.md
2. ~/.config/opencode/agent/my-agent.md
(if not found in project)
User invokes: /autopilot
Search order:
1. ./.opencode/skills/autopilot/SKILL.md
2. ~/.config/opencode/skills/autopilot/SKILL.md
Project-level configurations override user-wide:
// Configuration merge
const config = {
...userWideConfig, // Base configuration
...projectConfig, // Overrides
skills: [
...projectSkills, // Project skills first
...userWideSkills // Then user-wide
]
}Main configuration file with JSON5 syntax (comments allowed).
Project-level:
User-wide:
{
"provider": {
"ollama": {
"models": {
"glm-5.1:cloud": { "_launch": true },
"kimi-k2.5:cloud": { "_launch": true }
}
}
},
"skills": { "paths": ["./skills"] },
"agents": { "paths": ["./agent"] },
"commands": { "paths": ["./commands"] }
}Agent instructions file with markdown syntax.
# Project Instructions
## Tech Stack
- TypeScript 5.7
- React 19
- Next.js 15
## Coding Standards
- Use const assertions for readonly arrays
- Prefer named exports
- Use Zod for runtime validation
## Project-Specific Rules
- All API routes use /api/v2/ prefix
- Tests go in __tests__ directory
- Use custom hooks for data fetchingFor custom tools:
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["./tools/**/*"],
"exclude": ["node_modules"]
}| Variable | Default | Description |
|---|---|---|
OPENCODE_CONFIG_DIR |
~/.config/opencode |
Global config directory |
OMC_QUIET |
0 |
Quiet mode (0-2) |
OLLAMA_HOST |
(ollama default) | Ollama API host |
OLLAMA_API_KEY |
(none) | Ollama API key |
# Custom config directory
export OPENCODE_CONFIG_DIR="$HOME/.opencode-config"
# Quiet mode (suppress non-essential output)
export OMC_QUIET=1
# More quiet (suppress more output)
export OMC_QUIET=2
# Custom Ollama host
export OLLAMA_HOST="https://api.ollama.ai"
export OLLAMA_API_KEY="your-key"{
"provider": {
"ollama": {
"models": {
"glm-5.1:cloud": {
"_launch": true,
"env": {
"OLLAMA_HOST": "${OLLAMA_HOST}",
"OLLAMA_API_KEY": "${OLLAMA_API_KEY}"
}
}
}
}
}
}my-project/
├── .opencode/
│ ├── opencode.jsonc # Project config
│ ├── AGENTS.md # Project instructions
│ ├── agent/ # Project agents
│ ├── skills/ # Project skills
│ ├── commands/ # Project commands
│ ├── state/ # (gitignored)
│ └── .gitignore # Ignore state/
├── .gitignore # Also ignore state/
└── ... (project files)
# .opencode/.gitignore
state/
# Keep config
!.opencode.jsonc
!AGENTS.md
!agent/
!skills/
!commands/
!tools/
!rules/
!plugins/
!templates/| Type | Shared (User-wide) | Project-specific |
|---|---|---|
| Common agents | ✅ | - |
| Project agents | - | ✅ |
| Common skills | ✅ | - |
| Project skills | - | ✅ |
| Global settings | ✅ | - |
| Project overrides | - | ✅ |
| State | - | ✅ |
User-wide config:
├── Base provider settings
├── Common agents
├── Common skills
└── Common commands
Project config:
├── Provider overrides (merges with user-wide)
├── Project-specific agents (adds to user-wide)
├── Project-specific skills (adds to user-wide)
├── Project-specific commands (adds to user-wide)
└── Project state (not inherited)
- Installation - Setting up configuration
- Agents - Agent configuration
- Skills - Skill configuration
- Tools - Tool configuration
{ "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "models": { "glm-5.1:cloud": { "_launch": true } } } }, "tools": { "loadSkill": "./tools/loadSkill.ts" }, "plugin": [ "./plugins/project-plugin.ts" ], "instructions": ["AGENTS.md"], "skills": { "paths": ["./skills"] }, "agents": { "paths": ["./agent"] }, "commands": { "paths": ["./commands"] } }