Skip to main content
skill CX Codex

ai-sdk-6 — Claude Code skill: Vercel AI SDK v6 development

ai-sdk-6 — a skill for projects already on Vercel AI SDK v6. Covers building agents, chatbots, tool integrations, streaming responses and structured output with patterns specific to the v6 API.

MIT 218 installs ★ 74 updated 2026-10-18

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add laguagu/claude-code-nextjs-skills --skill ai-sdk-6 -a claude-code
Open on GitHub

What ai-sdk-6 does

This skill teaches your agent the boundaries and patterns of AI SDK v6. It spans ToolLoopAgent, useChat, generateText, streamText, tool approval, MCP integration and output shapes. Explains when system replaces instructions, how loop limits work via stopWhen: stepCountIs(...) and why convertToModelMessages is async.

Includes a complete chat route handler with message validation, tools and UI streaming, plus a React client using useChat with a DefaultChatTransport. Tested on [email protected], @ai-sdk/[email protected], Zod and React 19.

If the codebase is already on ai@7 or the version is unknown, reach for ai-sdk-7 or ai-sdk instead. Using this skill on v7 code will give you outdated patterns—check package.json first.

What it helps with

  • decide between system and instructions for text functions
  • configure agent loop with step limits
  • add typed tools to a stream
  • build a chat with message state and transport
  • migrate logic from v5 or earlier to v6

Example prompts for the agent

  • How do I set ToolLoopAgent to stop at 10 steps instead of 20?
  • Show me a useChat example with DefaultChatTransport for my backend
  • How do I add tool approval to a streamText call?

How to install ai-sdk-6

1Skills CLI (Vercel)

npx skills add laguagu/claude-code-nextjs-skills --skill ai-sdk-6 -a claude-code

2Manually: put the files in place

~/.claude/skills/ai-sdk-6/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/ai-sdk-6/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about ai-sdk-6

How do I install ai-sdk-6 in Claude Code?

Run npx skills add laguagu/claude-code-nextjs-skills --skill ai-sdk-6 -a claude-code, then open ~/.claude/skills/ai-sdk-6/SKILL.md.

What does ai-sdk-6 do?

It provides your agent with knowledge of Vercel AI SDK v6 patterns: component structure, tools, message types and key differences from v5 and v7.

My project is on ai@7. Should I use this?

No, use ai-sdk-7 instead. This skill is for ai@6 only; v7 changed system to instructions, stepCountIs to isStepCount and response methods.

Source text

SKILL.md · MIT
---
name: ai-sdk-6
description: Vercel AI SDK v6 development, for projects already on ai@6. Use when building or maintaining AI agents, chatbots, tool integrations, streaming apps, or structured output in a v6 codebase. New projects and ai@7 code use ai-sdk-7; an unknown version goes through ai-sdk. Covers ToolLoopAgent, useChat, generateText, streamText, tool approval, provider tools, MCP integration, and Output patterns.
---

# AI SDK 6 maintenance

Apply this skill only to `ai@6` projects. Resolve compatible provider and UI
packages from the existing manifest/lockfile. Use `ai-sdk` when the major is
unknown and `ai-sdk-7` for an authorized upgrade.

Read the resolved `ai/docs/`, provider docs and source/types for the exact minor
release. In a monorepo, resolve from the app using the dependency. Default web
docs and repository main can describe v7. `ai` bundles `docs/` from 6.0.32; the
tree mirrors the website paths (mapping in `ai-sdk`). If installed docs are
unavailable, select the `ai@<resolved-version>` tag in `vercel/ai` and read
`content/docs/`.
Feature links here use a checked [v6 documentation snapshot](https://github.com/vercel/ai/tree/ai%406.0.297/content/docs)
as a fallback; match the project's release when available. This tag selects
documentation, not an application dependency version.

## Boundaries that differ from old and new code

- Text functions use `system`; `ToolLoopAgent` uses `instructions`.
- Loop limits use `stopWhen: stepCountIs(...)`. Text functions default to one
  step (tool execution without a follow-up answer); `ToolLoopAgent` defaults
  to 20.
- `convertToModelMessages` is async; await it.
- Use text functions with `Output` for new schema output; legacy object
  functions are deprecated.
- Tools use `inputSchema`; SDK-executed approval is tool-level `needsApproval`.
  V6 does not know v7's `toolApproval`: unless a typecheck rejects it, it is
  ignored and the tool runs without approval.
- React `useChat` owns messages and stream status, not form input. Use the
  appropriate transport and UI-message response protocol.
- Core completion callbacks are `onFinish`; result `usage` is final-step usage,
  while `totalUsage` covers all steps.

Use a configured model verified for the actual provider. Typecheck and test a
multi-turn stream with relevant tool/approval/error states after integration changes.

## Core shape

Checked with `[email protected]`, `@ai-sdk/[email protected]`, `[email protected]`, React 19 and
TypeScript 5.9: `tsc --noEmit`, plus a mock-model run through one tool step and
the follow-up answer. A string model resolves through the AI Gateway. In v7,
`system`, `stepCountIs` and `result.toUIMessageStreamResponse()` become
`instructions`, `isStepCount` and
`createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream }) })`.

```ts
// app/api/chat/route.ts
import { convertToModelMessages, stepCountIs, streamText, tool, validateUIMessages,
  type InferUITools, type UIDataTypes, type UIMessage } from 'ai';
import { z } from 'zod';

const tools = {
  weather: tool({
    inputSchema: z.object({ city: z.string() }),
    execute: async ({ city }) => ({ city, celsius: 21 }),
  }),
};
export type ChatMessage = UIMessage<never, UIDataTypes, InferUITools<typeof tools>>;

export async function POST(req: Request) {
  const { messages } = await req.json();
  const uiMessages = await validateUIMessages<ChatMessage>({ messages, tools });
  const result = streamText({
    model: 'provider/model-id', // configured gateway ID, or a provider instance
    system: 'Answer briefly.',
    messages: await convertToModelMessages(uiMessages),
    tools,
    stopWhen: stepCountIs(5),
  });
  return result.toUIMessageStreamResponse();
}
```

```tsx
// app/page.tsx
'use client';
import { useChat } from '@ai-sdk/react';
import { DefaultChatTransport } from 'ai';
import type { ChatMessage } from './api/chat/route';

const transport = new DefaultChatTransport<ChatMessage>({ api: '/api/chat' });

export default function Chat() {
  const { messages, sendMessage, status } = useChat<ChatMessage>({ transport });
  return (
    <form action={(form) => void sendMessage({ text: String(form.get('text')) })}>
      {messages.map((m) => <div key={m.id}>{m.parts.map((part, i) =>
        part.type === 'text' ? <p key={i}>{part.text}</p>
        : part.type === 'tool-weather' && part.state === 'output-available'
          ? <p key={i}>{part.output.city}: {part.output.celsius} °C</p> : null)}</div>)}
      <input name="text" disabled={status === 'submitted' || status === 'streaming'} />
    </form>
  );
}
```

## Read for the feature

- [Agents](references/agents.md): loop limits, call options and context.
- [Core functions](references/core-functions.md): output and stream contracts.
- [Tools](references/tools.md): execution, approval and typed states.
- [UI hooks](references/ui-hooks.md): transport, restoration and stream lifetime.
- [Middleware](references/middleware.md): provider interception.
- [MCP](references/mcp.md): transport and cleanup.
- [Workflows](references/workflows.md): when a loop needs explicit orchestration.
- [Examples](references/examples.md): version-matched official implementations.

© laguagu · MIT · laguagu/claude-code-nextjs-skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set13

The whole set →
nextjs-shadcn nextjs-shadcn — a skill for Claude Code that guides Next.js and shadcn/ui development. Activates when building or refining pages, presets, layouts and design system components. CX Codex +1 861installs next-best-practices The next-best-practices Claude Code skill applies Next.js App Router practices while writing or reviewing code. It covers hydration bugs, RSC boundaries, async APIs, and data handling. CX Codex +1 286installs postgres-semantic-search The postgres-semantic-search Claude Code skill builds and tunes PostgreSQL retrieval. It covers semantic and hybrid search, evaluation, and troubleshooting weak results. CX Codex +1 227installs cache-components A skill for mastering Next.js Cache Components and Partial Prerendering in version 16.4+. Advises on the use cache directive, setting cache lifetime with cacheLife(), tagging data with cacheTag(), and invalidating via updateTag(). CX Codex +1 222installs ai-app A skill for Claude Code sets up full-stack Next.js AI applications with AI SDK and shadcn/ui. Activates when generating chatbots, agent dashboards, and custom AI tools. CX Codex +1 198installs nextjs-chatbot nextjs-chatbot guides a production web chat in Next.js: tool approval, saved conversations, rendered tool results, follow-up suggestions and an embeddable widget. CX Codex +1 161installs ai-sdk Identifies the installed Vercel AI SDK major version and routes to matching API docs. Activates when working with generateText, streamText, useChat, or tools. CX Codex +1 149installs hetzner-cloud This Claude Code skill manages Hetzner Cloud resources through the hcloud CLI. It activates for Hetzner requests, location codes, or VPS work in a project already hosted there. CX Codex +1 125installs

Project sponsors

Companies that keep this analytics open