[PR #8093] feat: add OPENCODE_DISABLE_PROJECT_CONFIG env var #12619

Closed
opened 2026-02-16 18:17:31 -05:00 by yindo · 0 comments
Owner

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

State: closed
Merged: Yes


Closes #7559

Adds environment variable to disable project-level config discovery for external tooling integration.

Changes

  • Skip project config files when flag is set
  • Skip project .opencode/ directories
  • Skip local rule files (AGENTS.md, CLAUDE.md, CONTEXT.md)
  • Relative instructions without OPENCODE_CONFIG_DIR log warning and skip
  • Use dynamic getters for env var flags (fixes runtime evaluation)
  • Extract resolveRelativeInstruction helper for cleaner code structure

Usage

OPENCODE_DISABLE_PROJECT_CONFIG=true \
OPENCODE_CONFIG_DIR=/path/to/profile/ \
opencode

Verification

Automated

Test Command Result
Unit tests bun test --filter "OPENCODE_DISABLE_PROJECT_CONFIG" 5/5 passing

Manual

Setup:

mkdir -p /tmp/test-proj
cat > /tmp/test-proj/opencode.json << 'EOF'
{"mcp": {"test_server_1": {"type": "remote", "url": "https://example.com", "enabled": true}}}
EOF
echo "Always say PINEAPPLE first." > /tmp/test-proj/AGENTS.md
Test Command Expected Result
Config without flag bun dev /tmp/test-proj run "what tools do you have?" Shows test_server_1
Config with flag OPENCODE_DISABLE_PROJECT_CONFIG=true bun dev /tmp/test-proj run "what tools do you have?" No test_server_1
AGENTS.md without flag bun dev /tmp/test-proj run "say hello" Says PINEAPPLE
AGENTS.md with flag OPENCODE_DISABLE_PROJECT_CONFIG=true bun dev /tmp/test-proj run "say hello" No PINEAPPLE
Global config preserved OPENCODE_DISABLE_PROJECT_CONFIG=true bun dev /tmp/test-proj run "what tools do you have?" Shows global MCP servers

Cleanup:

rm -rf /tmp/test-proj
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8093 **State:** closed **Merged:** Yes --- Closes #7559 Adds environment variable to disable project-level config discovery for external tooling integration. ## Changes - Skip project config files when flag is set - Skip project `.opencode/` directories - Skip local rule files (AGENTS.md, CLAUDE.md, CONTEXT.md) - Relative instructions without OPENCODE_CONFIG_DIR log warning and skip - Use dynamic getters for env var flags (fixes runtime evaluation) - Extract `resolveRelativeInstruction` helper for cleaner code structure ## Usage ```bash OPENCODE_DISABLE_PROJECT_CONFIG=true \ OPENCODE_CONFIG_DIR=/path/to/profile/ \ opencode ``` ## Verification ### Automated | Test | Command | Result | | ---------- | --------------------------------------------------- | ----------- | | Unit tests | `bun test --filter "OPENCODE_DISABLE_PROJECT_CONFIG"` | 5/5 passing | ### Manual **Setup:** ```bash mkdir -p /tmp/test-proj cat > /tmp/test-proj/opencode.json << 'EOF' {"mcp": {"test_server_1": {"type": "remote", "url": "https://example.com", "enabled": true}}} EOF echo "Always say PINEAPPLE first." > /tmp/test-proj/AGENTS.md ``` | Test | Command | Expected | Result | | ----------------------- | ----------------------------------------------------------------------------------------- | ------------------------ | ------ | | Config without flag | `bun dev /tmp/test-proj run "what tools do you have?"` | Shows test_server_1 | ✅ | | Config with flag | `OPENCODE_DISABLE_PROJECT_CONFIG=true bun dev /tmp/test-proj run "what tools do you have?"` | No test_server_1 | ✅ | | AGENTS.md without flag | `bun dev /tmp/test-proj run "say hello"` | Says PINEAPPLE | ✅ | | AGENTS.md with flag | `OPENCODE_DISABLE_PROJECT_CONFIG=true bun dev /tmp/test-proj run "say hello"` | No PINEAPPLE | ✅ | | Global config preserved | `OPENCODE_DISABLE_PROJECT_CONFIG=true bun dev /tmp/test-proj run "what tools do you have?"` | Shows global MCP servers | ✅ | **Cleanup:** ```bash rm -rf /tmp/test-proj ```
yindo added the pull-request label 2026-02-16 18:17:31 -05:00
yindo closed this issue 2026-02-16 18:17:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12619