What it is used for
The SDK exists to embed the Claude Code agent inside an application of your own, running in a process you operate and control. The example the official documentation leads with is a bug hunting agent: it reads a codebase, finds the mistakes that make a program fail, and edits the files until the repair is finished, all without a human approving each individual step.
Beyond that example, its documented abilities cover file and code work in general: reading, writing, and editing files, running commands, searching through a project, and searching the web. The agent can also be given outside tools and data through MCP, short for Model Context Protocol, an open protocol for connecting agents to other services. That makes the SDK a fit for internal team tools, automated code maintenance, and services whose work comes as a sequence of steps.
How to use it
The starting requirements are modest: a machine with Node.js version 18.14 or newer, or Python version 3.10 or newer, an Anthropic account, and an API key set up for your program. An API key is the secret code that proves your program may use Anthropic's services and that ties usage to your billing. Once installed, both language versions already bundle the Claude Code program itself, so in most cases there is no separate Claude Code installation to manage.
Basic use is a single call named query. You hand it three things: the task written as a plain prompt, the tools you allow to run automatically, and the permission behaviour you want. From there you read the stream of messages that flows back while the agent works, from the opening session message, through Claude's step by step messages and every tool result, to a final result message carrying the answer text, token usage, meaning the units of text the model processed, cost, and session identity.
Practitioner level
The setting that shapes an agent most is permissions. An allowed tools list lets named tools run without asking, but it does not forbid anything else. To forbid, there is a disallowed tools list that wins over every other setting, and a permission mode that decides how much human approval is needed. Rules can also be narrowed to a single command pattern, approving only commands that begin a certain way.
Two further levers are hooks and subagents. A hook is code of your own that runs at key points in the agent's life, and it can intercept, change, or reject a tool call before the call runs. A subagent is a helper agent sent after one focused subtask, such as researching a single part of a project, while the main agent carries on with the larger job. Together they make long running agents easier to steer and to watch.
Expert level
At the advanced level, what you tune is the loop itself. One full pass, from Claude responding to the tool results coming back, is called a turn. The documentation offers a maximum turn count and a maximum budget in dollars, and when either is passed the loop stops and the result message reports that a limit ended the run. There is also an effort setting, which controls how deeply Claude reasons on each turn, from low for simple file lookups to maximum for involved multi step problems.
A session is the thread of conversation that keeps context between exchanges, and the documentation says a session can be resumed later or forked into a new branch. Skills, meaning stored reusable working procedures, along with commands and project memory, load automatically from the .claude folder in a project and from the user folder, exactly as in Claude Code. For work beyond the built in tools, a program can add tools of its own and connect MCP servers, programs that offer tools and data over the MCP protocol described earlier.
Limits and risks
The plainest limit is that the loop has no built in stopping point of its own. With no turn limit and no budget limit set, the agent runs until Claude finishes by itself, and the documentation warns that open ended tasks can run for a long time. A budget does not stop exactly at the figure you set either: the response that reaches the cap still completes and its cost still counts, so spending can pass the cap by the cost of that one response.
The second risk follows from the power handed to the agent. This agent can run commands and edit files on your machine, so permissions set too loosely mean a misdirected program could change or delete something important before anyone reviews it. The third risk is legal and commercial: using this SDK is governed by Anthropic's Commercial Terms of Service, including when it powers services for your own customers, so read those terms before building it into a product.
