1# Configuration Development Guide
2
3## Merge Rules
4
5When adding new fields to config structs (`Config`, `Options`, `MCPConfig`, `LSPConfig`, `TUIOptions`, `Tools`, `ProviderConfig`), you **must** update the corresponding `merge()` method in `config.go` and add test cases to `merge_test.go`.
6
7### Merge Behavior Patterns
8
9Each field type has a specific merge strategy:
10
11| Type | Strategy | Example |
12|------|----------|---------|
13| **Booleans** | `true` if any config has `true` | `Disabled`, `Debug`, `Progress` |
14| **Strings** | Later value replaces earlier | `Model`, `InitializeAs`, `TrailerStyle` |
15| **Slices (paths/tools)** | Appended, sorted, deduped | `SkillsPaths`, `DisabledTools` |
16| **Slices (args)** | Later replaces earlier entirely | `Args` in LSPConfig |
17| **Maps** | Merged, later values overwrite keys | `Env`, `Headers`, `Options` |
18| **Timeouts** | Max value wins | `Timeout` in MCPConfig/LSPConfig |
19| **Pointers** | Later non-nil replaces earlier | `MaxTokens`, `Temperature` |
20| **Structs** | Call sub-struct's `merge()` method | `TUI`, `Tools` |
21
22### Adding a New Config Field
23
241. Add the field to the appropriate struct in `config.go`
252. Add merge logic to the struct's `merge()` method following the patterns above
263. Add a test case in `merge_test.go` verifying the merge behavior
274. Run `go test ./internal/config/... -v -run TestConfigMerging` to verify