[FEATURE]: add OPENCODE_NO_PARENT_CONFIG to disable parent directory config inheritance #7202

Closed
opened 2026-02-16 18:06:26 -05:00 by yindo · 1 comment
Owner

Originally created by @kynnyhsap on GitHub (Jan 22, 2026).

Originally assigned to: @thdxr on GitHub.

Problem

When running opencode in a subdirectory that has its own opencode.json, the config from parent directories is automatically merged via findUp. This can cause unwanted config inheritance.

Example:

~/project/opencode.json          # parent config with MCP servers A, B, C
~/project/agent/opencode.json    # child config with MCP server D

Running from ~/project/agent/ loads both configs and sees all MCP servers (A, B, C, D), even when you only want the local config.

Use Case

When developing multiple agents locally, each with their own config, you want isolation - only the config in the current directory should be loaded, not inherited from parent directories.

Proposed Solution

Add OPENCODE_NO_PARENT_CONFIG environment variable that limits findUp to only search the current directory, not walk up to parent directories.

OPENCODE_NO_PARENT_CONFIG=true opencode

This would skip:

  • opencode.json / opencode.jsonc from parent directories
  • .opencode/ directories from parent directories
  • AGENTS.md / CLAUDE.md from parent directories

Global config (~/.config/opencode/) would still be loaded unless combined with OPENCODE_DISABLE_GLOBAL_CONFIG=true.

Related

  • #10021 - Request for OPENCODE_DISABLE_GLOBAL_CONFIG
  • #10013 - PR implementing OPENCODE_DISABLE_GLOBAL_CONFIG
Originally created by @kynnyhsap on GitHub (Jan 22, 2026). Originally assigned to: @thdxr on GitHub. ## Problem When running opencode in a subdirectory that has its own `opencode.json`, the config from parent directories is automatically merged via `findUp`. This can cause unwanted config inheritance. Example: ``` ~/project/opencode.json # parent config with MCP servers A, B, C ~/project/agent/opencode.json # child config with MCP server D ``` Running from `~/project/agent/` loads both configs and sees all MCP servers (A, B, C, D), even when you only want the local config. ## Use Case When developing multiple agents locally, each with their own config, you want isolation - only the config in the current directory should be loaded, not inherited from parent directories. ## Proposed Solution Add `OPENCODE_NO_PARENT_CONFIG` environment variable that limits `findUp` to only search the current directory, not walk up to parent directories. ```bash OPENCODE_NO_PARENT_CONFIG=true opencode ``` This would skip: - `opencode.json` / `opencode.jsonc` from parent directories - `.opencode/` directories from parent directories - `AGENTS.md` / `CLAUDE.md` from parent directories Global config (`~/.config/opencode/`) would still be loaded unless combined with `OPENCODE_DISABLE_GLOBAL_CONFIG=true`. ## Related - #10021 - Request for `OPENCODE_DISABLE_GLOBAL_CONFIG` - #10013 - PR implementing `OPENCODE_DISABLE_GLOBAL_CONFIG`
yindo closed this issue 2026-02-16 18:06:27 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 22, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #10021: Complementary request for OPENCODE_DISABLE_GLOBAL_CONFIG to disable global config loading
  • #6479: Similar issue about opencode reading AGENTS.md from parent directories
  • #4479: Configurable instruction file search boundary that includes parent directory config behavior

While #10021 and #10025 are related (both dealing with config isolation), they address different aspects - #10021 focuses on global config, while #10025 focuses on parent directory config in the same project hierarchy. These may need coordinated implementation to provide complete isolation control.

Feel free to ignore if your specific use case requires something different from these existing discussions.

@github-actions[bot] commented on GitHub (Jan 22, 2026): This issue might be a duplicate of existing issues. Please check: - #10021: Complementary request for `OPENCODE_DISABLE_GLOBAL_CONFIG` to disable global config loading - #6479: Similar issue about opencode reading AGENTS.md from parent directories - #4479: Configurable instruction file search boundary that includes parent directory config behavior While #10021 and #10025 are related (both dealing with config isolation), they address different aspects - #10021 focuses on global config, while #10025 focuses on parent directory config in the same project hierarchy. These may need coordinated implementation to provide complete isolation control. Feel free to ignore if your specific use case requires something different from these existing discussions.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7202