From c735233f926f19470a7e04ed439347f700d595e0 Mon Sep 17 00:00:00 2001 From: KRATOS <84986124+gnanam1990@users.noreply.github.com> Date: Fri, 3 Apr 2026 21:20:36 +0530 Subject: [PATCH] fix: change default config dir from ~/.claude to ~/.openclaude (#280) Prevents collision with existing Claude Code installations that already use ~/.claude for their own config, settings, and project data. Migration compatibility: if ~/.openclaude does not yet exist but ~/.claude does, the legacy path is kept automatically so existing openclaude users don't lose their data on upgrade. New installs go straight to ~/.openclaude. Users who need an explicit path can set CLAUDE_CONFIG_DIR. Fixes #184 Co-authored-by: Claude Sonnet 4.6 --- src/utils/envUtils.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/utils/envUtils.ts b/src/utils/envUtils.ts index 5a3ca96a..fb700117 100644 --- a/src/utils/envUtils.ts +++ b/src/utils/envUtils.ts @@ -1,4 +1,5 @@ import memoize from 'lodash-es/memoize.js' +import { existsSync } from 'fs' import { homedir } from 'os' import { join } from 'path' @@ -6,9 +7,18 @@ import { join } from 'path' // tests that change the env var get a fresh value without explicit cache.clear. export const getClaudeConfigHomeDir = memoize( (): string => { - return ( - process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude') - ).normalize('NFC') + if (process.env.CLAUDE_CONFIG_DIR) { + return process.env.CLAUDE_CONFIG_DIR.normalize('NFC') + } + const newDefault = join(homedir(), '.openclaude') + // Migration compatibility: if ~/.openclaude doesn't exist yet but ~/.claude + // does, keep using ~/.claude so existing users don't lose their data on + // upgrade. New installs (neither dir exists) go straight to ~/.openclaude. + const legacyPath = join(homedir(), '.claude') + if (!existsSync(newDefault) && existsSync(legacyPath)) { + return legacyPath.normalize('NFC') + } + return newDefault.normalize('NFC') }, () => process.env.CLAUDE_CONFIG_DIR, )