claude-agent-sdk

Run Claude agent loops programmatically from TypeScript via the query() API.

9|5|Updated Aug 8, 2025
One-click install
npx skills add https://github.com/AnExiledDev/CodeForge --skill claude-agent-sdk-anexileddev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-agent-sdk
Source: https://github.com/AnExiledDev/CodeForge/tree/main/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/claude-agent-sdk
Command: npx skills add https://github.com/AnExiledDev/CodeForge --skill claude-agent-sdk-anexileddev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

The Claude Agent SDK exposes the Claude Code agent loop as a library, providing a single function, query(), to run prompts and options and stream a structured message sequence for full lifecycle control.

Core Features & Use Cases

  • Programmatic agent orchestration: start an agent loop, feed prompts, and receive a live stream of assistant messages and results.
  • Subagents and MCP tooling: define subagents and MCP servers to delegate tasks and integrate external tools within TypeScript projects.
  • Cloud-provider compatibility: supports Claude models across Anthropic, Bedrock, Vertex AI, and Foundry with permission controls and sandboxing.

Quick Start

Run a basic TS example that calls query() to start an agent loop and observe the streamed results.

Frequently Asked Questions about claude-agent-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I orchestrate Claude agents programmatically in TypeScript?

The SDK provides a query() function that exposes the Claude Code agent loop as a library, returning an async generator of structured messages including system, assistant, user, and result messages for programmatic orchestration.

Can I use Claude agent workflows with Bedrock or Vertex AI?

Yes, Claude agent workflows support Claude models across multiple cloud providers including Anthropic, Bedrock, Vertex AI, and Foundry, with built-in permission controls and sandbox settings.

How do I integrate MCP servers and subagents into a TypeScript project?

You can define subagents and MCP servers within the query() options to delegate tasks and integrate external tools, enabling multi-agent orchestration directly inside your TypeScript project.

What is the best way to test Claude-based agents in a TypeScript environment?

The best way to test Claude-based agents is by calling the query() API to start an agent loop and observing the streamed async generator results, optionally applying hooks and sandbox settings for controlled testing.

Does the Claude Agent SDK support permission controls and sandboxing?

Yes, the SDK supports permission controls and sandbox settings, allowing you to configure safe execution environments and manage access when running agent workflows across different cloud providers.