Register and share your invite link to earn from video plays and referrals.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
Joined May 2026
279 Following    408 Followers
# Useful but Little-Known Features of Claude Agent SDK ๐ŸŒ Control exactly which filesystem settings your SDK agent loads with the setting_sources option. Selectively enable CLAUDE.md, skills, hooks, and settings.json โ€” or disable them all for multi-tenant isolation. ๐Ÿ“Œ Title: Selective Settings Loading with setting_sources ๐Ÿ”— URL: ๐Ÿงฉ Overview The `setting_sources` option (TypeScript: `settingSources`) controls which filesystem-based settings the SDK loads. There are three sources: `"project"` loads settings.json, hooks, CLAUDE.md, and skills from `/.claude/`; `"user"` loads user-level settings from `~/.claude/`; `"local"` loads `.claude/settings.local.json` and `CLAUDE.local.md`. Omitting the option defaults to all three (`["user", "project", "local"]`). Passing an empty array `[]` disables all filesystem settings. Managed policies and `~/.claude.json` are always loaded regardless. ๐Ÿ›  Usage Pass a list to `setting_sources` to enable only the sources you need. ```python from claude_agent_sdk import query, ClaudeAgentOptions # Load project and user settings async for message in query( prompt="Help me refactor the auth module", options=ClaudeAgentOptions( setting_sources=["user", "project"], # Enable CLAUDE.md, skills, hooks allowed_tools=["Read", "Edit", "Bash"], ), ): pass # Disable all filesystem settings (programmatic config only) async for message in query( prompt="Analyze this code", options=ClaudeAgentOptions( setting_sources=[], # No filesystem settings loaded ), ): pass ``` ๐Ÿ— Integration into Production Systems - For multi-tenant environments, combine `setting_sources=[]` with `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` to prevent settings leakage between tenants - CLAUDE.md requires `"project"` in setting_sources to load โ€” it won't load without it - Each source loads from specific locations: - `"project"`: `/.claude/` for settings.json and hooks; `` and parent dirs for CLAUDE.md and rules - `"user"`: `~/.claude/` for user settings, CLAUDE.md, and rules - `"local"`: `/.claude/settings.local.json` and parent dirs for CLAUDE.local.md ๐Ÿ’ก Use Cases ๐Ÿ”’ Secure multi-tenant: run each tenant in isolated filesystem with `setting_sources=[]` to block cross-tenant config ๐Ÿ— CI/CD pipelines: enable only `"project"` to load repo-specific CLAUDE.md and skills ๐Ÿ‘ค Developer customization: include `"user"` to allow personal `~/.claude/CLAUDE.md` preferences โš ๏ธ Caveats - Some inputs are not controlled by setting_sources: managed policies, `~/.claude.json`, auto memory (`~/.claude/projects/`), MCP connectors - To disable auto memory, set `autoMemoryEnabled: false` in settings or `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` in env - When you set setting_sources explicitly, all three defaults are disabled โ€” list every source you need โœจ Proper setting_sources configuration gives you precise control over agent settings, enabling safe and predictable behavior across environments. #ClaudeAgentSDK# #AIAgent#
Show more