Skip to content

claude: honor $CLAUDE_CONFIG_DIR for the settings file location - #343

Open
eabrouwer3 wants to merge 2 commits into
databricks:mainfrom
eabrouwer3:claude/issue-342-fix-l8l7mf
Open

claude: honor $CLAUDE_CONFIG_DIR for the settings file location#343
eabrouwer3 wants to merge 2 commits into
databricks:mainfrom
eabrouwer3:claude/issue-342-fix-l8l7mf

Conversation

@eabrouwer3

@eabrouwer3 eabrouwer3 commented Aug 14, 2026

Copy link
Copy Markdown

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 #342

Copilot AI lite review requested due to automatic review settings August 14, 2026 22:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_DIR with a ~/.claude fallback (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.

Comment thread src/ucode/agents/claude.py
Comment thread src/ucode/config_io.py Outdated
Copilot AI review requested due to automatic review settings August 17, 2026 16:07
@eabrouwer3
eabrouwer3 force-pushed the claude/issue-342-fix-l8l7mf branch from 92824fd to b572a03 Compare August 17, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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
@eabrouwer3
eabrouwer3 force-pushed the claude/issue-342-fix-l8l7mf branch from b572a03 to c86cb79 Compare August 17, 2026 16:12
Copilot AI review requested due to automatic review settings August 17, 2026 16:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json env block, but this agent actually writes ucode-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)."""

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_DIR fallback 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 (see CLAUDE_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)."""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Custom $CLAUDE_CONFIG_DIR

3 participants