Skip to main content
Use the Agent SDK to build an AI agent that reads your code, finds bugs, and fixes them, all without manual intervention. What you’ll do:
  1. Set up a project with the Agent SDK
  2. Create a file with some buggy code
  3. Run an agent that finds and fixes the bugs automatically

Prerequisites

  • Node.js 18+ or Python 3.10+
  • An Anthropic account. If you don’t have one, sign up here.

Setup

1

Create a project folder

Create a new directory for this quickstart:
For your own projects, you can run the SDK from any folder; it will have access to files in that directory and its subdirectories by default.
2

Install the SDK

Install the Agent SDK package for your language:
Setting "type": "module" in package.json lets your agent script use top-level await, and tsx runs TypeScript files directly. npm prints added N packages when the install succeeds.
Both the TypeScript and Python SDKs bundle a native Claude Code binary, so most installs need no separate Claude Code install. Some installs have no bundled binary:
  • If pip installs the Python SDK’s source distribution instead of a platform wheel, for example on ARM64 Windows, no binary is bundled. Install Claude Code natively. The Python SDK finds it on your PATH.
  • The TypeScript SDK installs its binary through npm optional dependencies, so an install that skips them, for example npm ci --omit=optional, gets no binary even on a supported platform. Reinstall without skipping optional dependencies, or install Claude Code natively and set pathToClaudeCodeExecutable to its path.
3

Set your API key

Get an API key from the Claude Console, then set it as an environment variable in the shell where you’ll run your agent:
The SDK reads the key from the environment of the process that runs your agent; it doesn’t load .env files automatically. If you keep the key in a .env file, load it yourself, for example with the dotenv package, before calling the SDK.The SDK also supports authentication via third-party API providers:
  • Amazon Bedrock: set CLAUDE_CODE_USE_BEDROCK=1 environment variable and configure AWS credentials
  • Claude Platform on AWS: set CLAUDE_CODE_USE_ANTHROPIC_AWS=1 and ANTHROPIC_AWS_WORKSPACE_ID, then configure AWS credentials
  • Google Cloud’s Agent Platform: set CLAUDE_CODE_USE_VERTEX=1 environment variable and configure Google Cloud credentials
  • Microsoft Foundry: set CLAUDE_CODE_USE_FOUNDRY=1 environment variable and configure Azure credentials
See the setup guides for Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, or Microsoft Foundry for details.
U