Konfigurationsdatei-Details
Das Verständnis des Konfigurationssystems von Opencode ist der Schlüssel zur fortgeschrittenen Nutzung.
Konfigurationsdateispeicherorte
| Konfigurationsdatei | Speicherort | Geltungsbereich |
|---|---|---|
| Globale Konfiguration | ~/.config/opencode/opencode.json | Alle Projekte |
| Projektkonfiguration | ./opencode.json | Aktuelles Projekt |
Konfigurationsformat: JSONC
Opencode unterstützt JSONC-Format (JSON mit Kommentaren):
{
"$schema": "https://opencode.ai/config.json",
// Theme-Konfiguration
"theme": "opencode-dark",
/* Hauptmodell-Einstellungen */
"model": "anthropic/claude-sonnet-4-5"
}
Konfigurationspriorität
Priorität (niedrig bis hoch):
- Remote-Organisationskonfiguration
- Globale Konfiguration
- Umgebungsvariablenkonfiguration
- Projektkonfiguration
- Projektverzeichniskonfiguration
- Laufzeitkonfiguration (höchste)
Kernkonfigurationsoptionen
1. Modellkonfiguration
{
"model": "anthropic/claude-sonnet-4-5",
"small_model": "anthropic/claude-haiku-4-5",
"enabled_providers": ["anthropic", "openai"]
}
2. Berechtigungskonfiguration
{
"permission": {
"read": {
"*": "allow",
"*.env": "deny"
},
"edit": "ask",
"bash": {
"*": "ask",
"git status": "allow",
"rm -rf": "deny"
}
}
}
Berechtigungswerte:
"allow"- Direkt zulassen"ask"- Jedes Mal fragen"deny"- Direkt ablehnen
3. Agent-Konfiguration
{
"agent": {
"code-reviewer": {
"description": "Code-Review-Experte",
"model": "anthropic/claude-sonnet-4-5",
"tools": {
"write": false,
"edit": false
}
}
}
}
Praktische Konfigurationsvorlagen
Minimale Konfiguration
{
"model": "anthropic/claude-sonnet-4-5",
"permission": {
"edit": "ask",
"bash": "ask"
}
}
Nächste Schritte
Zusammengestellt von der OpenCodex-Community.