Text of code.claude.com › docs › en › agent-sdk › claude-code-features as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Use Claude Code features in the SDK - Claude Code Docs

Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. The Agent SDK is built on the same foundation as Claude Code, which means your SDK agents have access to the same filesystem-based features: project instructions ( CLAUDE.md and rules), skills, hooks, and more.

When you omit settingSources , query() reads the same filesystem settings as the Claude Code CLI: user, project, and local settings, CLAUDE.md files, and .claude/ skills, agents, and commands. To run without these, pass settingSources: [] , which limits the agent to what you configure programmatically. Managed policy settings and the global ~/.claude.json config are read regardless of this option. For more information, see What settingSources does not control .

Control filesystem settings with settingSources The setting sources option ( setting_sources in Python, settingSources in TypeScript) controls which filesystem-based settings the SDK loads. Pass an explicit list to opt in to specific sources, or pass an empty array to disable user, project, and local settings. This example loads both user-level and project-level settings by setting settingSources to ["user", "project"] : from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, ResultMessage import asyncio async def main (): async for message in query( prompt = "Help me refactor the auth module" , options = ClaudeAgentOptions( # "user" loads from ~/.claude/, "project" loads from ./.claude/ in cwd. # Together they give the agent access to CLAUDE.md, skills, hooks, and # permissions from both locations. setting_sources = [ "user" , "project" ], allowed_tools = [ "Read" , "Edit" , "Bash" ], ), ): if isinstance (message, AssistantMessage): for block in message.content: if hasattr (block, "text" ): print (block.text) if isinstance (message, ResultMessage) and message.subtype == "success" : print ( f " \n Result: { message.result } " ) asyncio.run(main()) import { query } from "@anthropic-ai/claude-agent-sdk" ; for await ( const message of query ({ prompt: "Help me refactor the auth module" , options: { // "user" loads from ~/.claude/, "project" loads from ./.claude/ in cwd. // Together they give the agent access to CLAUDE.md, skills, hooks, and // permissions from both locations. settingSources: [ "user" , "project" ], allowedTools: [ "Read" , "Edit" , "Bash" ] } })) { if ( message . type === "assistant" ) { for ( const block of message . message . content ) { if ( block . type === "text" ) console . log ( block . text ); } } if ( message . type === "result" && message . subtype === "success" ) { console . log ( ` \n Result: ${ message . result } ` ); } } When this runs, the assistant’s response prints to stdout, followed by a final result line once the run completes.

Each source loads settings from a specific location, where <cwd> is the working directory you pass via the cwd option, or the process’s current directory if unset. For the full type definition, see SettingSource (TypeScript) or SettingSource (Python). Source What it loads Location "project" Project settings.json and hooks; project CLAUDE.md and .claude/rules/*.md ; project skills, commands, and subagents <cwd>/.claude/ for settings.json and hooks; <cwd> and every parent directory for CLAUDE.md and rules; <cwd> and every parent directory up to the repository root for skills, commands, and subagents, plus the .claude/skills/ , .claude/commands/ , and .claude/agents/ folders of each directory you pass through the additionalDirectories or add_dirs option, which the SDK passes to Claude Code as --add-dir "user" User settings.json ; user CLAUDE.md and ~/.claude/rules/*.md ; user skills, commands, and subagents ~/.claude/ for settings.json , CLAUDE.md, and rules; ~/.claude/skills/ , ~/.claude/commands/ , and ~/.claude/agents/ for skills, commands, and subagents "local" CLAUDE.local.md, .claude/settings.local.json <cwd>/.claude/ for settings.local.json , which can also load from the repository’s root when <cwd> is inside a git repository; <cwd> and every parent directory for CLAUDE.local.md Omitting settingSources is equivalent to ["user", "project", "local"] .

The cwd option determines where the SDK looks for project-level inputs. Project settings.json loads from <cwd>/.claude/ with no parent-directory fallback. What settingSources does not control settingSources covers user, project, and local settings. A few inputs are read regardless of its value: Input Behavior To disable Managed policy settings Endpoint-managed policy, such as an MDM plist, registry policy, or managed settings file, loads from the host.

Server-managed settings are fetched on an eligible configuration when the session authenticates with a qualifying credential, such as an organization OAuth login, a directly configured API key, or a user_oauth Anthropic profile Endpoint policy: remove the managed settings file, plist, or registry policy from the host. Server-managed settings: an Owner in your Claude organization controls them; you can’t disable them from the SDK ~/.claude.json global config Always read Relocate with CLAUDE_CONFIG_DIR in env Auto memory at ~/.claude/projects/<project>/memory/ Loaded into the system prompt at session start.

The agent writes new memories there with the standard Write and Edit tools rather than a dedicated memory tool, so those tools must be enabled for the agent to save memories Set autoMemoryEnabled: false in settings, or CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 in env claude.ai MCP connectors Loaded when the session authenticates with your claude.ai login. Not loaded when CLAUDE_CODE_OAUTH_TOKEN holds a token from claude setup-token , which can only make model requests.

Passing mcpServers: {} does not suppress the connectors Set strictMcpConfig: true , disableClaudeAiConnectors: true in settings, or ENABLE_CLAUDEAI_MCP_SERVERS=false in env sandbox.credentials deny entries and file mask entries in ~/.claude/settings.json When the command sandbox runs, Claude Code applies the deny entries and keeps the credentials.files mask entries as restrictions even when settingSources excludes user settings.

Claude Code uses these entries only to narrow what sandboxed commands can access Remove the entries from ~/.claude/settings.json Do not rely on default query() options for multi-tenant isolation. Because the inputs above are read regardless of settingSources , an SDK process can pick up host-level configuration and per-directory memory. For multi-tenant deployments, run each tenant in its own filesystem and set settingSources: [] plus CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 in env .

Server-managed settings are fetched when the process authenticates with an organization credential; filesystem isolation does not remove them. See Secure deployment . Project instructions (CLAUDE.md and rules) CLAUDE.md files and .claude/rules/*.md files give your agent persistent context about your project: coding conventions, build commands, architecture decisions, and instructions. When settingSources includes "project" , as in the settingSources example , the SDK loads these files into context at session start.

The agent then follows your project conventions without you repeating them in every prompt. CLAUDE.md load locations Level Location When loaded Project (root) <cwd>/CLAUDE.md or <cwd>/.claude/CLAUDE.md settingSources includes "project" Project rules <cwd>/.claude/rules/*.md and .claude/rules/*.md in every parent directory settingSources includes "project" Project (parent dirs) CLAUDE.md files in directories above cwd settingSources includes "project" , loaded at session start Project (child dirs) CLAUDE.md files in subdirectories of cwd settingSources includes "project" , loaded on demand Local <cwd>/CLAUDE.local.md and CLAUDE.local.md in every parent directory settingSources includes "local" User ~/.cla

The rest of this page is on the live site.