claude: honor $CLAUDE_CONFIG_DIR for the settings file location - #343
Open
eabrouwer3 wants to merge 1 commit into
Open
claude: honor $CLAUDE_CONFIG_DIR for the settings file location#343eabrouwer3 wants to merge 1 commit into
eabrouwer3 wants to merge 1 commit into
Conversation
Claude Code reads its user config from $CLAUDE_CONFIG_DIR when set, but ucode hardcoded ~/.claude. Users who keep separate personal and work config dirs got a ucode-settings.json written somewhere the launched `claude` never reads. Add a claude_config_dir() helper that resolves the env var with a fallback to ~/.claude, so existing setups are unchanged. Fixes databricks#342 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012fpivLSjbQ9QJMgfebeJoy
There was a problem hiding this comment.
Pull request overview
This PR updates the Claude Code agent integration so ucode writes/reads its Claude settings file from the same config directory Claude Code uses: $CLAUDE_CONFIG_DIR when set, otherwise ~/.claude. This resolves cases where users switch between multiple Claude config directories and ucode previously wrote ucode-settings.json into the wrong location.
Changes:
- Add a
claude_config_dir()helper to resolve$CLAUDE_CONFIG_DIRwith a~/.claudefallback (including tilde expansion and blank-var fallback). - Update the Claude agent to compute its settings path from
claude_config_dir(). - Add unit tests covering default behavior, env-var overrides, tilde expansion, and blank env-var fallback.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/ucode/config_io.py |
Adds claude_config_dir() helper for resolving the Claude Code config directory from environment with backward-compatible fallback. |
src/ucode/agents/claude.py |
Switches Claude settings directory to be derived from claude_config_dir() instead of a hardcoded ~/.claude. |
tests/test_config_io.py |
Adds focused tests validating claude_config_dir() behavior across env/default cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| from ucode.ui import print_err, print_note, print_success, print_warning | ||
|
|
||
| CLAUDE_CONFIG_DIR = Path.home() / ".claude" | ||
| CLAUDE_CONFIG_DIR = claude_config_dir() |
Comment on lines
+27
to
+30
| def claude_config_dir() -> Path: | ||
| """Claude Code's user config directory: ``$CLAUDE_CONFIG_DIR`` or ``~/.claude``.""" | ||
| override = os.environ.get("CLAUDE_CONFIG_DIR", "").strip() | ||
| return Path(override).expanduser() if override else Path.home() / ".claude" |
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.
Claude Code reads its user config from $CLAUDE_CONFIG_DIR when set, but ucode hardcoded ~/.claude. Users who keep separate personal and work config dirs got a ucode-settings.json written somewhere the launched
claudenever reads.Add a claude_config_dir() helper that resolves the env var with a fallback to ~/.claude, so existing setups are unchanged.
Fixes #342