Fluent, chainable TypeScript SDK: configure models, enable tools, stream events, then fetch text, JSON, run details or token stats in one call via .asText() or .allowTools('Read', 'Write'). Multi-level logging plus live onMessage/onToolUse callbacks give deep, CLI-compatible observability.
# Add to your Claude Code skills
git clone https://github.com/instantlyeasy/claude-code-sdk-tsUnofficial TypeScript SDK for Claude Code - the powerful CLI tool for interacting with Claude.
✨ What's New in v0.3.3:
Note: For the classic async generator API, see Classic API Documentation.
npm install @instantlyeasy/claude-code-sdk-ts
# or
yarn add @instantlyeasy/claude-code-sdk-ts
# or
pnpm add @instantlyeasy/claude-code-sdk-ts
Latest Version: v0.3.3 with enhanced features and working visual streaming!
No comments yet. Be the first to share your thoughts!
Prerequisites:
npm install -g @anthropic-ai/claude-code)import { claude } from '@instantlyeasy/claude-code-sdk-ts';
// Simple query
const response = await claude()
.query('Say "Hello World!"')
.asText();
console.log(response); // "Hello World!"
This SDK delegates all authentication to the Claude CLI:
# One-time setup - login with your Claude account
claude login
The SDK does not handle authentication directly. If you see authentication errors, authenticate using the Claude CLI first.
Chain methods for clean, readable code:
const result = await claude()
.withModel('sonnet') // Choose model
.allowTools('Read', 'Write') // Configure permissions
.skipPermissions() // Auto-accept edits
.inDirectory('/path/to/project') // Set working directory
.query('Refactor this code') // Your prompt
.asText(); // Get response as text
Extract exactly what you need:
// Get plain text
const text = await claude()
.query('Explain this concept')
.asText();
// Parse JSON response
const data = await claude()
.query('Return a JSON array of files')
.asJSON<string[]>();
// Get the final result
const result = await claude()
.query('Complete this task')
.asResult();
// Analyze tool usage
const tools = a...