-
Notifications
You must be signed in to change notification settings - Fork 6k
feat: support CLAUDE_CONFIG_DIR environment variable #6550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
- Add CLAUDE_CONFIG_DIR to Flag namespace - Add Global.claudeConfigDir() function with proper fallback logic: 1. CLAUDE_CONFIG_DIR env var (if set and is a directory) 2. ~/.config/claude (new Claude Code default) 3. ~/.claude (legacy path) - Update system.ts to use dynamic path for CLAUDE.md - Update skill.ts to use dynamic path for skills directory - Add unit tests for claudeConfigDir logic This fixes compatibility with Claude Code v1.0.30+ which changed the default config directory from ~/.claude to ~/.config/claude.
| async function isDirectory(p: string): Promise<boolean> { | ||
| const stat = await fs.stat(p).catch(() => undefined) | ||
| return stat?.isDirectory() ?? false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer Bun apis, see style guide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, thanks for the speedy review <3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Investigated Bun APIs - Bun.file().exists() returns false for directories, so there is no Bun-native way to check if a path is a directory. The fs.stat approach is necessary and consistent with other directory operations in this file (fs.mkdir, fs.readdir, fs.rm). Implemented by Claude (claude-opus-4-5-thinking).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have u seen stats method for a bun file? see other locations in our codebase there is an isDirectory check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a bun installation problem, one min
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
|
/review |
| const envDir = process.env.CLAUDE_CONFIG_DIR | ||
| if (envDir && (await isDirectory(envDir))) return envDir | ||
|
|
||
| const xdgPath = process.env.XDG_CONFIG_HOME || path.join(Path.home, ".config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const xdgPath = process.env.XDG_CONFIG_HOME || path.join(Path.home, ".config")
Whats the purpose of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of XDG_CONFIG_HOME you mean? 🤔
https://specifications.freedesktop.org/basedir/latest/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I particularly have my XDG vars set to "standard" values, but in theory (and maybe windows?) you could set them to any directory and most linux/macos software "should" honor them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rekram1-node 👋🏻 Did I answer your question?
- packages/opencode/src/global/index.ts - packages/opencode/test/global/claude-config-dir.test.ts
|
Hey @rekram1-node 👋🏻 |
Summary
CLAUDE_CONFIG_DIRenvironment variable~/.config/claude(new Claude Code default) then~/.claude(legacy)~/.claudeis a file instead of directoryFixes #6551
Changes
CLAUDE_CONFIG_DIRto Flag namespaceGlobal.claudeConfigDir()function with proper fallback logicsystem.tsto use dynamic path for CLAUDE.mdskill.tsto use dynamic path for skills directoryTesting
CLAUDE_CONFIG_DIRset to custom path