[PR #10024] feat(config): add OPENCODE_NO_PARENT_CONFIG env var #13305

Open
opened 2026-02-16 18:18:10 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10024

State: open
Merged: No


Add environment variable flag to prevent findUp from walking up parent directories when loading project config. Only loads config from the current working directory.

Fixes #10025

This is a logical continuation of #10013 (OPENCODE_DISABLE_GLOBAL_CONFIG), providing more granular control over config loading.

Use Case

Running opencode in a subdirectory that has its own opencode.json, without inheriting/merging config from parent directories.

Example structure:

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

Without flag (current behavior): Running from ~/project/agent/ loads both configs, sees A, B, C, D.

With flag: Running from ~/project/agent/ only loads the local config, sees only D.

What Gets Disabled

When OPENCODE_NO_PARENT_CONFIG=true:

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

Note: Global config (~/.config/opencode/) is still loaded. Use OPENCODE_DISABLE_GLOBAL_CONFIG=true (from #10013) to disable that as well.

Usage

# Only load config from current directory
OPENCODE_NO_PARENT_CONFIG=true opencode

# Full isolation - current directory only, no global
OPENCODE_NO_PARENT_CONFIG=true OPENCODE_DISABLE_GLOBAL_CONFIG=true opencode

Test Plan

  • Added 5 tests for OPENCODE_NO_PARENT_CONFIG
  • Verified existing OPENCODE_DISABLE_PROJECT_CONFIG tests still pass
  • Manual testing with built binary

Related

  • #10025 - Issue for this feature
  • #10021 - Issue for OPENCODE_DISABLE_GLOBAL_CONFIG
  • #10013 - PR implementing OPENCODE_DISABLE_GLOBAL_CONFIG
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10024 **State:** open **Merged:** No --- Add environment variable flag to prevent `findUp` from walking up parent directories when loading project config. Only loads config from the current working directory. Fixes #10025 This is a logical continuation of #10013 (`OPENCODE_DISABLE_GLOBAL_CONFIG`), providing more granular control over config loading. ## Use Case Running opencode in a subdirectory that has its own `opencode.json`, without inheriting/merging config from parent directories. Example structure: ``` ~/project/opencode.json # parent config with MCP servers A, B, C ~/project/agent/opencode.json # child config with MCP server D ``` Without flag (current behavior): Running from `~/project/agent/` loads both configs, sees A, B, C, D. With flag: Running from `~/project/agent/` only loads the local config, sees only D. ## What Gets Disabled When `OPENCODE_NO_PARENT_CONFIG=true`: - `opencode.json` / `opencode.jsonc` from parent directories - `.opencode/` directories from parent directories - `AGENTS.md` / `CLAUDE.md` / `CONTEXT.md` from parent directories **Note:** Global config (`~/.config/opencode/`) is still loaded. Use `OPENCODE_DISABLE_GLOBAL_CONFIG=true` (from #10013) to disable that as well. ## Usage ```bash # Only load config from current directory OPENCODE_NO_PARENT_CONFIG=true opencode # Full isolation - current directory only, no global OPENCODE_NO_PARENT_CONFIG=true OPENCODE_DISABLE_GLOBAL_CONFIG=true opencode ``` ## Test Plan - [x] Added 5 tests for `OPENCODE_NO_PARENT_CONFIG` - [x] Verified existing `OPENCODE_DISABLE_PROJECT_CONFIG` tests still pass - [x] Manual testing with built binary ## Related - #10025 - Issue for this feature - #10021 - Issue for `OPENCODE_DISABLE_GLOBAL_CONFIG` - #10013 - PR implementing `OPENCODE_DISABLE_GLOBAL_CONFIG`
yindo added the pull-request label 2026-02-16 18:18:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13305