claude: honor $CLAUDE_CONFIG_DIR for the settings file location - #343
claude: honor $CLAUDE_CONFIG_DIR for the settings file location#343eabrouwer3 wants to merge 2 commits into
Conversation
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.
92824fd to
b572a03
Compare
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. User-scope skill downloads follow it too — they previously landed in ~/.claude/skills, invisible to a `claude` running against another config dir. Project-scope downloads (`--path`) are unaffected: those dirs belong to the project, not the user's config. Docs and comments naming ~/.claude now say it is the default rather than the only location. Fixes databricks#342 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012fpivLSjbQ9QJMgfebeJoy
b572a03 to
c86cb79
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/ucode/agents/claude.py:2
- The module docstring says it writes the
settings.jsonenv block, but this agent actually writesucode-settings.json(a settings.json-format overlay). Clarifying the filename here will reduce confusion now that the config directory is no longer always~/.claude.
"""Claude Code agent: writes the settings.json env block into Claude Code's config
directory (``~/.claude`` by default, or ``$CLAUDE_CONFIG_DIR`` when set)."""
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/ucode/managed_resolve.py:10
- This docstring example mixes the default path (
~/.claude/ucode-settings.json) with the env-var override in a way that's easy to misread as both applying simultaneously. Consider describing the location as "/ucode-settings.json" with the default and$CLAUDE_CONFIG_DIRfallback spelled out once.
(e.g. ``~/.claude/ucode-settings.json``, under ``$CLAUDE_CONFIG_DIR`` when that is set), so managed
settings take precedence for every ``ucode`` command without either file being rewritten.
src/ucode/agents/claude.py:2
- Module docstring says the agent writes a "settings.json" env block, but this module actually writes ucode's overlay file
ucode-settings.json(seeCLAUDE_SETTINGS_PATH). Updating the docstring avoids confusion about which file ucode manages.
"""Claude Code agent: writes the settings.json env block into Claude Code's config
directory (``~/.claude`` by default, or ``$CLAUDE_CONFIG_DIR`` when set)."""
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