Skip to content

fix(env): move first-party variables to OPENCLAUDE_* namespace (#2589) - #2595

Open
Gravirei wants to merge 5 commits into
Twigpine:mainfrom
Gravirei:fix/issue-2589-rebrand-env-vars
Open

Gravirei wants to merge 5 commits into
Twigpine:mainfrom
Gravirei:fix/issue-2589-rebrand-env-vars

Conversation

@Gravirei

@Gravirei Gravirei commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2589

Summary

  • Renamed first-party CLAUDE_* / CLAUDE_CODE_* environment variables to the existing OPENCLAUDE_* namespace, stripping the CODE segment (CLAUDE_CODE_DEBUG_LOGS_DIR → OPENCLAUDE_DEBUG_LOGS_DIR). This stops OpenClaude from sharing configuration and credential variables with Claude Code.
  • Added a compatibility bridge so existing installations keep working: legacy names are accepted from shell env, settings env, provider env files, and SDK env overrides. A canonical OPENCLAUDE_* name always wins when both spellings are present; legacy names inherited from the shell produce one deprecation notice per process.
  • Left ANTHROPIC_* variables unchanged, as those are read by Anthropic SDKs and external contracts. Hook/plugin/Agent SDK protocol variables (CLAUDE_ENV_FILE, CLAUDE_PROJECT_DIR, CLAUDE_PLUGIN_*, CLAUDE_AGENT_SDK_*) and CLAUDE_CONFIG_DIR, which this codebase deliberately ignores, keep their original spelling.
  • Updated setup docs, .env.example, diagnostics, Windows launchers, Android install notes, web config tables, and the VS Code extension to advertise the canonical names.

Impact

  • user-facing impact: configuration now uses OPENCLAUDE_*; existing CLAUDE_* / CLAUDE_CODE_* settings continue to work during migration. ANTHROPIC_* provider credentials are unaffected.
  • developer/maintainer impact: added envRebrand helpers with unit tests, a generated list of migrated legacy names, and a source-parity test that fails if first-party CLAUDE_* env reads return to src/ or tests/.

Testing

  • I followed Validation, including applicable lint/static/type checks and regression tests.
  • affected surfaces and selected checks: environment compatibility helpers, provider-selection flags, managed settings env, provider env files, SDK session/query/permission env overrides, subprocess secret scrubbing, VS Code extension state detection, docs and web config tables.
  • exact commands and results:
    • bun run check:static — passed (ESLint warnings unchanged, any-usage budget, smoke build, deadcode).
    • NODE_OPTIONS=--max-old-space-size=8192 ./node_modules/.bin/tsc --noEmit — passed.
    • bun run integrations:check — passed; bun run web:typecheck — passed (0 errors).
    • bun run test <focused files> — passed for env rebrand, env files, provider flags, managed env, subprocess env, SDK session env, and SDK code-mode transcript tests.
    • cd vscode-extension/openclaude-vscode && bun test src — 56 passed.
  • focused tests: src/utils/envRebrand.test.ts, src/utils/envFile.test.ts, src/utils/subprocessEnv.test.ts, src/utils/managedEnv.test.ts, src/utils/providerSelectionFlags.test.ts, src/entrypoints/sdk/v2.sessionEnvTurn.test.ts, tests/sdk/sdk-code-mode-transcript.test.ts, vscode-extension/openclaude-vscode/src/state.test.js.
  • for follow-ups, prior validated revision and unaffected results reused: n/a (initial PR).
  • inapplicable checks and reasons; blocked checks, platform limits, or verified pre-existing failures:
    • bun run typecheck:fast cannot run in this environment (Script not found "check" from the wrapper); tsc with a larger heap was used instead.
    • tests/sdk/package-consumer-types.test.ts fails here because npm pack --dry-run --json produces no files entry; the same 7 failures reproduce on a clean HEAD worktree.
    • src/utils/managedEnv.test.ts proxy-fixture assertion and src/utils/execFileNoThrow.test.ts Windows batch quoting fail identically on clean HEAD.
    • src/utils/undiciFetch.test.ts child-process TLS/proxy cases fail on clean HEAD under Node 26 module resolution.
    • A sharded full-suite run was attempted; remaining failures were either the pre-existing cases above or load-related flakes that pass in isolation.
  • CI and review checks: pending on this draft PR.

Notes

  • provider/model path tested: provider-selection flags (OpenAI, Gemini, Gemini Vertex, Bedrock, Vertex, Foundry, GitHub Models, Mistral) resolve through the canonical names; no credential handling changed.
  • screenshots attached (if UI changed): n/a — no UI changes.
  • follow-up work or known limitations: the ANTHROPIC_* → TWIGPINE_* mapping described in the issue is intentionally deferred; this change is limited to the CLAUDE_* namespace as scoped.

Copilot AI balanced review requested due to automatic review settings December 3, 2026 04:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 588 files, which is 288 over the limit of 300.

To get a review, reduce the PR to 300 files or fewer by splitting it into smaller PRs or changing its base branch.

Usage-priced reviews support at most 500 files.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7f971ac and ba8a5a8.

Files ignored due to path filters: 1

  • src/utils/legacyEnvNames.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 588

  • .env.example
  • ANDROID_INSTALL.md
  • README.md
  • docs/advanced-setup.md
  • docs/agent-routing.md
  • docs/aimlapi-setup.md
  • docs/architecture/integrations.md
  • docs/hook-chains.md
  • docs/integrations/common-pitfalls.md
  • docs/integrations/how-to/add-model.md
  • docs/litellm-setup.md
  • docs/local-usage.md
  • docs/quick-start-mac-linux.md
  • docs/quick-start-windows.md
  • docs/repo-map.md
  • docs/windows-aliases-and-launchers.md
  • scripts/build.ts
  • scripts/externals.ts
  • scripts/no-telemetry-growthbook-stub.test.ts
  • scripts/provider-bootstrap.ts
  • scripts/provider-launch.test.ts
  • scripts/provider-launch.ts
  • scripts/provider-recommend.ts
  • scripts/system-check.test.ts
  • scripts/system-check.ts
  • scripts/verify-clean-install.test.ts
  • scripts/verify-clean-install.ts
  • scripts/windows/openclaude-aliases.ps1
  • src/QueryEngine.ts
  • src/__tests__/bugfixes.test.ts
  • src/__tests__/security-hardening.test.ts
  • src/__tests__/statusNoticeLocalModel.test.ts
  • src/bridge/bridgeConfig.ts
  • src/bridge/bridgeEnabled.ts
  • src/bridge/bridgeMain.ts
  • src/bridge/inboundAttachments.ts
  • src/bridge/initReplBridge.ts
  • src/bridge/remoteBridgeCore.ts
  • src/bridge/replBridge.ts
  • src/bridge/replBridgeTransport.ts
  • src/bridge/sessionRunner.test.ts
  • src/bridge/sessionRunner.ts
  • src/bridge/trustedDevice.ts
  • src/cli/bg.test.ts
  • src/cli/bg.ts
  • src/cli/handlers/auth.ts
  • src/cli/handlers/xaiAuth.test.ts
  • src/cli/print.ts
  • src/cli/printMaxTurns.test.ts
  • src/cli/remoteIO.ts
  • src/cli/structuredIO.ts
  • src/cli/transports/HybridTransport.test.ts
  • src/cli/transports/SSETransport.ts
  • src/cli/transports/WebSocketTransport.ts
  • src/cli/transports/ccrClient.ts
  • src/cli/transports/transportUtils.ts
  • src/commands/cache-probe/cache-probe.test.ts
  • src/commands/cache-probe/cache-probe.ts
  • src/commands/cache-probe/index.ts
  • src/commands/clear/conversation.goal.test.ts
  • src/commands/clear/conversation.ts
  • src/commands/ctx_viz/ctx-noninteractive.ts
  • src/commands/effort/effort.test.tsx
  • src/commands/effort/effort.tsx
  • src/commands/focus/focus.test.ts
  • src/commands/focus/focus.ts
  • src/commands/init.test.ts
  • src/commands/initMode.test.ts
  • src/commands/initMode.ts
  • src/commands/install-github-app/install-github-app.tsx
  • src/commands/install-github-app/setupGitHubActions.test.ts
  • src/commands/install-github-app/setupGitHubActions.ts
  • src/commands/mcp/addCommand.ts
  • src/commands/model/model.test.tsx
  • src/commands/model/model.tsx
  • src/commands/onboard-github/onboard-github.test.ts
  • src/commands/onboard-github/onboard-github.tsx
  • src/commands/provider/provider.test.tsx
  • src/commands/provider/provider.tsx
  • src/commands/reload-plugins/reload-plugins.ts
  • src/commands/scroll-speed/scroll-speed.test.ts
  • src/commands/scroll-speed/scroll-speed.ts
  • src/commands/search/search.test.tsx
  • src/commands/search/searchSettings.test.ts
  • src/commands/set-context-window/set-context-window.test.ts
  • src/commands/set-context-window/set-context-window.ts
  • src/commands/tui/tui.test.ts
  • src/commands/tui/tui.ts
  • src/commands/usage/index.test.ts
  • src/components/ConsoleOAuthFlow.tsx
  • src/components/FeedbackSurvey/useFeedbackSurvey.tsx
  • src/components/FeedbackSurvey/useMemorySurvey.tsx
  • src/components/FeedbackSurvey/usePostCompactSurvey.tsx
  • src/components/FullscreenLayout.tsx
  • src/components/ManagedSettingsSecurityDialog/utils.test.ts
  • src/components/ManagedSettingsSecurityDialog/utils.ts
  • src/components/Messages.tsx
  • src/components/ModelPicker.switchProfile.test.ts
  • src/components/PromptInput/Notifications.effort.test.tsx
  • src/components/PromptInput/Notifications.tsx
  • src/components/ProviderManager.test.tsx
  • src/components/ProviderManager.tsx
  • src/components/ScrollKeybindingHandler.tsx
  • src/components/SessionBackgroundHint.tsx
  • src/components/Settings/Config.tsx
  • src/components/Spinner.tsx
  • src/components/StartupScreen.test.ts
  • src/components/StartupScreen.ts
  • src/components/StructuredDiff/colorDiff.ts
  • src/components/TextInput.tsx
  • src/components/ThemePicker.tsx
  • src/components/TrustDialog/utils.test.ts
  • src/components/TrustDialog/utils.ts
  • src/components/mcp/MCPRemoteServerMenu.tsx
  • src/components/messages/UserPromptMessage.tsx
  • src/constants/common.ts
  • src/constants/oauth.ts
  • src/constants/product.ts
  • src/constants/promptIdentity.test.ts
  • src/constants/prompts.doingTasks.test.ts
  • src/constants/prompts.ts
  • src/constants/system.ts
  • src/context.repoMap.test.ts
  • src/context.ts
  • src/coordinator/coordinatorMode.ts
  • src/cost-tracker.ts
  • src/entrypoints/cli.skills.test.ts
  • src/entrypoints/cli.test.ts
  • src/entrypoints/cli.tsx
  • src/entrypoints/init.ts
  • src/entrypoints/mcp.test.ts
  • src/entrypoints/mcp.ts
  • src/entrypoints/sdk/index.ts
  • src/entrypoints/sdk/mcpNeedsAuth.test.ts
  • src/entrypoints/sdk/permissions.ts
  • src/entrypoints/sdk/query.ts
  • src/entrypoints/sdk/v2.sessionEnvTurn.test.ts
  • src/entrypoints/sdk/v2.ts
  • src/history.ts
  • src/hooks/notifs/useModelMigrationNotifications.tsx
  • src/hooks/useAfterFirstRender.ts
  • src/hooks/useIDEIntegration.tsx
  • src/hooks/useIdleCompaction.test.tsx
  • src/hooks/useIdleCompaction.ts
  • src/hooks/useInboxPoller.ts
  • src/hooks/useManagePlugins.ts
  • src/ink/colorize.test.ts
  • src/ink/colorize.ts
  • src/ink/components/App.tsx
  • src/ink/dom.ts
  • src/ink/ink.tsx
  • src/ink/reconciler.ts
  • src/integrations/aimlapi/topup.ts
  • src/integrations/discoveryService.test.ts
  • src/integrations/discoveryService.ts
  • src/integrations/gateways/github-enterprise.ts
  • src/integrations/gateways/github.ts
  • src/integrations/gateways/gitlawb-opengateway.test.ts
  • src/integrations/gateways/gmi-cloud.test.ts
  • src/integrations/gateways/llmtr.test.ts
  • src/integrations/gateways/merge-gateway.test.ts
  • src/integrations/gateways/mistral.ts
  • src/integrations/gateways/requesty.test.ts
  • src/integrations/gateways/straitly.test.ts
  • src/integrations/routeMetadata.test.ts
  • src/integrations/routeMetadata.ts
  • src/integrations/runtimeMetadata.modelLimits.test.ts
  • src/integrations/runtimeMetadata.test.ts
  • src/integrations/vendors/gemini-vertex.ts
  • src/integrations/vendors/gemini.ts
  • src/integrations/vendors/openai.ts
  • src/interactiveHelpers.tsx
  • src/jobs/classifier.ts
  • src/main.tsx
  • src/memdir/autoExtractFacts.test.ts
  • src/memdir/memdir.ts
  • src/memdir/paths.test.ts
  • src/memdir/paths.ts
  • src/native-ts/color-diff/index.ts
  • src/plugins/bundled/aimlapiMcp.test.ts
  • src/plugins/bundled/aimlapiMcp.ts
  • src/query.conversationArc.test.ts
  • src/query.ts
  • src/query/agentStepLimit.test.ts
  • src/query/autoCompactCooldown.test.ts
  • src/query/config.ts
  • src/query/providerMaxTokensCapRetry.test.ts
  • src/query/stopHooks.ts
  • src/query/toolFailureLoopGuard.ts
  • src/screens/Doctor.tsx
  • src/screens/REPL.tsx
  • src/screens/replResumeToolPool.test.ts
  • src/services/AgentSummary/agentSummary.ts
  • src/services/PromptSuggestion/promptSuggestion.ts
  • src/services/analytics/metadata.ts
  • src/services/api/agentRouting.test.ts
  • src/services/api/agentRouting.ts
  • src/services/api/authRouting.attribution.test.ts
  • src/services/api/authRouting.ts
  • src/services/api/bootstrap.test.ts
  • src/services/api/cacheMetrics.ts
  • src/services/api/claude.lifecycle.test.ts
  • src/services/api/claude.streamWatchdog.test.ts
  • src/services/api/claude.timeout.test.ts
  • src/services/api/claude.ts
  • src/services/api/client.bedrockStreaming.test.ts
  • src/services/api/client.foundryStreaming.test.ts
  • src/services/api/client.optionalRuntime.test.ts
  • src/services/api/client.test.ts
  • src/services/api/client.ts
  • src/services/api/codexShim.test.ts
  • src/services/api/compressToolHistory.test.ts
  • src/services/api/errors.ts
  • src/services/api/filesApi.ts
  • src/services/api/googleAuth.integration.test.ts
  • src/services/api/openaiShim.compression.test.ts
  • src/services/api/openaiShim.test.ts
  • src/services/api/openaiShim.ts
  • src/services/api/openaiShim/codexDispatch.test.ts
  • src/services/api/openaiShim/ollamaAdapter.test.ts
  • src/services/api/openaiShim/providerCompatibility.test.ts
  • src/services/api/openaiShim/providerCompatibility.ts
  • src/services/api/openaiShim/providerStreamInterruptionTrace.test.ts
  • src/services/api/openaiShim/requestExecutor.integration.test.ts
  • src/services/api/openaiShim/requestExecutor.test.ts
  • src/services/api/openaiShim/requestPlanner.test.ts
  • src/services/api/openaiShim/requestPlanner.ts
  • src/services/api/openaiShim/streamControl.test.ts
  • src/services/api/openaiShim/streamControl.ts
  • src/services/api/promptCacheBreakDetection.test.ts
  • src/services/api/promptCacheBreakDetection.ts
  • src/services/api/providerConfig.envDiagnostics.test.ts
  • src/services/api/providerConfig.github.test.ts
  • src/services/api/providerConfig.local.test.ts
  • src/services/api/providerConfig.test.ts
  • src/services/api/providerConfig.ts
  • src/services/api/sessionIngress.ts
  • src/services/api/withRetry.test.ts
  • src/services/api/withRetry.ts
  • src/services/compact/autoCompact.test.ts
  • src/services/compact/autoCompact.ts
  • src/services/compact/compact.test.ts
  • src/services/compact/compact.ts
  • src/services/compact/idleCompaction.test.ts
  • src/services/compact/idleCompaction.ts
  • src/services/contextCollapse/index.test.ts
  • src/services/contextCollapse/index.ts
  • src/services/contextCollapse/operations.test.ts
  • src/services/contextCollapse/persist.test.ts
  • src/services/contextCollapse/spawnCtxAgent.test.ts
  • src/services/mcp/auth.refreshLock.test.ts
  • src/services/mcp/auth.ts
  • src/services/mcp/client.activity.test.ts
  • src/services/mcp/client.tasks.test.ts
  • src/services/mcp/client.ts
  • src/services/mcp/enterpriseMcpBoundary.test.ts
  • src/services/mcp/enterpriseMcpErrors.test.ts
  • src/services/mcp/headersHelper.ts
  • src/services/mcp/officialRegistry.test.ts
  • src/services/mcp/officialRegistry.ts
  • src/services/mcp/tasks.test.ts
  • src/services/mcp/tasks.ts
  • src/services/mcp/xaaIdpLogin.ts
  • src/services/oauth/client.ts
  • src/services/remoteManagedSettings/syncCache.ts
  • src/services/remoteManagedSettings/syncCacheState.ts
  • src/services/tips/tipRegistry.ts
  • src/services/tokenEstimation.ts
  • src/services/tools/toolOrchestration.ts
  • src/services/usage/ledger.test.ts
  • src/services/usage/rollups.test.ts
  • src/services/vcr.ts
  • src/services/voice.ts
  • src/setup.ts
  • src/skills/bundled/autoModeSetup.ts
  • src/skills/bundled/index.test.ts
  • src/skills/bundled/paritySkills.test.ts
  • src/skills/loadSkillsDir.test.ts
  • src/skills/loadSkillsDir.ts
  • src/state/onChangeAppState.ts
  • src/tasks/LocalMainSessionTask.test.ts
  • src/test/fixtures/managedEnvTransport.fixture.ts
  • src/test/fixtures/orcarouterCredentials.fixture.ts
  • src/test/fixtures/sentryShutdown.fixture.ts
  • src/test/settingSourceState.ts
  • src/tools.ts
  • src/tools/AgentTool/AgentTool.replConcurrency.test.ts
  • src/tools/AgentTool/AgentTool.schema.test.ts
  • src/tools/AgentTool/AgentTool.teammateModel.test.ts
  • src/tools/AgentTool/AgentTool.tsx
  • src/tools/AgentTool/agentMemory.test.ts
  • src/tools/AgentTool/agentMemory.ts
  • src/tools/AgentTool/agentMemorySnapshotGate.test.ts
  • src/tools/AgentTool/built-in/codeReviewerAgent.test.ts
  • src/tools/AgentTool/builtInAgents.ts
  • src/tools/AgentTool/loadAgentsDir.test.ts
  • src/tools/AgentTool/prompt.test.ts
  • src/tools/AgentTool/prompt.ts
  • src/tools/AgentTool/runAgent.output.test.ts
  • src/tools/AgentTool/runAgent.routing.test.ts
  • src/tools/AgentTool/runAgent.ts
  • src/tools/BashTool/BashTool.sandboxAnalysis.test.ts
  • src/tools/BashTool/BashTool.tsx
  • src/tools/BashTool/UI.tsx
  • src/tools/BashTool/bashCommandAnalysis.test.ts
  • src/tools/BashTool/bashCommandAnalysis.ts
  • src/tools/BashTool/bashPermissions.test.ts
  • src/tools/BashTool/bashPermissions.ts
  • src/tools/BashTool/prompt.ts
  • src/tools/BriefTool/BriefTool.ts
  • src/tools/BriefTool/attachments.ts
  • src/tools/BriefTool/upload.ts
  • src/tools/CtxInspectTool/CtxInspectTool.test.ts
  • src/tools/FileEditTool/FileEditTool.ts
  • src/tools/FileReadTool/FileReadTool.ts
  • src/tools/FileReadTool/limits.ts
  • src/tools/FileWriteTool/FileWriteTool.ts
  • src/tools/PowerShellTool/PowerShellTool.interruptForeground.test.ts
  • src/tools/PowerShellTool/PowerShellTool.tsx
  • src/tools/PowerShellTool/prompt.ts
  • src/tools/REPLTool/REPLTool.test.ts
  • src/tools/REPLTool/constants.test.ts
  • src/tools/REPLTool/constants.ts
  • src/tools/REPLTool/prompt.test.ts
  • src/tools/REPLTool/toolWrappers.ts
  • src/tools/ScheduleCronTool/prompt.ts
  • src/tools/SendMessageTool/SendMessageTool.ts
  • src/tools/TeamCreateTool/TeamCreateTool.ts
  • src/tools/WebFetchTool/WebFetchTool.backend.test.ts
  • src/tools/WebFetchTool/aimlapiScrape.test.ts
  • src/tools/WebFetchTool/aimlapiScrape.ts
  • src/tools/WebFetchTool/domainCheck.test.ts
  • src/tools/WebSearchTool/providers/aimlapi.test.ts
  • src/tools/WebSearchTool/providers/aimlapi.ts
  • src/tools/WebSearchTool/providers/index.test.ts
  • src/tools/WebSearchTool/providers/ollama.test.ts
  • src/tools/WebSearchTool/providers/ollama.ts
  • src/tools/shared/spawnMultiAgent.ts
  • src/types/logs.ts
  • src/upstreamproxy/upstreamproxy.ts
  • src/utils/Shell.ts
  • src/utils/advisor.ts
  • src/utils/agentContext.ts
  • src/utils/agentSwarmsEnabled.ts
  • src/utils/agenticSessionSearch.test.ts
  • src/utils/analyzeContext.mcp.test.ts
  • src/utils/analyzeContext.messageBreakdown.test.ts
  • src/utils/analyzeContext.ts
  • src/utils/anthropicAttribution.test.ts
  • src/utils/api.ts
  • src/utils/apiPreconnect.test.ts
  • src/utils/apiPreconnect.ts
  • src/utils/attachments.agentListing.test.ts
  • src/utils/attachments.compactionReminder.test.ts
  • src/utils/attachments.contextEfficiency.test.ts
  • src/utils/attachments.lspDiagnostics.test.ts
  • src/utils/attachments.todoReminder.test.ts
  • src/utils/attachments.ts
  • src/utils/attachments.ultracode.test.ts
  • src/utils/attachments.ultrathink.test.ts
  • src/utils/attribution.test.ts
  • src/utils/attribution.ts
  • src/utils/auth.test.ts
  • src/utils/auth.ts
  • src/utils/authFileDescriptor.ts
  • src/utils/bash/ShellSnapshot.ts
  • src/utils/betas.test.ts
  • src/utils/betas.ts
  • src/utils/claudeInChrome/mcpServer.ts
  • src/utils/claudeInChrome/setup.ts
  • src/utils/claudemd.ts
  • src/utils/codexCredentials.test.ts
  • src/utils/commitAttribution.ts
  • src/utils/concurrentSessions.ts
  • src/utils/config.ts
  • src/utils/context.test.ts
  • src/utils/context.ts
  • src/utils/conversationArc.test.ts
  • src/utils/conversationRecovery.hooks.test.ts
  • src/utils/conversationRecovery.test.ts
  • src/utils/copilotOptimization.ts
  • src/utils/debug.ts
  • src/utils/diagLogs.ts
  • src/utils/diagnostics/issueReport.test.ts
  • src/utils/diagnostics/issueReport.ts
  • src/utils/effort.codex.test.ts
  • src/utils/effort.test.ts
  • src/utils/effort.ts
  • src/utils/effort.ultracode-display.test.ts
  • src/utils/embeddedTools.ts
  • src/utils/env.test.ts
  • src/utils/env.ts
  • src/utils/envDynamic.ts
  • src/utils/envFile.test.ts
  • src/utils/envFile.ts
  • src/utils/envParity.test.ts
  • src/utils/envProviderOption.test.ts
  • src/utils/envRebrand.test.ts
  • src/utils/envRebrand.ts
  • src/utils/envRebrandBootstrap.ts
  • src/utils/envUtils.ts
  • src/utils/envValidation.ts
  • src/utils/extraUsage.test.ts
  • src/utils/fastMode.test.ts
  • src/utils/fastMode.ts
  • src/utils/fileHistory.ts
  • src/utils/filePersistence/filePersistence.ts
  • src/utils/filePersistence/outputsScanner.ts
  • src/utils/focusView.test.ts
  • src/utils/fullscreen.ts
  • src/utils/geminiCredentials.test.ts
  • src/utils/geminiCredentials.ts
  • src/utils/geminiVertexRouting.test.ts
  • src/utils/gitDiff.ts
  • src/utils/gitSettings.test.ts
  • src/utils/gitSettings.ts
  • src/utils/githubModelsCredentials.hydrate.test.ts
  • src/utils/githubModelsCredentials.refresh.test.ts
  • src/utils/githubModelsCredentials.test.ts
  • src/utils/githubModelsCredentials.ts
  • src/utils/glob.ts
  • src/utils/gracefulShutdown.ts
  • src/utils/headlessProfiler.ts
  • src/utils/hookChains.integration.test.ts
  • src/utils/hookChains.test.ts
  • src/utils/hookChains.ts
  • src/utils/hooks.ts
  • src/utils/hooks/hookEvents.ts
  • src/utils/hooks/skillImprovement.init.test.ts
  • src/utils/hooks/skillImprovement.ts
  • src/utils/http.test.ts
  • src/utils/http.ts
  • src/utils/ide.download.test.ts
  • src/utils/ide.ts
  • src/utils/idleTimeout.ts
  • src/utils/imagePaste.clipboard-error.test.ts
  • src/utils/imagePaste.ts
  • src/utils/imagePaste.win32.test.ts
  • src/utils/imageResizer.native.test.ts
  • src/utils/interruptionTrace.test.ts
  • src/utils/knowledgeGraph.test.ts
  • src/utils/log.ts
  • src/utils/managedEnv.test.ts
  • src/utils/managedEnv.ts
  • src/utils/managedEnvConstants.ts
  • src/utils/markdownConfigLoader.scaling.test.ts
  • src/utils/markdownConfigLoader.ts
  • src/utils/mcpInstructionsDelta.ts
  • src/utils/memoryFileDetection.ts
  • src/utils/messages.toolUseIds.test.ts
  • src/utils/messages.ts
  • src/utils/messages/planMode.test.ts
  • src/utils/model/agent.test.ts
  • src/utils/model/agent.ts
  • src/utils/model/bedrock.ts
  • src/utils/model/deprecation.test.ts
  • src/utils/model/model.github.test.ts
  • src/utils/model/model.openai-shim-providers.test.ts
  • src/utils/model/model.ts
  • src/utils/model/modelOptions.catalogDedup.test.ts
  • src/utils/model/modelOptions.codexRecovery.test.ts
  • src/utils/model/modelOptions.crossProfile.test.ts
  • src/utils/model/modelOptions.gateways.test.ts
  • src/utils/model/modelOptions.github.test.ts
  • src/utils/model/modelOptions.hicap.test.ts
  • src/utils/model/modelOptions.ts
  • src/utils/model/modelOptions.xiaomi-mimo.test.ts
  • src/utils/model/modelStrings.gemini-vertex.test.ts
  • src/utils/model/modelStrings.github.test.ts
  • src/utils/model/nvidiaNimModels.test.ts
  • src/utils/model/openaiContextWindows.test.ts
  • src/utils/model/openaiContextWindows.ts
  • src/utils/model/openaiModelDiscovery.test.ts
  • src/utils/model/parseUserSpecifiedModel.disable1m.test.ts
  • src/utils/model/providers.test.ts
  • src/utils/model/providers.ts
  • src/utils/mtls.ts
  • src/utils/nativeInstaller/download.ts
  • src/utils/permissions/bashClassifier.test.ts
  • src/utils/permissions/bashClassifier.ts
  • src/utils/permissions/filesystem.blockWrites.test.ts
  • src/utils/permissions/filesystem.test.ts
  • src/utils/permissions/filesystem.ts
  • src/utils/permissions/pathValidation.ts
  • src/utils/permissions/permissionSetup.ts
  • src/utils/permissions/permissions.test.ts
  • src/utils/permissions/yoloClassifier.ts
  • src/utils/planModeV2.ts
  • src/utils/plugins/headlessPluginInstall.ts
  • src/utils/plugins/marketplaceManager.test.ts
  • src/utils/plugins/marketplaceManager.ts
  • src/utils/plugins/officialMarketplaceStartupCheck.ts
  • src/utils/plugins/orphanedPluginFilter.ts
  • src/utils/plugins/performStartupChecks.tsx
  • src/utils/plugins/pluginDirectories.ts
  • src/utils/plugins/pluginLoader.ts
  • src/utils/plugins/zipCache.ts
  • src/utils/powershell/parser.ts
  • src/utils/privacyLevel.ts
  • src/utils/processUserInput/processSlashCommand.tsx
  • src/utils/profilerRetention.test.ts
  • src/utils/providerFlag.test.ts
  • src/utils/providerFlag.ts
  • src/utils/providerProfile.test.ts
  • src/utils/providerProfile.ts
  • src/utils/providerProfiles.orcarouter.process.test.ts
  • src/utils/providerProfiles.test.ts
  • src/utils/providerProfiles.ts
  • src/utils/providerSelectionFlags.test.ts
  • src/utils/providerSelectionFlags.ts
  • src/utils/providerStartupOverrides.test.ts
  • src/utils/providerValidation.test.ts
  • src/utils/providerValidation.ts
  • src/utils/proxy.connect.test.ts
  • src/utils/proxy.noProxy.test.ts
  • src/utils/proxy.test.ts
  • src/utils/proxy.ts
  • src/utils/queryHelpers.ts
  • src/utils/queryProfiler.ts
  • src/utils/ripgrep.ts
  • src/utils/sandbox/sandbox-adapter.test.ts
  • src/utils/sandbox/sandbox-adapter.ts
  • src/utils/sentry.test.ts
  • src/utils/sentry.ts
  • src/utils/sessionActivity.ts
  • src/utils/sessionIngressAuth.ts
  • src/utils/sessionPersistencePolicy.ts
  • src/utils/sessionRestore.test.ts
  • src/utils/sessionState.ts
  • src/utils/sessionStorage.atomicReplace.test.ts
  • src/utils/sessionStorage.sessionSwitch.test.ts
  • src/utils/sessionStorage.test.ts
  • src/utils/sessionStorage.ts
  • src/utils/settings/applySettingsChange.ts
  • src/utils/settings/managedPath.ts
  • src/utils/settings/settings.ts
  • src/utils/settings/types.ts
  • src/utils/shell/bashProvider.ts
  • src/utils/shell/powershellProvider.ts
  • src/utils/shell/shellToolUtils.ts
  • src/utils/sideQuery.attribution.test.ts
  • src/utils/slowOperations.ts
  • src/utils/startupProfiler.ts
  • src/utils/status.routes.test.ts
  • src/utils/status.test.ts
  • src/utils/status.tsx
  • src/utils/statusNoticeLocalModel.ts
  • src/utils/streamlinedTransform.test.ts
  • src/utils/streamlinedTransform.ts
  • src/utils/subprocessEnv.test.ts
  • src/utils/subprocessEnv.ts
  • src/utils/swarm/constants.ts
  • src/utils/swarm/permissionSync.ts
  • src/utils/swarm/spawnUtils.test.ts
  • src/utils/swarm/spawnUtils.ts
  • src/utils/systemPrompt.ts
  • src/utils/tasks.ts
  • src/utils/teammate.ts
  • src/utils/teammateContext.ts
  • src/utils/teammateMailbox.ts
  • src/utils/telemetry/events.test.ts
  • src/utils/telemetry/events.ts
  • src/utils/teleport.tsx
  • src/utils/thinking.test.ts
  • src/utils/thinking.ts
  • src/utils/tmuxSocket.ts
  • src/utils/toolSearch.test.ts
  • src/utils/toolSearch.ts
  • src/utils/udsMessaging.ts
  • src/utils/undiciFetch.test.ts
  • src/utils/warningHandler.test.ts
  • src/utils/warningHandler.ts
  • src/utils/windowsPaths.test.ts
  • src/utils/windowsPaths.ts
  • src/utils/worktree.ts
  • src/utils/xaiCredentials.test.ts
  • tests/sdk/helpers/query-test-doubles.ts
  • tests/sdk/sdk-code-mode-transcript.test.ts
  • vscode-extension/openclaude-vscode/README.md
  • vscode-extension/openclaude-vscode/package.json
  • vscode-extension/openclaude-vscode/src/chat/chatProvider.js
  • vscode-extension/openclaude-vscode/src/extension.js
  • vscode-extension/openclaude-vscode/src/state.js
  • vscode-extension/openclaude-vscode/src/state.test.js
  • web/src/data/configuration.ts
  • web/src/data/providers.ts
  • web/src/pages/docs/providers.astro
  • web/src/pages/docs/quickstart.astro

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Pre-merge checks: Passed 1 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Risk Surface Disclosed Warning Applicability: the check applies. PR #2595 (Twigpine/openclaude, author Gravirei, base main, head fix/issue-2589-rebrand-env-vars) changes environment variables that drive provider routing and credent… Blocking (required before this check passes): - Add a review note that names each touched risk surface: provider routing and provider-selection flags, auth and credential env handling, managed settings env, provider env files, SDK permissio…
Passed Passed checks: 1 passed

Check name Status Explanation
No Hidden Policy Change Passed Summary: No hidden policy change found. The PR's policy-relevant behavior is the CLAUDE_* / CLAUDE_CODE_* to OPENCLAUDE_* environment rename. The PR title and description disclose it, and it…
Full details: No Hidden Policy Change

Explanation

Summary: No hidden policy change found. The PR's policy-relevant behavior is the CLAUDE_* / CLAUDE_CODE_* to OPENCLAUDE_* environment rename. The PR title and description disclose it, and it is the stated scope of #2589. I found no changed default in routing, telemetry, network, or permissions. Evidence (base 0021ae67, head 519fdad, 27 commits, 592 files): - Disclosed: The description states the namespace split, the legacy-name bridge, the unchanged ANTHROPIC_* names, the kept protocol names, and the deferred ANTHROPIC_* → TWIGPINE_* item. The bridge is in src/utils/envRebrand.ts and src/utils/envRebrandBootstrap.ts. - Routing and telemetry: Renamed switches keep the same gating. Examples: OPENCLAUDE_USE_* in providerSelectionFlags.ts, OPENCLAUDE_ENABLE_TELEMETRY in telemetry/events.ts, and OPENCLAUDE_DISABLE_NONESSENTIAL_TRAFFIC in sentry.ts. No default value changed in the diff. - Trust-gated settings: managedEnv.ts canonicalizes settings env before the SAFE_ENV_VARS check. Legacy aliases therefore map to the same canonical names that were already allowlisted. managedEnvConstants.ts changed only by renaming. Membership was not expanded. - Subprocess secret scrubbing: subprocessEnv.ts adds OPENCLAUDE_OAUTH_TOKEN and the legacy CLAUDE_CODE_OAUTH_TOKEN to the GitHub Actions scrub list. This tightens the policy. - Permissions: permissions.ts and sdk/query.ts apply canonicalizeEnvEntries to SDK env overrides. The mapping is one-to-one with the existing legacy keys. Non-blocking observations: - package.json bumps cross-spawn from 7.0.6 to 7.1.2, and the version moves 0.37.0 → 0.38.0. Neither change relates to the env rename. Splitting them out would make the review cleaner. This is not a listed policy category. - Maintainers should confirm the namespace split in #2589 is approved. The linked issue text was not available to me, so I could not verify that approval. - Inherited shell variables named CLAUDE_CODE_* still steer OpenClaude through the bridge. This matches prior behavior, but users sharing a shell with Claude Code should be told this in the migration docs.

Full details: Risk Surface Disclosed

Explanation

Applicability: the check applies. PR #2595 (Twigpine/openclaude, author Gravirei, base main, head fix/issue-2589-rebrand-env-vars) changes environment variables that drive provider routing and credentials. The PR description lists these surfaces: provider-selection flags (OpenAI, Gemini, Bedrock, Vertex, Foundry, GitHub Models, Mistral), managed settings env, provider env files, SDK session/query/permission env overrides, and subprocess secret scrubbing. The local checkout also shows changes under auth, MCP auth, OAuth, permissions, and skills/plugins paths. Those paths match the check's risk categories. Review evidence: no review threads were returned. The posted review comments section states "No CodeRabbit review threads were returned." No review calls out the risk surface or states whether any item is a blocker. The PR description does list affected surfaces under "Testing". It does not assess risk. It does not state whether any surface is a blocker. It also says the change is a rename with a compatibility bridge, which is a risk claim the review does not check (for example, legacy env names inherited from the shell and the precedence rule for canonical names). Scope note: the local HEAD diff against the merge-base has 592 files. It includes upstream merge content, so I did not use it to scope the PR's own changes. The verdict relies on the PR description and the file paths.

Resolution

Blocking (required before this check passes): - Add a review note that names each touched risk surface: provider routing and provider-selection flags, auth and credential env handling, managed settings env, provider env files, SDK permission env overrides, subprocess secret scrubbing, and MCP/OAuth paths. - State for each surface whether it introduces a blocker. Give the reason, and cite the test or code path that supports the statement. Non-blocking suggestions: - Confirm that legacy CLAUDE_* names read from shell env cannot override a canonical OPENCLAUDE_* value. Cite the test that covers this. - Confirm that the subprocess secret scrubbing list covers the renamed variables.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment thread src/utils/shell/bashProvider.ts Fixed
Copilot AI balanced review requested due to automatic review settings December 3, 2026 04:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: fix(env): move first-party variables to OPENCLAUDE_* namespace (#2589)

#2595
Head: 519fdad7dd32a81302eb920029fc63d21c7e519d · Base: 10b14987275fca42cc38522a3b763116d50ea7ed

Merge readiness

  • Review required: GitHub reports mergeStateStatus: BLOCKED / reviewDecision: REVIEW_REQUIRED (required review not satisfied yet).
  • Branch history: The PR branch carries older merge commits, but the three-dot diff against current main is the env-rename work (≈581 files, dominated by d9fb8adf); no extra unreleased integration blobs beyond main (e.g. Runcrate matches origin/main).
  • CodeRabbit pre-merge: "Risk Surface Disclosed" warning — expand the PR body with an explicit risk-surface note (provider routing, managed settings env, OAuth/subprocess scrub, SDK env overrides) so automated policy checks pass. The Testing section is close but the bot asked for a dedicated disclosure block.
  • Checks: All rolled-up PR checks succeeded on head 519fdad7 at review time.

Findings

🟠 P1 — Standalone launcher scripts must install the env bridge before reading canonical names

📍 Where: scripts/provider-launch.ts (and the same pattern in any other maintainer script that reads OPENCLAUDE_* from process.env without importing envRebrandBootstrap).

💥 What fails: An operator runs bun run scripts/provider-launch.ts (or the packaged equivalent) with legacy shell variables such as CLAUDE_CODE_USE_OPENAI=1 or CLAUDE_CODE_SIMPLE=1. The script reads only OPENCLAUDE_* (for example OPENCLAUDE_PROFILE_GOAL, fast-path flags, and provider routing inside buildLaunchEnv / resolveActiveRouteIdFromEnv). Without the import-time bridge, legacy names never mirror into canonical names, so auto profile selection, credentials, and spawned openclaude children can follow the wrong provider or fail credential checks.

🔎 Root cause: Entrypoints covered by envRebrand.test.ts import envRebrandBootstrap, but provider-launch.ts does not, while this PR retargeted the script to canonical names.

📜 Stated contract:

"legacy names are accepted from shell env, settings env, provider env files, and SDK env overrides." (PR description)

🏷️ Attribution: PR-worsened — on main, the script consumed CLAUDE_CODE_* directly; the rename to OPENCLAUDE_* removed that implicit compatibility for this entry path.

📌 In this PR:

  • scripts/provider-launch.ts — no bootstrap; canonical reads and applyFastFlags only
  • scripts/system-check.ts — already imports bootstrap (use as sibling pattern)

🔒 Unchanged on main: Core envRebrand helpers.

🔧 Required correction: Import envRebrandBootstrap before any other module that reads provider env (match system-check.ts), or apply applyLegacyEnvAliases on the launch env object before provider resolution. Add a launcher test that sets only a legacy provider flag and expects the same profile as the canonical flag.

🛠️ Author fix: Close the root cause on every maintainer script entry path in this PR that reads OPENCLAUDE_* from the shell without the bridge — not only provider-launch.ts if others match after grep.

🚫 Out of scope: Rewriting buildLaunchEnv or provider routing helpers.


🟡 P2 — canonicalizeEnvEntries must apply the same CLAUDE_CODE-over-CLAUDE rule as the shell bridge

📍 Where: src/utils/envRebrand.ts (canonicalizeEnvEntries); SDK callers src/entrypoints/sdk/query.ts, permissions.ts, v2.ts.

💥 What fails: SDK env override objects that contain both CLAUDE_* and CLAUDE_CODE_* aliases for the same canonical key (with no explicit OPENCLAUDE_* entry) keep whichever legacy pair appears first in the iterable, not the more specific CLAUDE_CODE_* value.

order CLAUDE_TMPDIR then CLAUDE_CODE_TMPDIR → OPENCLAUDE_TMPDIR = generic
order CLAUDE_CODE_TMPDIR then CLAUDE_TMPDIR → OPENCLAUDE_TMPDIR = code

🔎 Root cause: The legacy pass in canonicalizeEnvEntries is a single FIFO merge; it does not sort legacy aliases CODE-before-CLAUDE the way applyLegacyEnvAliases does.

📜 Stated contract:

Test applyLegacyEnvAliases > "prefers CLAUDE_CODE_* over CLAUDE_* on a collision" (src/utils/envRebrand.test.ts).

🏷️ Attribution: PR-introduced — helper added in this PR for SDK overrides.

📌 In this PR:

  • src/utils/envRebrand.ts — canonicalizeEnvEntries
  • SDK merge sites that call it for env overrides

🔒 Unchanged on main: N/A (new helper).

🔧 Required correction: When merging legacy aliases in canonicalizeEnvEntries, apply the same CODE-then-CLAUDE priority (or merge legacy entries CODE-first before filling gaps). Add a regression test mirroring the applyLegacyEnvAliases collision case for SDK-shaped entry lists.

🛠️ Author fix: Fix the helper and add tests once; all SDK call sites inherit the fix.

🚫 Out of scope: Changing canonical-vs-legacy precedence when an explicit OPENCLAUDE_* key is present (already tested).


🟡 P2 — Subprocess scrub gate should honor the legacy scrub flag at the read site

📍 Where: src/utils/subprocessEnv.ts (subprocessEnv).

💥 What fails: Workflows or wrappers that still set CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 (documented on main for claude-code-action) but do not run import-time bootstrap before the first subprocessEnv() call see scrubbing disabled, so children inherit secrets listed in GHA_SUBPROCESS_SCRUB (OAuth tokens, cloud keys, etc.).

🔎 Root cause: The gate was renamed to OPENCLAUDE_SUBPROCESS_ENV_SCRUB without an explicit legacy fallback at the read site. Bootstrap usually mirrors shell legacy names, but this PR already uses explicit legacy reads elsewhere (e.g. getDefaultMaxRetries).

📜 Stated contract:

"legacy names are accepted from shell env …" (PR description)

🏷️ Attribution: PR-worsened — main gated on CLAUDE_CODE_SUBPROCESS_ENV_SCRUB directly.

📌 In this PR:

  • src/utils/subprocessEnv.ts — gate read
  • src/utils/subprocessEnv.test.ts — extend coverage

🔒 Unchanged on main: Scrub list contents (aside from added OPENCLAUDE_OAUTH_TOKEN).

🔧 Required correction: Treat scrub as enabled when either canonical or legacy scrub env is truthy (mirror the getDefaultMaxRetries pattern). Add a test with only CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1.

🛠️ Author fix: Implement the dual read and test in one pass.

🚫 Out of scope: Changing which secrets are scrubbed.


🟡 P2 — Managed-settings security UI must canonicalize legacy safe env keys before the allowlist check

📍 Where: src/components/ManagedSettingsSecurityDialog/utils.ts (extractDangerousSettings); src/utils/managedEnvConstants.ts (SAFE_ENV_VARS).

💥 What fails: A settings.json / project settings.env that still uses legacy safe keys (for example CLAUDE_CODE_USE_OPENAI=1) is flagged as "dangerous" in the security dialog because SAFE_ENV_VARS now lists only OPENCLAUDE_*, even though managedEnv.ts canonicalizes those keys on apply.

🔎 Root cause: The dialog checks raw setting keys against the renamed allowlist without running toCanonicalEnvName / canonicalizeEnvKeys.

📜 Stated contract:

"legacy names are accepted from … settings env" (PR description). On main, CLAUDE_CODE_USE_OPENAI was a safe allowlist member.

🏷️ Attribution: PR-introduced — allowlist rename without dialog update.

📌 In this PR:

  • src/components/ManagedSettingsSecurityDialog/utils.ts
  • src/utils/managedEnvConstants.ts (allowlist rename)

🔒 Unchanged on main: Threat model for genuinely unsafe vars.

🔧 Required correction: Map each settings env key through toCanonicalEnvName (or reuse canonicalizeEnvKeys) before SAFE_ENV_VARS.has. Add a dialog unit test with a legacy safe provider flag that must not be classified as dangerous.

🛠️ Author fix: Update the dialog helper and tests together.

🚫 Out of scope: Re-expanding the safe list to unrelated third-party secrets.

Copilot AI balanced review requested due to automatic review settings December 3, 2026 20:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Gravirei
Gravirei requested a review from jatmn December 3, 2026 20:43

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not ready to merge this until the items below are addressed.

Merge readiness

  • Rebase required: GitHub reports mergeable: CONFLICTING / mergeStateStatus: DIRTY. I ran git merge-tree and see changed in both on src/services/api/claude.lifecycle.test.ts and src/services/api/codexShim.test.ts vs current origin/main. Please rebase onto main, resolve those env-fixture hunks, and re-run PR checks.
  • Review scope: gh pr diff exceeded GitHub's 300-file limit, so I used a local base→head diff (merge_base 10b14987275fca42cc38522a3b763116d50ea7ed, head 01acb4fd118c9be6f59ac84cae6c8de5c0430370). CI on head was green when I reviewed.
  • What I ran: bun test src/utils/envRebrand.test.ts src/utils/envFile.test.ts src/utils/subprocessEnv.test.ts — 73 pass.
  • Pre-existing (I'm not blocking on this): src/utils/sandbox/sandbox-adapter.ts is unchanged on this diff. Extra config-home denyWrite still keys only on CLAUDE_CONFIG_DIR; operators using only OPENCLAUDE_CONFIG_DIR had the same sandbox coverage gap at merge-base. I won't count that as a defect introduced here; we can harden it here or in a follow-up.

Findings

🟠 P1 — Apply the same legacy collision precedence in canonicalizeEnvKeys as the rest of the bridge

📍 Where: src/utils/envRebrand.ts (canonicalizeEnvKeys); consumers src/utils/managedEnv.ts (filterSettingsEnv), src/utils/envFile.ts (loadEnvFile).

💥 What fails: When a settings or env-file object contains both legacy spellings that map to the same canonical key (e.g. CLAUDE_TMPDIR and CLAUDE_CODE_TMPDIR) and no explicit OPENCLAUDE_* value, the winner depends on object insertion order. CLAUDE_CODE_* may lose even though the module documents that CLAUDE_CODE_* wins on collisions.

🔎 Root cause: canonicalizeEnvEntries and applyLegacyEnvAliases apply CODE-before-CLAUDE priority; canonicalizeEnvKeys walks Object.entries into a flat legacy list and last-write wins.

📜 Stated contract:

Legacy aliases in canonicalizeEnvEntries follow the same CLAUDE_CODE_-before-CLAUDE_ priority as applyLegacyEnvAliases. Issue #2589 / this PR: legacy fallback must keep existing installations working during migration.

🏷️ Attribution: Introduced in this PR (envRebrand.ts is new). I reproduced with bun -e on head.

📌 In this PR:

  • canonicalizeEnvKeys — order-dependent collision
  • managedEnv settings apply — uses canonicalizeEnvKeys
  • Provider/settings env files — envFile.loadEnvFile uses canonicalizeEnvKeys
  • Tests — no regression case in canonicalizeEnvKeys describe (unlike canonicalizeEnvEntries)

🔧 Required correction: In canonicalizeEnvKeys, resolve legacy collisions with the same CODE-then-CLAUDE priority as applyLegacyEnvAliases (e.g. two-pass legacy collection). Add a regression test mirroring the existing canonicalizeEnvEntries collision cases.

🛠️ Author fix: Fix canonicalizeEnvKeys and add tests in envRebrand.test.ts; don't expand unrelated rename churn.


🟠 P1 — Canonicalize legacy keys when loading persisted provider profiles

📍 Where: src/utils/providerProfile.ts — readProfileFile, buildStartupEnvFromProfile, route-retarget guards on persisted.env.OPENCLAUDE_PROVIDER_ROUTE_ID.

💥 What fails: On-disk ~/.openclaude*.json profile files saved before this rename store CLAUDE_CODE_PROVIDER_ROUTE_ID and related CLAUDE_CODE_USE_* flags (merge-base used those names). Head reads only OPENCLAUDE_PROVIDER_ROUTE_ID / OPENCLAUDE_USE_* from persisted.env with no canonicalizeEnvKeys (or equivalent) after JSON parse. Route guards and startup env then behave as if no route was saved.

🔎 Root cause: Runtime rename without a persistence read-path bridge for profile JSON (unlike managedEnv / envFile, which call canonicalizeEnvKeys on apply).

📜 Stated contract:

This PR accepts legacy names from settings env and provider env files during migration; saved provider profiles are the same kind of persisted operator configuration.

🏷️ Attribution: Introduced / incomplete migration in this PR (providerProfile.ts is in the diff).

📌 In this PR:

  • readProfileFile / loadProfileFile — raw parsed.env
  • buildStartupEnvFromProfile and route-id guards — OPENCLAUDE_PROVIDER_ROUTE_ID only
  • Tests — legacy openai saved profiles cases cover provider credential shape, not renamed env keys in env

🔧 Required correction: Run canonicalizeEnvKeys (or shared helper) on profile env at load before consumers read fields. Add a regression test with a fixture profile containing CLAUDE_CODE_PROVIDER_ROUTE_ID (and at least one CLAUDE_CODE_USE_*) proving startup rebuild matches pre-rename behavior.

🛠️ Author fix: Close load + guard paths in one pass; optional one-time rewrite on save is fine but not sufficient alone.


🟡 P2 — Trust dialog must canonicalize legacy safe settings.env keys like managed-settings security UI

📍 Where: src/components/TrustDialog/utils.ts (hasDangerousEnvVars, getDangerousEnvVarsSources); contrast src/components/ManagedSettingsSecurityDialog/utils.ts (updated in this PR with toCanonicalEnvName).

💥 What fails: Project/local settings.env still contains allowlisted legacy keys (e.g. CLAUDE_CODE_USE_OPENAI=1). Managed settings apply treats them as safe after canonicalization; Trust dialog flags the file as having “dangerous env vars” because it checks raw keys against SAFE_ENV_VARS.

🔎 Root cause: This PR updated one security dialog sibling but not the Trust dialog path.

📜 Stated contract:

Same as the managed-settings dialog comment: canonicalize legacy keys before SAFE_ENV_VARS so safe keys spelled the old way match the renamed allowlist.

🏷️ Attribution: Introduced in this PR (partial sibling fix).

📌 In this PR: ManagedSettingsSecurityDialog/utils.ts — fixed; TrustDialog/utils.ts — not updated; TrustDialog/utils.test.ts — extend if needed.

🔧 Required correction: Mirror the ManagedSettingsSecurityDialog loop: toCanonicalEnvName(upper) ?? upper before SAFE_ENV_VARS.has. Add/extend tests for a safe legacy key in project settings.

🛠️ Author fix: Both dialog paths in one pass.


🟡 P2 — Code Mode enablement must honor legacy user settings.env keys

📍 Where: src/tools/REPLTool/constants.ts (resolveCodeModeEnablement); caller src/main.tsx (configureCodeModeForInteractiveSession).

💥 What fails: User settings contain only CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1. Enablement reads userSettingsEnv?.[OPENCLAUDE_EXPERIMENTAL_CODE_MODE] only. Shell legacy still works via bootstrap + process snapshot; user settings file legacy does not.

🔎 Root cause: Code Mode resolver bypasses the same canonicalization managedEnv uses for settings apply. At merge-base CODE_MODE_ENV_VAR was CLAUDE_CODE_EXPERIMENTAL_CODE_MODE, so this used to work for legacy keys in user settings.

📜 Stated contract:

Issue #2589 / this PR: backward compatibility for settings env; docs/advanced-setup.md documents OPENCLAUDE_EXPERIMENTAL_CODE_MODE as canonical with migration expected.

🏷️ Attribution: Introduced in this PR (rename without resolver parity).

📌 In this PR: resolveCodeModeEnablement, main.tsx caller, managedEnvConstants.ts (CODE_MODE_ENV_VAR), legacyEnvNames.generated.ts (includes CLAUDE_CODE_EXPERIMENTAL_CODE_MODE).

🔧 Required correction: When reading userSettingsEnv, canonicalize keys (or check legacy alias via toCanonicalEnvName) before comparing to CODE_MODE_ENV_VAR. Add test in constants.test.ts with legacy-only user settings env.

🛠️ Author fix: Resolver + test only; don't change consent flow.

@Gravirei
Gravirei force-pushed the fix/issue-2589-rebrand-env-vars branch from 01acb4f to 12b5c2c Compare December 4, 2026 06:27
Copilot AI balanced review requested due to automatic review settings December 4, 2026 06:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…ttings boundaries

- Install the env rebrand bridge in provider-launch, provider-bootstrap, and
  provider-recommend so legacy shell flags (e.g. CLAUDE_CODE_USE_OPENAI) mirror
  into canonical OPENCLAUDE_* names before provider env is read.
- Make canonicalizeEnvEntries prefer CLAUDE_CODE_* over CLAUDE_* on a collision,
  matching applyLegacyEnvAliases for SDK env overrides.
- Enable subprocess scrubbing when either OPENCLAUDE_SUBPROCESS_ENV_SCRUB or the
  legacy CLAUDE_CODE_SUBPROCESS_ENV_SCRUB flag is truthy.
- Canonicalize settings env keys before the SAFE_ENV_VARS allowlist check so
  legacy safe keys are not misclassified as dangerous in the security dialog.
@Gravirei
Gravirei force-pushed the fix/issue-2589-rebrand-env-vars branch from 12b5c2c to 98b1eb8 Compare December 4, 2026 07:41
Copilot AI balanced review requested due to automatic review settings December 4, 2026 07:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Gravirei
Gravirei requested a review from jatmn December 4, 2026 07:41
CLAUDE_CODE_TMPDIR and CLAUDE_TMPDIR both canonicalize to
OPENCLAUDE_TMPDIR, so the rename left two identical consecutive writes in
the bash and PowerShell shell providers. CodeQL flagged the second write as
a useless assignment; keep one.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 07:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked on head ba8a5a8475255b30f0d3391a2488e90aadfe81b9 (base / merge-base 7f971ac024fc22a2b640df7710d7bd548f16d03e). The earlier change-requested review targeted older SHAs; the items from that review appear addressed on this head (launcher bootstrap, canonicalizeEnvKeys / canonicalizeEnvEntries collision precedence, subprocess scrub dual-read, managed/trust security dialogs, profile JSON canonicalization, Code Mode user-settings legacy). CI rollup is green on this head; GitHub still shows mergeStateStatus: BLOCKED until a fresh approving review lands.

Merge readiness

  • Fresh review required: reviewDecision remains CHANGES_REQUESTED from the prior review on older heads. Please dismiss or supersede that state with a new review on ba8a5a84 after addressing the finding below (or confirming accept risk).
  • Branch / merge-base: Three-dot diff is current with origin/main at preparation time (merge_base == base). No merge conflicts observed locally.
  • Checks: All reported PR check rollup jobs succeeded on head when fetched (PR Checks, Install hygiene, CodeQL, VS Code launcher, typecheck, web).
  • Note: gh pr diff exceeds GitHub’s 300-file API cap; local git diff merge-base..head was used for review (589 files).

Findings

🟡 P2 — Canonical OPENCLAUDE_TMPDIR must reach @anthropic-ai/sandbox-runtime temp injection

📍 Where: src/utils/permissions/filesystem.ts (getClaudeTempDir), src/utils/sandbox/sandbox-adapter.ts (sandbox startup path), vendored @anthropic-ai/sandbox-runtime@0.0.81 dist/sandbox/sandbox-utils.js.

💥 What fails: An operator migrates to only OPENCLAUDE_TMPDIR (no legacy CLAUDE_CODE_TMPDIR / CLAUDE_TMPDIR in the environment). OpenClaude’s permission and temp helpers follow the canonical path, but sandbox-runtime still builds child TMPDIR from the legacy chain and falls back to /tmp/claude:

const tmpdir = process.env.CLAUDE_CODE_TMPDIR ||
    process.env.CLAUDE_TMPDIR ||
    '/tmp/claude';

That diverges from getClaudeTempDir() (reads process.env.OPENCLAUDE_TMPDIR first). Sandboxed tool execution can use a different writable temp root than the paths OpenClaude computed for FS policy — surprising denials, wrong temp location, or inconsistent cleanup for custom-tmpdir setups.

🔎 Root cause: The env rename updated first-party readers and the one-way legacy→canonical bridge, but the pinned sandbox-runtime package was not updated to read OPENCLAUDE_TMPDIR, and OpenClaude does not mirror canonical tmpdir into the legacy names the dependency still consults before wrapping.

📜 Stated contract:

OpenClaude-specific variables use OPENCLAUDE_* … Legacy CLAUDE_* / CLAUDE_CODE_* names are accepted as fallbacks during migration (.env.example header; PR description).

🏷️ Attribution: PR-introduced. At merge-base, getClaudeTempDir and the dependency both keyed off CLAUDE_CODE_TMPDIR; canonical-only OPENCLAUDE_TMPDIR is new on this head.

📌 In this PR:

  • getClaudeTempDir / related FS allow paths — canonical tmpdir
  • bashProvider.ts / powershellProvider.ts — set OPENCLAUDE_TMPDIR on shell children (legacy duplicate writes removed)
  • Sandbox integration — no bridge for sandbox-runtime’s legacy tmpdir read
  • Tests — legacy tmpdir collision tests in envRebrand.test.ts; no regression for canonical-only tmpdir + sandbox-runtime

🔒 Unchanged on main: Vendored sandbox-runtime version pin; upgrading the package is optional follow-up, not required in this finding.

🔧 Required correction: Before sandbox-runtime reads process.env for tmpdir (sandbox manager init or wrap), ensure the effective temp root matches getClaudeTempDir() / OPENCLAUDE_TMPDIR — e.g. set CLAUDE_CODE_TMPDIR from the canonical value only for sandbox-runtime consumption, or inject equivalent TMPDIR in the sandbox child env the adapter already controls. Add a focused test: OPENCLAUDE_TMPDIR alone → sandbox wrapper child env TMPDIR aligns with getClaudeTempDir() (no reliance on /tmp/claude default).

🛠️ Author fix: Close the tmpdir bridge on every sandbox spawn/init path this PR touches in one pass; do not revert the OPENCLAUDE_* rename or require operators to keep exporting legacy tmpdir forever.

🚫 Out of scope: Forking sandbox-runtime, repo-wide dependency bumps, or changing default /tmp/claude for users who set no custom tmpdir at all.

This branch has not been deployed

No deployments
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.

4 participants