feat(config): add OPENCLAUDE_CONFIG_DIR env var as preferred alias (#454)#935
Open
gnanam1990 wants to merge 1 commit intomainfrom
Open
feat(config): add OPENCLAUDE_CONFIG_DIR env var as preferred alias (#454)#935gnanam1990 wants to merge 1 commit intomainfrom
gnanam1990 wants to merge 1 commit intomainfrom
Conversation
…r CLAUDE_CONFIG_DIR (#454) The legacy CLAUDE_CONFIG_DIR name was the only way to point openclaude at a non-default config home, which leaked Anthropic branding for a fork that has otherwise rebranded to OpenClaude. Add OPENCLAUDE_CONFIG_DIR as the preferred name. CLAUDE_CONFIG_DIR continues to work for backward compatibility; when both are set with different values, OPENCLAUDE_CONFIG_DIR wins and a one-time warning is logged. - src/utils/envUtils.ts: introduce resolveConfigDirEnv() that picks OPENCLAUDE_CONFIG_DIR over CLAUDE_CONFIG_DIR and emits a conflict warning. Memoize cache key now tracks both env vars so changing either invalidates the cached result. - src/utils/env.ts: getGlobalClaudeFile() previously read CLAUDE_CONFIG_DIR directly, missing the new alias. Route through resolveConfigDirEnv() so the global config file path follows the same precedence. - src/utils/secureStorage/macOsKeychainHelpers.ts: the "is default dir" check used by keychain service-name scoping now considers both env vars. - src/utils/swarm/spawnUtils.ts: forward OPENCLAUDE_CONFIG_DIR to teammate processes alongside the legacy var. - src/utils/openclaudePaths.test.ts: +6 unit tests covering the new alias, fallthrough, conflict warning, and resolveConfigDirEnv() in isolation. - .env.example: document both env vars and the precedence rule. Verified locally on Linux: with only OPENCLAUDE_CONFIG_DIR set, with only CLAUDE_CONFIG_DIR set (legacy still works), with both set matching (silent), with both set conflicting (warn once + OPENCLAUDE wins), with neither set (default ~/.openclaude). Memo cache invalidates across 4 sequential env transitions. Built dist/cli.mjs honors the new var and emits the conflict warning to the user.
kevincodex1
approved these changes
May 2, 2026
Vasanthdev2004
approved these changes
May 3, 2026
Collaborator
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Thanks for the PR. I reviewed the current head and this looks good from my side.
Scope: Targeted review of the config-directory alias change and its direct call sites.
Verdict: Approve-ready
What I checked:
resolveConfigDirEnv()precedence:OPENCLAUDE_CONFIG_DIRwins,CLAUDE_CONFIG_DIRremains a legacy fallback, and conflict warnings are one-time.getGlobalClaudeFile()now follows the same resolver instead of reading only the legacy env var.- Keychain service scoping and teammate env forwarding both consider the preferred and legacy config-dir env vars.
.env.exampledocuments the preferred name, legacy alias, and precedence rule.- Ran
bun test src/utils/openclaudePaths.test.ts— 16/16 passed. - Ran
bun run build— passed.
I do not see a remaining blocker on the current head.
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
Closes #454.
The legacy `CLAUDE_CONFIG_DIR` name was the only way to point openclaude at a non-default config home, which leaked Anthropic branding for a fork that has otherwise rebranded. This adds `OPENCLAUDE_CONFIG_DIR` as the preferred env var. `CLAUDE_CONFIG_DIR` continues to work for backward compatibility; when both are set with different values, `OPENCLAUDE_CONFIG_DIR` wins and a one-time warning is logged so users can clean up.
Behavior
/.openclaude` (or `/.claude` for legacy installs that pre-date PR #280)Conflict warning example:
Changes
Test plan
Notes for review
/.openclaude` for new installs, `/.claude` for legacy) is preserved unchanged.