Agent hardcodes ~/.claude/ instead of respecting $CLAUDE_CONFIG_DIR
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
- Set
CLAUDE_CONFIG_DIRto a custom path (e.g., via direnv:export CLAUDE_CONFIG_DIR=.claude-custom) - Place a
settings.jsonin that custom config directory - Start Claude Code — the CLI correctly loads settings from
$CLAUDE_CONFIG_DIR(env vars defined insettings.jsonare present in the environment) - Ask the agent to check or find your settings file
- The agent searches
~/.claude/settings.jsonand~/.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_DIRset 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗