feat(core): [v2] restore OPENCODE_DISABLE_CLAUDE_CODE by malarahfelipe · Pull Request #51888 · anomalyco/opencode · GitHub
Skip to content

feat(core): [v2] restore OPENCODE_DISABLE_CLAUDE_CODE - #51888

Closed
malarahfelipe wants to merge 13 commits into
anomalyco:devfrom
malarahfelipe:fix/opencode-disable-claude-code
Closed

malarahfelipe wants to merge 13 commits into
anomalyco:devfrom
malarahfelipe:fix/opencode-disable-claude-code

Conversation

@malarahfelipe

@malarahfelipe malarahfelipe commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Part of #36990

Replacement for #44725 (auto-closed by the stale-PR cleanup; the author can't reopen it). Same branch and reviewed change.

Type of change

  • New feature

What does this PR do?

Brings back OPENCODE_DISABLE_CLAUDE_CODE support. V1 honored this flag to keep OpenCode from reading ~/.claude (prompt + skills); on v2 the env var was declared but never wired into config discovery, so the global ~/.claude and project .claude dirs kept loading.

Discovery now gates the claude sources on Config.Options.disableClaudeCode or the env var. Setting it drops .claude skill sources (and their file watches) while .agents sources stay. v2 does not load a CLAUDE.md prompt, so there is no prompt path to gate. Discovery stays infallible: absent, malformed, or provider-failing reads fall back to false instead of leaking a ConfigError into the layer graph. The duplicated claude/agents root building is now a shared optionalRoots helper.

Scope note: this restores the umbrella flag only. The granular OPENCODE_DISABLE_CLAUDE_CODE_SKILLS / OPENCODE_DISABLE_CLAUDE_CODE_PROMPT variables are still unimplemented; since v2 only consumes .claude for skill discovery, _SKILLS would map to the same gate and _PROMPT would be a no-op today.

Review feedback from #44725 is included: testLayer pins a ConfigProvider (empty env by default) so discovery never reads the ambient environment, and a dedicated test covers the env path next to the option path.

How did you verify your code works?

  • Config tests: 48/48 on the merged dev head, with OPENCODE_DISABLE_CLAUDE_CODE unset, 1, yes, 0, and malformed values.
  • Full repo typecheck: 36/36.
  • browser-idle.test.ts and server/test/generate.test.ts pass.
  • Mutation-checked the env wiring (renaming the variable in discovery makes the new test fail).

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…_CODE

- testLayer now provides ConfigProvider (empty env by default) so config
  discovery never reads the ambient process environment.
- Add an env-path test alongside the disableClaudeCode option test, with a
  no-flag assertion so it cannot pass trivially.
- Assert via Config.compatibility(); the claude/agents entry types were
  removed on v2, which left the option test red after the rebase.
- Document the OPENCODE_DISABLE_CLAUDE_CODE fallback on the option.
Extract the duplicated claude/agents root building into an optionalRoots
helper: roots vanish when disabled, and the global directory joins only
while the global scope is enabled. No behavior change; covered by the
config discovery tests.
Config.withDefault only covers absent input, so a malformed
OPENCODE_DISABLE_CLAUDE_CODE value leaked ConfigError into discovery and,
through Config.node, broke replacement typing in @opencode/server tests.
Fall back to false on any ConfigError.
@github-actions

Copy link
Copy Markdown
Contributor

@malarahfelipe

Copy link
Copy Markdown
Contributor Author

@rekram1-node could you approve the workflows on this branch? It's up to date with v2 and verified locally: config tests 42/42 (flag unset and =1), full turbo typecheck 35/35, browser-idle.test.ts and server/test/generate.test.ts pass.

This replaces #44725 (auto-closed by the PR cleanup; the author can't reopen it — viewerCanReopen=false).

@malarahfelipe malarahfelipe changed the title feat(core): v2 – restore OPENCODE_DISABLE_CLAUDE_CODE feat(core): [v2] restore OPENCODE_DISABLE_CLAUDE_CODE Sep 29, 2026
@malarahfelipe

Copy link
Copy Markdown
Contributor Author

@craftsamo can you help me get this cleared?

# Conflicts:
#	packages/core/test/config/config.test.ts
# Conflicts:
#	packages/core/src/config/discovery.ts
@malarahfelipe

Copy link
Copy Markdown
Contributor Author

Conflicts resolved — GitHub now reports this as MERGEABLE.

It had been retargeted to dev, so I merged the current dev tip (af6ec83979) and kept both sides in config/discovery.ts: this PR's disableClaudeCode gate + optionalRoots, plus dev's new system directory / macOS preferences discovery. Also adapted the flag read to the current effect API (Config.Boolean).

Verified on the merged head 7daa2146d1: config tests 48/48 (flag unset and =1), browser-idle and server/generate pass, turbo typecheck 36/36.

@thdxr thanks for moving this to dev — the test + check workflows on the new head still need approval when you have a moment.

@rekram1-node

Copy link
Copy Markdown
Collaborator

rios0rios0 added a commit to rios0rios0/opencode that referenced this pull request Oct 17, 2026
V1 parity for the skill catalog: OPENCODE_DISABLE_CLAUDE_CODE and OPENCODE_DISABLE_CLAUDE_CODE_SKILLS now drop the ~/.claude compatibility roots at discovery, so the compatibility skill plugin loads no Claude skills. The variables were ignored by the V2 rewrite (anomalyco#36990); upstream anomalyco#51888 restored them but was closed unmerged. Discovery is the single producer of claude roots, so gating here covers every consumer; the existing options.claude === false escape hatch still applies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants