You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(config): precedence and project config discovery
- Make the numbered precedence list easier to understand at a glance by
changing it to a table.
- Update the traversal and target documentaiton for configuration files
based on the current codebase
Signed-off-by: Trevor Vaughan <peiriannydd@gmail.com>
Copy file name to clipboardExpand all lines: packages/web/src/content/docs/config.mdx
+25-15Lines changed: 25 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,24 +33,27 @@ different order of precedence.
33
33
Configuration files are **merged together**, not replaced.
34
34
:::
35
35
36
-
Configuration files are merged together, not replaced. Settings from the following config locations are combined. Later configs override earlier ones only for conflicting keys. Non-conflicting settings from all configs are preserved.
36
+
Settings from the following config locations are combined. Later configs override earlier ones only for conflicting keys. Non-conflicting settings from all configs are preserved.
37
37
38
38
For example, if your global config sets `autoupdate: true` and your project config sets `model: "anthropic/claude-sonnet-4-5"`, the final configuration will include both settings.
39
39
40
40
---
41
41
42
42
### Precedence order
43
43
44
-
Config sources are loaded in this order (later sources override earlier ones):
44
+
Config sources are merged in this order, lowest to highest precedence (later sources override earlier ones):
This means project configs can override global defaults, and global configs can override remote organizational defaults. Managed settings override everything.
56
59
@@ -108,17 +111,24 @@ Global config overrides remote organizational defaults.
108
111
109
112
### Per project
110
113
111
-
Add `opencode.json` in your project root. Project config has the highest precedence among standard config files - it overrides both global and remote configs.
114
+
Starting in the current working directory, OpenCode traverses up to the nearest Git directory and merges every match it finds along the way.
115
+
116
+
The following files are picked up **at any level between the working directory and the repository root**, in this order:
117
+
118
+
-`opencode.json`
119
+
-`opencode.jsonc`
120
+
-`.opencode/opencode.json`
121
+
-`.opencode/opencode.jsonc`
122
+
123
+
Working directory config overrides the global config and the remote well-known defaults. Organization, managed, and MDM settings still take priority over it (see the precedence order above).
112
124
113
125
For project-specific TUI settings, add `tui.json` alongside it.
114
126
115
127
:::tip
116
-
Place project specific config in the root of your project.
128
+
Place project specific config in a `.opencode/` directory at your project root.
117
129
:::
118
130
119
-
When OpenCode starts up, it first looks for a config file in the current directory, then traverses up to the nearest Git directory.
120
-
121
-
This is also safe to be checked into Git and uses the same schema as the global one.
131
+
This is safe to be checked into Git and respects the global configuration schema.
0 commit comments