Claude Agent banner
kmcclosk kmcclosk

Claude Agent

Development community

Description

A comprehensive collection of examples demonstrating the Claude Agent SDK capabilities, from basic usage to advanced control mechanisms.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Claude Agent SDK Examples

A comprehensive collection of examples demonstrating the Claude Agent SDK capabilities, from basic usage to advanced control mechanisms.

📦 Installation

npm install
npm run build  # Compile TypeScript

📚 Documentation

🎯 Examples

1. Simple Example (`src/simple-example.ts`)

A beginner-friendly introduction to the Claude Agent SDK.

**Features:**

  • Basic agent initialization
  • Message handling
  • Cost tracking
  • Token usage monitoring

**Usage:**

npm run simple
# or
npx tsx src/simple-example.ts

**What it does:** Creates a TODO list application demonstrating basic agent capabilities with limited tools (FileWrite, FileRead).


2. Interactive Agent (`src/interactive-agent.ts`)

Advanced example showing how to steer and intervene in agent execution.

**Features:**

  • Bidirectional streaming communication - Send messages during execution
  • Real-time control methods - interrupt(), changeModel(), setPermissionMode()
  • Dynamic permissions - Runtime permission management
  • Hook system - Intervention points for monitoring and control
  • AbortController - External cancellation
  • Interactive CLI - Command-line interface for control

**Usage:**

# Run automated demonstration
npm run interactive:demo
# or
npx tsx src/interactive-agent.ts demo

# Run interactive CLI
npm run interactive:cli
# or
npx tsx src/interactive-agent.ts cli

**CLI Commands:**

  • /msg - Send message to agent
  • /model - Change model (opus/sonnet/haiku)
  • /perm - Toggle permission (writes/reads/commands)
  • /interrupt - Interrupt current execution
  • /pause - Pause execution
  • /resume - Resume execution
  • /history - Show execution history
  • /stop - Stop and exit

3. Example Agent (`src/example-a