claude-web/node_modules/@instantlyeasy/claude-code-sdk-ts/examples/fluent-api/new-features
MerCry 0cf07bfca6 初始化提交 2026-02-23 10:23:38 +08:00
..
README.md 初始化提交 2026-02-23 10:23:38 +08:00
error-handling.js 初始化提交 2026-02-23 10:23:38 +08:00
retry-strategies.js 初始化提交 2026-02-23 10:23:38 +08:00
token-streaming-fixed.js 初始化提交 2026-02-23 10:23:38 +08:00
token-streaming.js 初始化提交 2026-02-23 10:23:38 +08:00

README.md

Advanced Features Examples

This directory contains examples demonstrating the advanced features of the Claude Code SDK.

Examples

1. Token Streaming (token-streaming.js)

Demonstrates real-time token streaming capabilities:

  • Basic token streaming
  • Pause/resume control
  • Progress indicators
  • Stream metrics

Run:

node token-streaming.js

2. Error Handling (error-handling.js)

Shows advanced error handling patterns:

  • Typed error detection
  • Retry logic for rate limits
  • Graceful degradation
  • Error logging strategies
  • Custom error handlers

Run:

node error-handling.js

3. Retry Strategies (retry-strategies.js)

Explores various retry patterns:

  • Exponential backoff
  • Linear retry
  • Fibonacci sequence retry
  • Circuit breaker pattern
  • Retry with telemetry

Run:

node retry-strategies.js

Prerequisites

Make sure you have the SDK installed:

npm install @instantlyeasy/claude-code-sdk-ts

And Claude Code CLI configured:

claude --help

Best Practices

These examples demonstrate production-ready patterns:

  1. Error Handling: Always wrap your queries in try-catch blocks and handle specific error types appropriately.

  2. Retry Logic: Use exponential backoff for transient failures and respect rate limits.

  3. Streaming: Use token streaming for better UX in interactive applications.

  4. Telemetry: Track metrics to understand your application's behavior and performance.

Additional Resources