Skip to content

[FEATURE]: add OPENCODE_DISABLE_GLOBAL_CONFIG flag to skip global config loading #21264

Closed as not planned

Description

@ZY-Yim

Feature hasn't been suggested before.

I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

When embedding OpenCode as a subprocess via opencode serve (e.g. in an Electron app or backend service), the host application
provides all configuration through OPENCODE_CONFIG_CONTENT. However, OpenCode still loads global config files and scans global
directories from ~/.config/opencode/, which can cause unexpected behavior by merging unrelated user-level settings, agents, skills,
and plugins into the intended configuration.

Currently there is no way to skip global config and directory scanning:

  • OPENCODE_DISABLE_PROJECT_CONFIG only skips project-level config, not global
  • OPENCODE_CONFIG_CONTENT is additive — it merges on top of global config rather than replacing it

Note: This is related to but different from #20784 (settingSources). That PR provides a granular SDK-level mechanism to control
config sources. This PR takes a simpler approach with a single env var flag, consistent with existing OPENCODE_DISABLE_*
conventions, specifically targeting the embedded opencode serve use case.

Proposed Solution

Add a new environment variable OPENCODE_DISABLE_GLOBAL_CONFIG. When set to 1 or true:

  1. loadGlobal() in config.ts returns an empty config object, skipping all files under ~/.config/opencode/ (config.json,
    opencode.json, opencode.jsonc)
  2. ConfigPaths.directories() in paths.ts excludes ~/.config/opencode/ from the returned list, preventing scanning of global
    agents, skills, commands, and plugins

Scope

  • Skipped: ~/.config/opencode/ config files, agents, skills, commands, plugins
  • Not affected: project-level .opencode/ directories, OPENCODE_CONFIG, OPENCODE_CONFIG_CONTENT, well-known, account, managed
    configs

Naming

Follows the existing OPENCODE_DISABLE_* convention (e.g. OPENCODE_DISABLE_PROJECT_CONFIG, OPENCODE_DISABLE_CLAUDE_CODE).

Use Case

// Electron app spawning opencode serve
spawn(binaryPath, ['serve', '--port', '4096'], {
  env: {
    OPENCODE_DISABLE_GLOBAL_CONFIG: '1',
    OPENCODE_DISABLE_CLAUDE_CODE: '1',
    OPENCODE_CONFIG_CONTENT: JSON.stringify(myConfig),
  },
})

Implementation

Minimal change — 3 files, +15 lines:
- packages/opencode/src/flag/flag.ts: declare flag + dynamic getter
- packages/opencode/src/config/config.ts: early return in loadGlobal()
- packages/opencode/src/config/paths.ts: exclude global directory from ConfigPaths.directories()

PR: #21650

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Apr 7, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 7, 2026
  3. michaelvolz commented on Apr 26, 2026

    @michaelvolz

    I would really appreciate this feature as well. I have many global skills, agents, and configurations that are essential for some projects but completely irrelevant (or even counterproductive) for others. Being able to conditionally disable them would be fantastic.

    Either an environment variable like OPENCODE_DISABLE_GLOBAL_CONFIG or a setting in my local opencode.jsonc would work well for my use case. I use devenv, so the env var approach feels natural.

  4. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. Xynonners commented on May 4, 2026

    @Xynonners

    +1 here.

  6. CH-Chang commented on Jun 1, 2026

    @CH-Chang

    +1

  7. mostashkin commented on Jul 22, 2026

    @mostashkin

    +1

  8. github-actions commented on Sep 22, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions