OptionalabortController for cancelling the query. When aborted, the query will stop and clean up resources.
OptionaladditionalAdditional directories Claude can access beyond the current working directory. Paths should be absolute.
OptionalagentAgent name for the main thread. When specified, the agent's system prompt,
tool restrictions, and model will be applied to the main conversation.
The agent must be defined either in the agents option or in settings.
This is equivalent to the --agent CLI flag.
OptionalagentEnable periodic AI-generated progress summaries for running subagents. When
true, the subagent's conversation is forked every ~30s to produce a short
present-tense description (e.g. "Analyzing authentication module"), emitted
on task_progress events via the summary field. The fork reuses the
subagent's model and prompt cache, so cost is typically minimal.
Applies to both foreground and background subagents. Defaults to false.
OptionalagentsProgrammatically define custom subagents that can be invoked via the Agent tool. Keys are agent names, values are agent definitions.
OptionalallowMust be set to true when using permissionMode: 'bypassPermissions'.
This is a safety measure to ensure intentional bypassing of permissions.
OptionalallowedList of tool names that are auto-allowed without prompting for permission.
These tools will execute automatically without asking the user for approval.
To restrict which tools are available, use the tools option instead.
OptionalbetasEnable beta features. Currently supported:
'context-1m-2025-08-07' - Enable 1M token context window (Sonnet 4/4.5 only)OptionalcanCustom permission handler for controlling tool usage. Called before each tool execution to determine if it should be allowed, denied, or prompt the user.
OptionalcontinueContinue the most recent conversation in the current directory instead of starting a new one.
Mutually exclusive with resume.
OptionalcwdCurrent working directory for the session. Defaults to process.cwd().
OptionaldebugEnable debug mode for the Claude Code process.
When true, enables verbose debug logging (equivalent to --debug CLI flag).
Debug logs are written to a file (see debugFile option) or to stderr.
You can also capture debug output via the stderr callback.
OptionaldebugWrite debug logs to a specific file path.
Implicitly enables debug mode. Equivalent to --debug-file <path> CLI flag.
OptionaldisallowedList of tool names that are disallowed. These tools will be removed from the model's context and cannot be used, even if they would otherwise be allowed.
OptionaleffortControls how much effort Claude puts into its response. Works with adaptive thinking to guide thinking depth.
'low' — Minimal thinking, fastest responses'medium' — Moderate thinking'high' — Deep reasoning (default)'max' — Maximum effort (Opus 4.6 only)OptionalenableEnable file checkpointing to track file changes during the session.
When enabled, files can be rewound to their state at any user message
using Query.rewindFiles().
File checkpointing creates backups of files before they are modified, allowing you to restore them to previous states.
OptionalenvEnvironment variables to pass to the Claude Code process.
Defaults to process.env.
SDK consumers can identify their app/library to include in the User-Agent header by setting:
CLAUDE_AGENT_SDK_CLIENT_APP - Your app/library identifier (e.g., "my-app/1.0.0", "my-library/2.1")OptionalexecutableJavaScript runtime to use for executing Claude Code. Auto-detected if not specified.
OptionalexecutableAdditional arguments to pass to the JavaScript runtime executable.
OptionalextraAdditional CLI arguments to pass to Claude Code.
Keys are argument names (without --), values are argument values.
Use null for boolean flags.
OptionalfallbackFallback model to use if the primary model fails or is unavailable.
OptionalforkWhen true, resumed sessions will fork to a new session ID rather than
continuing the previous session. Use with resume.
OptionalhooksHook callbacks for responding to various events during execution. Hooks can modify behavior, add context, or implement custom logic.
OptionalincludeInclude hook lifecycle events in the output stream.
When true, hook_started, hook_progress, and hook_response system
messages will be emitted for all hook event types (PreToolUse, PostToolUse,
Stop, etc.). SessionStart and Setup hook events are always emitted
regardless of this setting.
OptionalincludeInclude partial/streaming message events in the output.
When true, SDKPartialAssistantMessage events will be emitted during streaming.
OptionalmaxMaximum budget in USD for the query. The query will stop if this
budget is exceeded, returning an error_max_budget_usd result.
OptionalmaxMaximum number of tokens the model can use for its thinking/reasoning process. Helps control cost and latency for complex tasks.
OptionalmaxMaximum number of conversation turns before the query stops. A turn consists of a user message and assistant response.
OptionalmcpMCP (Model Context Protocol) server configurations. Keys are server names, values are server configurations.
OptionalmodelClaude model to use. Defaults to the CLI default model. Examples: 'claude-sonnet-4-6', 'claude-opus-4-6'
OptionalonCallback for handling MCP elicitation requests. Called when an MCP server requests user input (form fields, URL auth, etc.) and no hook handles the request first.
If not provided, elicitation requests that aren't handled by hooks will be declined automatically.
OptionaloutputOutput format configuration for structured responses. When specified, the agent will return structured data matching the schema.
OptionalpathPath to the Claude Code executable. Uses the built-in executable if not specified.
OptionalpermissionPermission mode for the session.
'default' - Standard permission behavior, prompts for dangerous operations'acceptEdits' - Auto-accept file edit operations'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions)'plan' - Planning mode, no execution of tools'dontAsk' - Don't prompt for permissions, deny if not pre-approvedOptionalpermissionMCP tool name to use for permission prompts. When set, permission requests will be routed through this MCP tool instead of the default handler.
OptionalpersistWhen false, disables session persistence to disk. Sessions will not be saved to ~/.claude/projects/ and cannot be resumed later. Useful for ephemeral or automated workflows where session history is not needed.
OptionalpluginsLoad plugins for this session. Plugins provide custom commands, agents, skills, and hooks that extend Claude Code's capabilities.
Currently only local plugins are supported via the 'local' type.
OptionalpromptEnable prompt suggestions. When true, the agent emits a prompt_suggestion
message after each turn with a predicted next user prompt.
Delivery semantics:
prompt_suggestion per turn; arrives after the result message.result to receive it.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false env var.OptionalresumeSession ID to resume. Loads the conversation history from the specified session.
OptionalresumeWhen resuming, only resume messages up to and including the message with this UUID.
Use with resume. This allows you to resume from a specific point in the conversation.
The message ID should be from SDKAssistantMessage.uuid.
OptionalsandboxSandbox settings for command execution isolation.
When enabled, commands are executed in a sandboxed environment that restricts filesystem and network access. This provides an additional security layer.
Important: Filesystem and network restrictions are configured via permission rules, not via these sandbox settings:
Read and Edit permission rulesWebFetch permission rulesThese sandbox settings control sandbox behavior (enabled, auto-allow, etc.), while the actual access restrictions come from your permission configuration.
Dependency check: When enabled: true is passed via this option,
failIfUnavailable defaults to true — if sandbox dependencies are missing
(e.g. bubblewrap on Linux) or the platform is unsupported, query() will
emit an error result and exit rather than silently running commands
unsandboxed. Set failIfUnavailable: false to allow graceful degradation.
OptionalsessionUse a specific session ID for the conversation instead of an auto-generated one.
Must be a valid UUID. Cannot be used with continue or resume unless
forkSession is also set (to specify a custom ID for the forked session).
OptionalsettingsAdditional settings to apply. Accepts either a path to a settings JSON file or a settings object. These are loaded into the "flag settings" layer, which has the highest priority among user-controlled settings.
Equivalent to the --settings CLI flag.
OptionalsettingControl which filesystem settings to load.
'user' - Global user settings (~/.claude/settings.json)'project' - Project settings (.claude/settings.json)'local' - Local settings (.claude/settings.local.json)When omitted or empty, no filesystem settings are loaded (SDK isolation mode).
Must include 'project' to load CLAUDE.md files.
OptionalspawnCustom function to spawn the Claude Code process. Use this to run Claude Code in VMs, containers, or remote environments.
When provided, this function is called instead of the default local spawn. The default behavior checks if the executable exists before spawning.
OptionalstderrCallback for stderr output from the Claude Code process. Useful for debugging and logging.
OptionalstrictEnforce strict validation of MCP server configurations. When true, invalid configurations will cause errors instead of warnings.
OptionalsystemSystem prompt configuration.
string - Use a custom system prompt{ type: 'preset', preset: 'claude_code' } - Use Claude Code's default system prompt{ type: 'preset', preset: 'claude_code', append: '...' } - Use default prompt with appended instructionsOptional AlphataskAPI-side task budget in tokens. When set, the model is made aware of
its remaining token budget so it can pace tool use and wrap up before
the limit. Sent as output_config.task_budget with the
task-budgets-2026-03-13 beta header.
OptionalthinkingControls Claude's thinking/reasoning behavior.
{ type: 'adaptive' } — Claude decides when and how much to think (Opus 4.6+).
This is the default for models that support it.{ type: 'enabled', budgetTokens: number } — Fixed thinking token budget (older models){ type: 'disabled' } — No extended thinkingWhen set, takes precedence over the deprecated maxThinkingTokens.
OptionaltoolPer-tool configuration for built-in tools.
OptionaltoolsSpecify the base set of available built-in tools.
string[] - Array of specific tool names (e.g., ['Bash', 'Read', 'Edit'])[] (empty array) - Disable all built-in tools{ type: 'preset'; preset: 'claude_code' } - Use all default Claude Code tools
Options for the query function. Contains callbacks and other non-serializable fields.