Agent hardcodes ~/.claude/ instead of respecting $CLAUDE_CONFIG_DIR

Status Fixed / completed
Maintainer reply None cached
Activity 3 comments · opened Apr 20, 2026 · closed Apr 20, 2026

Bug Description

When the Claude Code agent needs to locate configuration files (e.g., settings.json), it defaults to searching ~/.claude/ rather than resolving $CLAUDE_CONFIG_DIR from the environment first. This happens even when $CLAUDE_CONFIG_DIR is set and the CLI itself correctly loads settings from the custom config directory.

Steps to Reproduce

  1. Set CLAUDE_CONFIG_DIR to a custom path (e.g., via direnv: export CLAUDE_CONFIG_DIR=.claude-custom)
  2. Place a settings.json in that custom config directory
  3. Start Claude Code — the CLI correctly loads settings from $CLAUDE_CONFIG_DIR (env vars defined in settings.json are present in the environment)
  4. Ask the agent to check or find your settings file
  5. The agent searches ~/.claude/settings.json and ~/.claude/ first, finds nothing, and only discovers the correct location after multiple failed attempts

Expected Behavior

The agent should resolve $CLAUDE_CONFIG_DIR from the environment before constructing any path to Claude configuration files. It should never hardcode ~/.claude/.

Actual Behavior

The agent's trained default is to look in ~/.claude/. It consistently reaches for that path first, even when $CLAUDE_CONFIG_DIR is set to something else. The CLI layer respects the variable (settings load correctly), but the agent layer does not use it when reasoning about where config files live.

Environment

  • macOS (Darwin 25.4.0)
  • $CLAUDE_CONFIG_DIR set via direnv
  • Claude Code installed via Homebrew
  • Model: Opus 4.6 (1M context)

Additional Context

This is a systemic issue — the agent repeatedly defaults to ~/.claude/ across multiple conversations despite explicit user correction and saved memory entries instructing it to resolve $CLAUDE_CONFIG_DIR first. The problem appears to be in the model's trained prior, which strongly associates Claude config with ~/.claude/. The system prompt or agent scaffolding could mitigate this by injecting the resolved $CLAUDE_CONFIG_DIR value into the agent's context.

View original on GitHub ↗

3 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/47227
  2. https://github.com/anthropics/claude-code/issues/38641
  3. https://github.com/anthropics/claude-code/issues/47056

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

PSalant726 · 5 months ago
github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.