To make Claude work with files, run commands, or use external services, use the Claude Agent SDK to build those abilities into software. An agent is a program that uses a language model to choose and take steps toward a goal. The SDK provides the tools and controls Claude needs to do that.
Anthropic renamed the Claude Code SDK to the Claude Agent SDK as it expanded the product beyond coding. You can use it to build agents for coding, research, customer support, or personal assistance. To get started, install the Claude Code command-line tool and the SDK, then call the SDK’s query function with instructions and options.
What the SDK provides
The SDK gives Claude access to tools such as reading and editing files, along with directory search and shell commands. It also supports custom tools, connections to external services through the Model Context Protocol (MCP), and subagents that handle separate tasks in isolated context windows. A quick reference for the SDK lists query as its main entry point. Its options include choosing a model and working directory, setting a turn limit, and controlling permissions.
With the SDK, Claude can take several steps to complete a task instead of answering a single prompt. For example, a coding agent could inspect a repository, find relevant files, propose edits, and run a test command. The same approach works for research or support tasks, using different tools and limits.
The SDK also supports persistent sessions and context management. Context is the information Claude can use during a task. Managing context helps an agent continue work without keeping every earlier detail in the active conversation.
Install and make a first request
The Python setup in KDnuggets’ getting-started instructions requires the Claude Code command-line interface and the Python package. Install the CLI through npm or PowerShell, then install the package:
pip install claude-agent-sdk
You also need access to Claude through an Anthropic account or API key. The sources give different minimum Python versions, so check the package’s current installation requirements before choosing a runtime.
In your Python program, import the SDK’s query function and options class. Give query a task prompt and options for the working directory and available tools. To summarize a repository, for example, give Claude file-reading and search tools, set the repository as its working directory, and ask for a summary. Start with read-only tools. Add file editing or shell access only if the task requires it.
Option names and tool permissions depend on the package version you install. Follow that version’s documentation when writing the call, and set a turn limit to stop the agent from taking steps indefinitely. The quick reference lists options such as cwd, maxTurns, permissionMode, and tools.
Choose tools and permissions deliberately
The tools you enable define what Claude can do. File-reading tools let Claude inspect files, while editing tools let it change them. With shell access, Claude can run commands. Web search and fetch tools support tasks that need external information. MCP connections let you connect the agent to services such as GitHub or Slack, while custom tools let you expose specific actions from your own code.
Give an agent only the access its task requires. File reading and search are often enough for a code review. For automated changes, allow editing in a test directory before granting access to a larger part of the repository. Require approval for commands or changes that affect production data, credentials, or shared infrastructure. Review generated edits and command results before using them.
Check costs and package details before deployment
Programmatic agent use has different costs from ordinary interactive use. A report on SDK and claude -p metering describes a monthly credit for programmatic usage. Usage stops when the credit runs out unless the user enables additional usage billed at API rates. Check Anthropic’s current terms before estimating costs or deploying an agent at scale, because billing terms can change.
Check that the package and integrations you plan to use are still maintained. The linked Tessl quick reference covers version 0.1.0 and is archived. Use it to begin learning the API, then check the current package documentation.