Repository navigation
feat: use --settings CLI param to override settings.json env conflicts - #85
Merged
Merged
Conversation
Replace the hard guard (refuse-to-start) approach with automatic override via Claude Code's --settings CLI parameter. Key discovery: --settings has 'Command line arguments' priority (level 2), which is higher than User settings (level 5, ~/.claude/settings.json). The env from --settings merges with settings.json env, with same-name keys overridden by --settings. Changes: - Remove checkSettingsEnvConflict() and checkValidateEnvConflict() - Remove FilterUserEnvForSettings(), DetectSettingsEnvConflicts(), FormatEnvConflictError() and env_guard.go - Add buildProviderSettingsJSON() to serialize provider env as --settings JSON with env var expansion - SwitchWithHook() now preserves user's complete env in settings.json - runClaude() passes provider env via --settings parameter Behavior change: - Before: settings.json env conflict → error and abort - After: settings.json env conflict → --settings auto-override See docs/discuss-20260609-env-override.md for empirical proof.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the hard guard (refuse-to-start) approach with automatic override via Claude Code's
--settingsCLI parameter.Key Discovery
--settingshas "Command line arguments" priority (level 2), which is higher than User settings (level 5,~/.claude/settings.json). The env from--settingsmerges with settings.json env, with same-name keys overridden by--settings, different keys preserved.Empirical proof:
docs/discuss-20260609-env-override.mdChanges
checkSettingsEnvConflict()andcheckValidateEnvConflict()FilterUserEnvForSettings(),DetectSettingsEnvConflicts(),FormatEnvConflictError()andenv_guard.gobuildProviderSettingsJSON()to serialize provider env as--settingsJSON with env var expansionSwitchWithHook()now preserves user's complete env in settings.jsonrunClaude()passes provider env via--settingsparameterBehavior Change
--settingsauto-overrideVerification (7 scenarios, real claude 2.1.169 process)
Testing
./check.shbuildProviderSettingsJSON()(nil, empty, single key, multiple keys, special chars, env var expansion)