The Claude Code SDK lets you embed the same agentic coding engine that powers theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/harshul786/claude-code-source/llms.txt
Use this file to discover all available pages before exploring further.
claude CLI directly into your own scripts, automation pipelines, and applications. Instead of spawning a subprocess or calling the Anthropic API yourself, you import a handful of functions and get a full agent loop — file editing, bash execution, MCP tool support, session persistence, and more — within your process.
Installation
Import paths
The package exposes two import paths:| Path | Purpose |
|---|---|
@anthropic-ai/claude-code | Main SDK export — query(), session helpers, tool(), createSdkMcpServer(), and all public types. |
@anthropic-ai/claude-code/bridge | Bridge subpath — control-protocol types (SDKControlRequest, SDKControlResponse) used by SDK builders (e.g. alternative language SDKs communicating with the CLI process over stdio). |
Key exports
| Export | Type | Stability | Description |
|---|---|---|---|
query() | function | Stable | Run a single prompt or streaming multi-turn conversation. |
unstable_v2_createSession() | function | Alpha | Create a persistent multi-turn session. |
unstable_v2_resumeSession() | function | Alpha | Resume an existing session by ID. |
unstable_v2_prompt() | function | Alpha | One-shot convenience wrapper around a session. |
listSessions() | function | Stable | List sessions with metadata. |
getSessionInfo() | function | Stable | Read metadata for a single session. |
getSessionMessages() | function | Stable | Read conversation messages from a session transcript. |
renameSession() | function | Stable | Rename a session. |
tagSession() | function | Stable | Tag or untag a session. |
forkSession() | function | Stable | Fork a session into a new branch. |
tool() | function | Stable | Define a custom MCP tool for in-process use. |
createSdkMcpServer() | function | Stable | Create an in-process MCP server from a set of tools. |
AbortError | class | Stable | Thrown when a query is aborted. |
Stability notes
Functions prefixed with
unstable_v2_ are marked alpha. Their signatures may change in minor or patch releases without a major version bump. Pin your dependency to an exact version when using these APIs in production.