[BUG] ~/.claude/settings.local.json env vars not applied to Bash tool subprocesses

Resolved 💬 4 comments Opened Mar 18, 2026 by mrskiro Closed Apr 26, 2026

Problem

Environment variables defined in ~/.claude/settings.local.json (user-scope local settings) are not injected into Bash tool subprocesses, while ~/.claude/settings.json env vars work correctly.

Reproduction

  1. Set env vars in ~/.claude/settings.local.json:
{
  "env": {
    "MY_API_KEY": "some-value",
    "ANOTHER_KEY": "another-value"
  }
}
  1. Set env vars in ~/.claude/settings.json:
{
  "env": {
    "ENABLE_TOOL_SEARCH": "true"
  }
}
  1. In a Claude Code session, run via Bash tool:
echo "MY_API_KEY=$MY_API_KEY"          # empty
echo "ANOTHER_KEY=$ANOTHER_KEY"        # empty
echo "ENABLE_TOOL_SEARCH=$ENABLE_TOOL_SEARCH"  # "true" ✓

Only env vars from ~/.claude/settings.json are available. Both vars in settings.local.json are empty.

Expected behavior

~/.claude/settings.local.json env vars should be merged into the session environment, following the same scope precedence as other settings (local overrides user).

Why this matters

~/.claude/settings.json is often managed by dotfile managers (e.g. chezmoi) and committed to a repository. API keys and other secrets should not be stored there. A user-scope settings.local.json is the natural place for secret env vars, similar to how project-scope .claude/settings.local.json is gitignored for the same reason.

Environment

  • macOS (Darwin 25.3.0)
  • Claude Code latest version

Notes

  • The settings documentation only lists settings.local.json under Project/Local scope, not User scope. It's unclear whether ~/.claude/settings.local.json is intended to be supported — if not, this is a feature request rather than a bug.
  • Project-scope .claude/settings.local.json env vars were not tested in this report.

View original on GitHub ↗

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