OpenCode.ai comprehensive reference documentation for configuration, customization, and troubleshooting...
Use when working with OpenCode TUI, CLI commands, IDE integration, agent configuration, tool development, MCP server setup, plugin creation, or SDK development.
Installation:
curl -fsSL https://opencode.ai/install | bash
npm install -g opencode
Essential Commands:
opencode # Launch TUI
opencode run "prompt" # Non-interactive mode
opencode --version # Check version
Core Features:
Priority:
1. Command-line flags (highest)
2. Environment variables
3. Project config (./opencode.json)
4. Global config (~/.config/opencode/opencode.json)
5. Built-in defaults (lowest)
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["plugin-name@version"],
"model": "provider/model-id",
"provider": {
"provider-id": {
"options": {},
"models": {}
}
},
"agent": {
"agent-name": {
"description": "Agent description",
"model": "provider/model",
"tools": {},
"skills": []
}
},
"tools": {},
"mcp": {},
"permission": {}
}
{
"agent": {
"jasaweb-architect": {
"description": "JasaWeb architectural specialist",
"mode": "subagent",
"model": "google/antigravity-claude-sonnet-4-5-thinking",
"temperature": 0.2,
"tools": {"write": true, "edit": true, "bash": true, "read": true},
"skills": ["skill-builder", "moai-opencode"]
}
}
}
Levels:
allow: Auto-approve execution
ask: Request user approval
deny: Block execution
import { tool } from "@opencode-ai/plugin";
export default tool({
description: "Tool description",
args: {
param1: tool.schema.string().describe("Parameter description")
},
async execute(args) {
return "Tool result";
}
});
{
"mcp": {
"github": {
"type": "local",
"command": ["npx", "-y", "@modelcontextprotocol/server-github"],
"environment": {
"GITHUB_TOKEN": "{env:GITHUB_TOKEN}"
}
},
"filesystem": {
"type": "local",
"command": ["npx", "-y", "@modelcontextprotocol/server-filesystem"],
"args": ["/path/to/files"]
}
}
}
my-plugin/
āāā package.json
āāā src/
ā āāā index.js
ā āāā agent.js
ā āāā skill.js
ā āāā tool.js
āāā README.md
{
"name": "my-plugin",
"version": "1.0.0",
"main": "src/index.js",
"opencode": {
"agents": ["src/agent.js"],
"skills": ["src/skill.js"],
"tools": ["src/tool.js"]
}
}
Keyboard Shortcuts:
Cmd+Esc (macOS) / Ctrl+Esc (Windows/Linux): Quick launchCmd+Shift+Esc / Ctrl+Shift+Esc: New sessionCmd+Option+K / Alt+Ctrl+K: Insert file referenceSetup:
opencode in integrated terminal// Reference syntax
@src/main.ts // File reference
@src/main.ts#L37-42 // Line range reference
@folder/ // Directory reference
{
"provider": {
"anthropic": {
"options": {
"apiKey": "{env:ANTHROPIC_API_KEY}",
"baseURL": "https://api.anthropic.com"
}
},
"google": {
"npm": "@ai-sdk/google",
"options": {
"project": "{env:GOOGLE_CLOUD_PROJECT}"
}
}
}
}
{
"models": {
"claude-sonnet-4-5-thinking": {
"variants": {
"low": {
"thinkingConfig": {
"thinkingBudget": 8192
}
},
"max": {
"thinkingConfig": {
"thinkingBudget": 32768
}
}
}
}
}
}
{
"command": {
"test": {
"description": "Run test suite",
"command": "npm test"
},
"lint": {
"description": "Run linter",
"command": "npm run lint"
}
}
}
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@company/opencode-enterprise"],
"enterprise": {
"sso": {
"provider": "okta",
"domain": "company.okta.com"
},
"ai_gateway": {
"url": "https://ai-gateway.company.com"
}
}
}
{
"permission": {
"write": "ask",
"bash": "allow",
"network": "deny"
},
"security": {
"allowed_paths": ["/workspace/project"],
"blocked_commands": ["rm -rf", "sudo"]
}
}
Plugin Loading Errors
# Clear cache
rm -rf ~/.cache/opencode
# Reinstall plugins
npm install -g oh-my-opencode@latest
Authentication Problems
# Clear auth
rm ~/.config/opencode/auth.json
# Re-authenticate
opencode auth login
Performance Issues
# Check logs
tail -f ~/.local/share/opencode/log/latest.log
# Monitor resources
opencode --log-level DEBUG
# Enable debug logging
opencode --log-level DEBUG
# Print logs to stdout
opencode --print-logs
# Check configuration
opencode --config-check
When using this skill for JasaWeb development:
This skill provides comprehensive OpenCode.ai documentation while maintaining JasaWeb's worldclass development standards.