setting_sources=["project"] still loads user-level ~/.claude/CLAUDE.md
Bug Description
When using the Claude Agent SDK with setting_sources=["project"], the user-level ~/.claude/CLAUDE.md is still loaded into the agent's context. According to the official documentation, only settingSources includes "user" should load ~/.claude/CLAUDE.md.
The docs state:
By default, the SDK loads no filesystem settings. Your agent runs in isolation mode with only what you pass programmatically.
And the loading table shows:
| Level | Location | When loaded |
|-------|----------|-------------|
| User | ~/.claude/CLAUDE.md | settingSources includes "user" |
Reproduction
from claude_agent_sdk import query, ClaudeAgentOptions
async for message in query(
prompt="What instructions do you have from CLAUDE.md?",
options=ClaudeAgentOptions(
setting_sources=["project"], # only project, NOT user
tools=[],
max_turns=1,
),
):
...
The agent responds with content from ~/.claude/CLAUDE.md, confirming it was loaded despite "user" not being in setting_sources.
Additionally, setting CLAUDE_CONFIG_DIR via the env parameter to redirect the config directory does not prevent loading of ~/.claude/CLAUDE.md either.
Expected Behavior
With setting_sources=["project"], only project-level CLAUDE.md (from <cwd>/.claude/CLAUDE.md) should be loaded. User-level ~/.claude/CLAUDE.md should NOT be loaded.
Environment
claude-agent-sdk(Python): 0.1.56- Claude Code CLI: 2.1.92
- OS: macOS (Darwin 25.2.0)
- Python: 3.12
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗