Bug Description
When running ccc, the entire env field in ~/.claude/settings.json gets removed, including user-defined environment variables that are not related to any provider.
Steps to Reproduce
- Create or edit
~/.claude/settings.json with custom env variables:
{
"permissions": {
"defaultMode": "bypassPermissions"
},
"env": {
"MY_CUSTOM_VAR": "some_value",
"ANTHROPIC_AUTH_TOKEN": "should_be_removed"
}
}
- Run
ccc (any provider)
- Check
~/.claude/settings.json again
- Observe that the entire
env field is missing
Expected Behavior
Only provider-related environment variables should be removed:
ANTHROPIC_* prefixed variables
CLAUDE_* prefixed variables
- Provider-specific env keys
User-defined environment variables like MY_CUSTOM_VAR should be preserved.
Actual Behavior
The entire env object is deleted from settings.json.
Root Cause Analysis
The issue is in internal/provider/provider.go:81:
// Remove env from settings before saving (provider env is passed via command line)
delete(settingsWithHook, "env")
This line removes the entire env field after CleanEnvInSettings() has already done the proper cleanup of provider-specific variables.
The code should preserve the result of CleanEnvInSettings() instead of deleting the entire env object.
Impact
- User custom environment variables are lost every time
ccc runs
- Users cannot persist custom configuration in
settings.json.env
- This breaks workflows that rely on custom environment variables
Suggested Fix
Remove line 81 in internal/provider/provider.go:
// Remove env from settings before saving (provider env is passed via command line)
delete(settingsWithHook, "env") // <- DELETE THIS LINE
The CleanEnvInSettings() function on line 65 already properly removes provider-related environment variables while preserving user-defined ones.
Test Case Update
The test in internal/provider/provider_test.go:99-102 should also be updated to expect that non-provider env variables are preserved.
Environment
- OS: macOS
- ccc version: current
- Go version: [if applicable]
Additional Context
The design intention to avoid persisting provider credentials to settings.json is good for security, but the current implementation is too aggressive and removes user configuration as well.
Bug Description
When running
ccc, the entireenvfield in~/.claude/settings.jsongets removed, including user-defined environment variables that are not related to any provider.Steps to Reproduce
~/.claude/settings.jsonwith custom env variables:{ "permissions": { "defaultMode": "bypassPermissions" }, "env": { "MY_CUSTOM_VAR": "some_value", "ANTHROPIC_AUTH_TOKEN": "should_be_removed" } }ccc(any provider)~/.claude/settings.jsonagainenvfield is missingExpected Behavior
Only provider-related environment variables should be removed:
ANTHROPIC_*prefixed variablesCLAUDE_*prefixed variablesUser-defined environment variables like
MY_CUSTOM_VARshould be preserved.Actual Behavior
The entire
envobject is deleted fromsettings.json.Root Cause Analysis
The issue is in
internal/provider/provider.go:81:This line removes the entire
envfield afterCleanEnvInSettings()has already done the proper cleanup of provider-specific variables.The code should preserve the result of
CleanEnvInSettings()instead of deleting the entireenvobject.Impact
cccrunssettings.json.envSuggested Fix
Remove line 81 in
internal/provider/provider.go:The
CleanEnvInSettings()function on line 65 already properly removes provider-related environment variables while preserving user-defined ones.Test Case Update
The test in
internal/provider/provider_test.go:99-102should also be updated to expect that non-provider env variables are preserved.Environment
Additional Context
The design intention to avoid persisting provider credentials to
settings.jsonis good for security, but the current implementation is too aggressive and removes user configuration as well.