{"id":29942908,"url":"https://github.com/ben-vargas/ai-sdk-provider-claude-code","last_synced_at":"2026-02-02T20:13:12.544Z","repository":{"id":298022266,"uuid":"998488502","full_name":"ben-vargas/ai-sdk-provider-claude-code","owner":"ben-vargas","description":"Vercel AI SDK community provider for Claude Code SDK - Use Pro/Max Subscription via SDK.","archived":false,"fork":false,"pushed_at":"2026-01-16T04:56:27.000Z","size":920,"stargazers_count":238,"open_issues_count":1,"forks_count":38,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-17T07:30:43.368Z","etag":null,"topics":["ai","ai-sdk","claude-code","claude-code-sdk"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ben-vargas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-06-08T18:02:19.000Z","updated_at":"2026-01-16T16:34:06.000Z","dependencies_parsed_at":"2026-01-09T06:02:34.916Z","dependency_job_id":null,"html_url":"https://github.com/ben-vargas/ai-sdk-provider-claude-code","commit_stats":null,"previous_names":["ben-vargas/ai-sdk-provider-claude-code"],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/ben-vargas/ai-sdk-provider-claude-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-vargas%2Fai-sdk-provider-claude-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-vargas%2Fai-sdk-provider-claude-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-vargas%2Fai-sdk-provider-claude-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-vargas%2Fai-sdk-provider-claude-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ben-vargas","download_url":"https://codeload.github.com/ben-vargas/ai-sdk-provider-claude-code/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-vargas%2Fai-sdk-provider-claude-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28557780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T00:46:33.223Z","status":"online","status_checked_at":"2026-01-19T02:00:08.049Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-sdk","claude-code","claude-code-sdk"],"created_at":"2025-08-03T02:08:04.347Z","updated_at":"2026-02-02T20:13:12.537Z","avatar_url":"https://github.com/ben-vargas.png","language":"TypeScript","funding_links":[],"categories":["SDK与开发工具"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/status-stable-00A79E\" alt=\"stable status\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/ai-sdk-provider-claude-code\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/ai-sdk-provider-claude-code?color=00A79E\" alt=\"npm version\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/ai-sdk-provider-claude-code\"\u003e\u003cimg src=\"https://img.shields.io/npm/unpacked-size/ai-sdk-provider-claude-code?color=00A79E\" alt=\"install size\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/ai-sdk-provider-claude-code\"\u003e\u003cimg src=\"https://img.shields.io/npm/dy/ai-sdk-provider-claude-code.svg?color=00A79E\" alt=\"npm downloads\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://nodejs.org/en/about/releases/\"\u003e\u003cimg src=\"https://img.shields.io/badge/node-%3E%3D18-00A79E\" alt=\"Node.js ≥ 18\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/ai-sdk-provider-claude-code\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/ai-sdk-provider-claude-code?color=00A79E\" alt=\"License: MIT\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# AI SDK Provider for Claude Code SDK\n\n\u003e **Latest Release**: Version 3.x supports AI SDK v6 stable with the Claude Agent SDK. For AI SDK v5 support, use the `ai-sdk-v5` tag.\n\n**ai-sdk-provider-claude-code** lets you use Claude via the [Vercel AI SDK](https://sdk.vercel.ai/docs) through the official `@anthropic-ai/claude-agent-sdk` and the Claude Code CLI.\n\n## Version Compatibility\n\n| Provider Version | AI SDK Version | Underlying SDK                       | NPM Tag              | Status | Branch                                                                                  |\n| ---------------- | -------------- | ------------------------------------ | -------------------- | ------ | --------------------------------------------------------------------------------------- |\n| 3.x.x            | v6             | `@anthropic-ai/claude-agent-sdk`     | `latest`             | Stable | `main`                                                                                  |\n| 2.x.x            | v5             | `@anthropic-ai/claude-agent-sdk`     | `ai-sdk-v5`          | Stable | [`ai-sdk-v5`](https://github.com/ben-vargas/ai-sdk-provider-claude-code/tree/ai-sdk-v5) |\n| 1.x.x            | v5             | `@anthropic-ai/claude-code` (legacy) | `v1-claude-code-sdk` | Legacy | [`v1`](https://github.com/ben-vargas/ai-sdk-provider-claude-code/tree/v1)               |\n| 0.x.x            | v4             | `@anthropic-ai/claude-code` (legacy) | `ai-sdk-v4`          | Legacy | [`ai-sdk-v4`](https://github.com/ben-vargas/ai-sdk-provider-claude-code/tree/ai-sdk-v4) |\n\n### Installing the Right Version\n\n**For AI SDK v6 (recommended):**\n\n```bash\nnpm install ai-sdk-provider-claude-code ai@^6.0.0\n# or explicitly: npm install ai-sdk-provider-claude-code@latest\n```\n\n**For AI SDK v5:**\n\n```bash\nnpm install ai-sdk-provider-claude-code@ai-sdk-v5 ai@^5.0.0\n```\n\n**For AI SDK v4 (legacy):**\n\n```bash\nnpm install ai-sdk-provider-claude-code@ai-sdk-v4 ai@^4.3.16\n# or use specific version: npm install ai-sdk-provider-claude-code@^0.2.2\n```\n\n## Zod Compatibility\n\n**Starting from v3.2.0, this package requires Zod 4.**\n\n```bash\nnpm install ai-sdk-provider-claude-code ai zod@^4.0.0\n```\n\n\u003e **Note:** Zod 3 support was dropped in v3.2.0 due to the underlying `@anthropic-ai/claude-agent-sdk@0.2.x` requiring Zod 4. If you need Zod 3 support, use `ai-sdk-provider-claude-code@3.1.x`.\n\n## Installation\n\n### 1. Install and authenticate the CLI\n\n```bash\nnpm install -g @anthropic-ai/claude-code\nclaude login\n```\n\n### 2. Add the provider\n\n```bash\n# For AI SDK v6 (recommended)\nnpm install ai-sdk-provider-claude-code ai@^6.0.0\n\n# For AI SDK v5\nnpm install ai-sdk-provider-claude-code@ai-sdk-v5 ai@^5.0.0\n\n# For AI SDK v4 (legacy)\nnpm install ai-sdk-provider-claude-code@ai-sdk-v4 ai@^4.3.16\n```\n\n## Disclaimer\n\n**This is an unofficial community provider** and is not affiliated with or endorsed by Anthropic or Vercel. By using this provider:\n\n- You understand that your data will be sent to Anthropic's servers through the Claude Code SDK\n- You agree to comply with [Anthropic's Terms of Service](https://www.anthropic.com/legal/consumer-terms)\n- You acknowledge this software is provided \"as is\" without warranties of any kind\n\nPlease ensure you have appropriate permissions and comply with all applicable terms when using this provider.\n\n## Quick Start\n\n### AI SDK v6\n\n```typescript\nimport { streamText } from 'ai';\nimport { claudeCode } from 'ai-sdk-provider-claude-code';\n\nconst result = streamText({\n  model: claudeCode('haiku'),\n  prompt: 'Hello, Claude!',\n});\n\nconst text = await result.text;\nconsole.log(text);\n```\n\n### AI SDK v5\n\n```typescript\n// npm install ai-sdk-provider-claude-code@ai-sdk-v5 ai@^5.0.0\nimport { streamText } from 'ai';\nimport { claudeCode } from 'ai-sdk-provider-claude-code';\n\nconst result = streamText({\n  model: claudeCode('haiku'),\n  prompt: 'Hello, Claude!',\n});\n\nconst text = await result.text;\nconsole.log(text);\n```\n\n## Breaking Changes\n\n### Version 3.0.0 (AI SDK v6 Stable)\n\nThis version upgrades to AI SDK v6 stable with updated provider types:\n\n- **`usage.raw`** now contains raw provider usage (previously in `providerMetadata['claude-code'].rawUsage`)\n- Internal type changes for `LanguageModelV3Usage` and `LanguageModelV3FinishReason` (transparent to most users)\n\n### Version 2.0.0 (Claude Agent SDK Migration)\n\nThis version migrates to `@anthropic-ai/claude-agent-sdk` with **new defaults for better control**:\n\n- **System prompt** is no longer applied by default\n- **Filesystem settings** (CLAUDE.md, settings.json) are no longer loaded by default\n- See [Migrating to Claude Agent SDK](#migrating-to-claude-agent-sdk) section below for migration details\n\n### Version 1.x (AI SDK v5)\n\nSee [Breaking Changes Guide](docs/ai-sdk-v5/V5_BREAKING_CHANGES.md) for details on migrating from v0.x to v1.x.\n\nKey changes:\n\n- Requires AI SDK v5\n- New streaming API pattern\n- Updated token usage properties\n- Changed message types\n\n## Models\n\n- **`opus`** - Claude Opus (most capable)\n- **`sonnet`** - Claude Sonnet (balanced performance)\n- **`haiku`** - Claude Haiku (fastest, most cost-effective)\n\nYou can also use full model identifiers directly (e.g., `claude-opus-4-5`, `claude-sonnet-4-5-20250514`).\n\n## Documentation\n\n- **[Usage Guide](docs/ai-sdk-v5/GUIDE.md)** - Comprehensive examples and configuration\n- **[Breaking Changes](docs/ai-sdk-v5/V5_BREAKING_CHANGES.md)** - v0.x to v1.x migration guide\n- **[Troubleshooting](docs/ai-sdk-v5/TROUBLESHOOTING.md)** - Common issues and solutions\n- **[Examples](examples/)** - Sample scripts and patterns\n- **[Tool Streaming Support](docs/ai-sdk-v5/TOOL_STREAMING_SUPPORT.md)** - Event semantics and performance notes\n\n## Migrating to Claude Agent SDK (v2.0.0)\n\n**Version 2.0.0** migrates from `@anthropic-ai/claude-code` to `@anthropic-ai/claude-agent-sdk`. Two defaults changed:\n\n- System prompt is no longer applied by default.\n- Filesystem settings (CLAUDE.md, settings.json) are not loaded by default.\n\nRestore old behavior explicitly:\n\n```ts\nimport { claudeCode } from 'ai-sdk-provider-claude-code';\n\nconst model = claudeCode('sonnet', {\n  systemPrompt: { type: 'preset', preset: 'claude_code' },\n  settingSources: ['user', 'project', 'local'],\n});\n```\n\nCLAUDE.md requires:\n\n- `systemPrompt: { type: 'preset', preset: 'claude_code' }`\n- `settingSources` includes `'project'`\n\nNew recommended behavior (explicit config):\n\n```ts\nconst model = claudeCode('sonnet', {\n  systemPrompt: 'You are a helpful assistant specialized in ...',\n  settingSources: ['project'], // or omit for no filesystem settings\n});\n```\n\nCLI install and auth are unchanged:\n\n```bash\nnpm install -g @anthropic-ai/claude-code\nclaude login\n```\n\n### Migrating from v1.x to v2.0.0\n\nIf you're upgrading from version 1.x:\n\n1. **Update the package**: `npm install ai-sdk-provider-claude-code@latest`\n2. **If you relied on default system prompt or CLAUDE.md**, add explicit configuration:\n   ```ts\n   const model = claudeCode('sonnet', {\n     systemPrompt: { type: 'preset', preset: 'claude_code' },\n     settingSources: ['user', 'project', 'local'],\n   });\n   ```\n3. **If you never used CLAUDE.md or custom system prompts**, no changes needed - v2.0.0 works the same for you.\n\n**Benefits of v2.0.0**:\n\n- Predictable behavior across environments (no hidden filesystem settings)\n- Better suited for CI/CD and multi-tenant applications\n- Explicit configuration over implicit defaults\n- Future-proof alignment with Claude Agent SDK design\n\n## Structured Outputs\n\nThis provider supports **native structured outputs** via the Claude Agent SDK (v0.1.45+). When using `generateObject()` or `streamObject()`, the SDK returns schema-compliant JSON for **supported** JSON Schema features via constrained decoding.\n\n```typescript\nimport { generateObject } from 'ai';\nimport { claudeCode } from 'ai-sdk-provider-claude-code';\nimport { z } from 'zod';\n\nconst result = await generateObject({\n  model: claudeCode('sonnet'),\n  schema: z.object({\n    name: z.string(),\n    age: z.number(),\n    email: z.string().describe('Email address (validate client-side)'),\n  }),\n  prompt: 'Generate a user profile for a software developer',\n});\n\nconsole.log(result.object); // Matches the schema above\n// { name: \"Alex Chen\", age: 28, email: \"alex@example.com\" }\n```\n\n**Benefits:**\n\n- ✅ **Schema compliance (supported features)** - Constrained decoding ensures valid output\n- ✅ **No JSON parsing errors** - SDK handles all validation\n- ✅ **No prompt engineering** - Schema enforcement is native to the SDK\n- ✅ **Better performance** - No retry/extraction logic needed\n\n\u003e **Note:** A schema is required for JSON output. Using `responseFormat: { type: 'json' }` without a schema is not supported by Claude Code (matching Anthropic's official provider behavior). An `unsupported-setting` warning will be emitted and the call will be treated as plain text.\n\u003e\n\u003e **Current CLI limitation:** Some JSON Schema features can cause the Claude Code CLI to silently fall back to prose (no `structured_output`). This includes `format` constraints (e.g., `email`, `uri`) and complex regex patterns (lookaheads/backreferences). Workaround: keep the generation schema simple, then validate with a stricter schema client-side. See `examples/structured-output-repro.ts` and `examples/limitations.ts`.\n\n## Core Features\n\n- 🚀 Vercel AI SDK compatibility\n- 🔄 Streaming support\n- 💬 Multi-turn conversations\n- 🎯 Native structured outputs with schema compliance for supported features\n- 🛑 AbortSignal support\n- 🔧 Tool management (MCP servers, permissions)\n- 🧩 Callbacks (hooks, canUseTool)\n\n## Agent SDK Options (Advanced)\n\nThis provider exposes Agent SDK options directly. Key options include:\n\n| Option                            | Description                                                                                               |\n| --------------------------------- | --------------------------------------------------------------------------------------------------------- |\n| `betas`                           | Enable beta features (e.g., `['context-1m-2025-08-07']`)                                                  |\n| `sandbox`                         | Configure sandbox behavior (`{ enabled: true }`)                                                          |\n| `plugins`                         | Load custom plugins from local paths                                                                      |\n| `resumeSessionAt`                 | Resume session at a specific message UUID                                                                 |\n| `enableFileCheckpointing`         | Enable file rewind support                                                                                |\n| `maxBudgetUsd`                    | Maximum budget in USD for the query                                                                       |\n| `tools`                           | Tool configuration (array of names or preset)                                                             |\n| `allowDangerouslySkipPermissions` | Allow bypassing permissions                                                                               |\n| `persistSession`                  | When `false`, disables session persistence to disk (v3.2.0+)                                              |\n| `spawnClaudeCodeProcess`          | Custom process spawner for VMs/containers (v3.2.0+)                                                       |\n| `permissionMode`                  | Permission mode: `'default'`, `'acceptEdits'`, `'bypassPermissions'`, `'plan'`, `'delegate'`, `'dontAsk'` |\n\n**Agent definitions** (`agents`) now support additional fields (v3.2.0+):\n\n- `disallowedTools` - Tools to explicitly disallow for the agent\n- `mcpServers` - MCP servers available to the agent\n- `criticalSystemReminder_EXPERIMENTAL` - Experimental critical reminder\n\nSee [`ClaudeCodeSettings`](https://github.com/ben-vargas/ai-sdk-provider-claude-code/blob/main/src/types.ts) for the full list of supported options (e.g., `allowedTools`, `disallowedTools`, `hooks`, `canUseTool`, `env`, `settingSources`).\n\nFor options not explicitly exposed, use the `sdkOptions` escape hatch. It **overrides** explicit settings,\nbut provider-managed fields are ignored (`model`, `abortController`, `prompt`, `outputFormat`).\nIf you set `sdkOptions.resume`, it also drives the streaming prompt `session_id` so the SDK\nand prompt target the same session.\n\n```ts\nconst model = claudeCode('sonnet', {\n  betas: ['context-1m-2025-08-07'],\n  sandbox: { enabled: true },\n  persistSession: false, // Don't persist session to disk\n  sdkOptions: {\n    maxBudgetUsd: 1,\n    resume: 'session-abc',\n  },\n});\n```\n\n## Mid-Session Message Injection\n\nThis provider supports **mid-session message injection** for supervisor patterns, allowing you to interrupt, redirect, or provide feedback to an agent during execution.\n\n```typescript\nimport { streamText } from 'ai';\nimport { claudeCode, type MessageInjector } from 'ai-sdk-provider-claude-code';\n\nlet injector: MessageInjector | null = null;\n\nconst result = streamText({\n  model: claudeCode('haiku', {\n    streamingInput: 'always', // Required for injection\n    onStreamStart: (inj) =\u003e {\n      injector = inj;\n\n      // Example: Inject after 5 seconds\n      setTimeout(() =\u003e {\n        injector?.inject('STOP! Change of plans - do something else.');\n      }, 5000);\n    },\n  }),\n  prompt: 'Write 10 files with poems...',\n});\n\nfor await (const chunk of result.textStream) {\n  process.stdout.write(chunk);\n}\n```\n\n**Requirements:**\n\n- `streamingInput: 'always'` or `'auto'` with `canUseTool` set\n- Messages injected via `inject(content)` are delivered to the agent mid-turn\n\n**Important:** Injection works between tool calls, not during continuous text generation. Use tasks that involve tool usage (file operations, bash commands, etc.) for effective mid-turn interruption.\n\n**Use Cases:**\n\n- Stop an agent mid-task\n- Redirect to a different goal\n- Provide real-time feedback\n- Implement human-in-the-loop approval workflows\n\n**API:**\n\n- `inject(content: string, onResult?: (delivered: boolean) =\u003e void)` - Inject a user message. Optional callback reports delivery status.\n- `close()` - Signal no more messages will be injected\n\n**Delivery Tracking:**\n\n```typescript\ninjector.inject('STOP!', (delivered) =\u003e {\n  if (!delivered) {\n    // Session ended before message was delivered\n    // Handle retry via session resume, etc.\n  }\n});\n```\n\nSee [examples/message-injection.ts](examples/message-injection.ts) for complete examples including conditional injection and supervisor approval patterns.\n\n## Image Inputs (Streaming Only)\n\n- Enable streaming input (`streamingInput: 'always'` or provide `canUseTool`) before sending images.\n- Supported payloads: data URLs (`data:image/png;base64,...`), strings prefixed with `base64:\u003cmediaType\u003e,\u003cdata\u003e`, or objects `{ data: '\u003cbase64\u003e', mimeType: 'image/png' }`.\n- Remote HTTP(S) image URLs are ignored with the warning \"Image URLs are not supported by this provider; supply base64/data URLs.\" (`supportsImageUrls` remains `false`).\n- When streaming input is disabled, image parts trigger the streaming prerequisite warning and are omitted from the request.\n- Use realistic image payloads—very small placeholders may result in the model asking for a different image.\n- `examples/images.ts` accepts a local image path and converts it to a data URL on the fly: `npx tsx examples/images.ts /absolute/path/to/image.png`.\n\n## Skills Support\n\nClaude Code supports **Skills** - custom tools and capabilities defined in your user or project settings. To enable skills, configure both `settingSources` and `allowedTools`:\n\n```typescript\nimport { claudeCode } from 'ai-sdk-provider-claude-code';\nimport { streamText } from 'ai';\n\nconst result = await streamText({\n  model: claudeCode('sonnet', {\n    settingSources: ['user', 'project'],\n    allowedTools: ['Skill', 'Read', 'Write', 'Bash'],\n  }),\n  prompt: 'Use my /custom-skill to help with this task',\n});\n```\n\n**Requirements:**\n\n- `settingSources` - Where to load skills from (`'user'`, `'project'`, `'local'`)\n- `allowedTools` must include `'Skill'` to invoke skills\n\n**Where to define Skills:**\n\n- User: `~/.claude/skills/your-skill/SKILL.md`\n- Project: `.claude/skills/your-skill/SKILL.md`\n\n**Validation:** If you add `'Skill'` to `allowedTools` but forget to set `settingSources`, a validation warning will alert you that skills won't load.\n\nSee [examples/skills-management.ts](examples/skills-management.ts) for more examples.\n\n## Limitations\n\n- Requires Node.js ≥ 18\n- Image inputs require streaming mode with base64/data URLs (remote fetch is not supported)\n- Some AI SDK parameters unsupported (temperature, maxTokens, etc.)\n- `canUseTool` requires streaming input at the SDK level (AsyncIterable prompt). This provider supports it via `streamingInput`: use `'auto'` (default when `canUseTool` is set) or `'always'`. See GUIDE for details.\n\n## Tool Error Parity (Streaming)\n\n- In addition to `tool-call` and `tool-result`, this provider emits a distinct `tool-error` stream event when a tool execution fails.\n- For parity with other tool events, `tool-error` includes `providerExecuted: true` and `providerMetadata['claude-code']` (e.g., `rawError`). These fields are documented extensions; downstream consumers may safely ignore them if unused.\n- See Tool Streaming Support for full event list, ordering guarantees, and performance considerations.\n\n## Content Block Streaming\n\nThis provider handles Anthropic `content_block_*` stream events directly for more responsive UIs:\n\n- **Tool input streaming** — `tool-input-delta` streams arguments incrementally; `tool-call` emits when the tool input block completes (before results), enabling “running” state in UIs.\n- **Text streaming** — `text-start/delta/end` emitted from content blocks with proper lifecycle management.\n- **Extended thinking** — `reasoning-start/delta/end` emitted from `thinking` content blocks (availability depends on model and request).\n\nFor subagent parent/child tracking, see **Subagent Hierarchy Tracking** in this README.\n\n## Subagent Hierarchy Tracking\n\nWhen Claude Code spawns subagents via the `Task` tool, this provider exposes parent-child relationships through `providerMetadata`:\n\n```ts\n// Available on tool-input-start, tool-call, tool-result, and tool-error events\nproviderMetadata['claude-code'].parentToolCallId: string | null;\n```\n\n- Task tools: Always null (top-level)\n- Child tools: Reference their parent Task's ID\n- Parallel Tasks: Child returns null if parent is ambiguous\n\nThis enables UIs to build hierarchical views of nested agent execution.\n\n## Contributing\n\nWe welcome contributions, especially:\n\n- Code structure improvements\n- Performance optimizations\n- Better error handling\n- Additional examples\n\nSee [Contributing Guidelines](docs/ai-sdk-v5/GUIDE.md#contributing) for details.\n\nFor development status and technical details, see [Development Status](docs/ai-sdk-v5/DEVELOPMENT-STATUS.md).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fben-vargas%2Fai-sdk-provider-claude-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fben-vargas%2Fai-sdk-provider-claude-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fben-vargas%2Fai-sdk-provider-claude-code/lists"}