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

Resolved 💬 3 comments Opened Apr 20, 2026 by PSalant726 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 ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗