/nextjs-ai-skills:ai-sdk-7from nextjs-ai-skills
Provides implementation guidance and migration support for Vercel AI SDK v7, covering ToolLoopAgent, WorkflowAgent, HarnessAgent, telemetry, reasoning, and breaking changes from v6. Useful when building or upgrading AI SDK 7 apps.
Ships in nextjs-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Apply this skill to ai@7; use ai-sdk to resolve unknown versions and
for v6 maintenance. Match provider and UI package versions to the
project. AI SDK 7 requires Node.js 22+ and AI SDK packages are ESM-only.
Read the resolved ai/docs/, provider docs and installed source/types first;
each ai-sdk.dev/docs/... link in this skill has an offline copy under ai/docs/
(path mapping in ai-sdk). Harness, WorkflowAgent and migration guides live
in ai/docs/03-ai-sdk-harnesses/, 03-agents/07-workflow-agent.mdx and
08-migration-guides/23-migration-guide-7-0.mdx; the companion packages ship
only types. Use official docs or the matching
repository tag when local docs are unavailable. Experimental package APIs need
a fresh check before adding long-lived wrappers.
| Need | Entry point |
|---|---|
| In-memory agent loop | ToolLoopAgent from ai |
| Durable agent | WorkflowAgent from @ai-sdk/workflow + workflow 5 |
| Claude Code/Codex/Pi runtime | HarnessAgent from @ai-sdk/harness/agent + adapter + sandbox package |
| OpenTelemetry | registerTelemetry(new OpenTelemetry()), @ai-sdk/otel |
| Stalled calls | timeout: ms or { totalMs, stepMs, firstChunkMs, chunkMs, toolMs } |
instructions; loop limits use
isStepCount. Core, agent and server UI-stream helpers use onEnd/onStepEnd
(onFinish remains a deprecated alias); client useChat/Chat keeps
onFinish.prepareStep instruction/message overrides carry forward. Results such as
usage and tool arrays aggregate all steps; finalStep preserves final-step
access, and is awaited for streams.runtimeContext for server loop state and schema-validated
toolsContext for per-tool state. Neither is model-visible merely by being
context.reasoning.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.
// app/api/chat/route.ts
import { convertToModelMessages, createUIMessageStreamResponse, isStepCount, streamText, tool,
toUIMessageStream, 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
instructions: 'Answer briefly.',
messages: await convertToModelMessages(uiMessages),
tools,
stopWhen: isStepCount(5),
});
return createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream }) });
}
// 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>
);
}
The v6 spellings (system, stepCountIs, result.toUIMessageStreamResponse())
still compile in 7.0.124; system and the response method are deprecated.
Typecheck and exercise the changed multi-turn, tool, stream or resume path. A successful compile does not prove approval policy or persistence behavior.
references/agent-execution.md (opens in a new tab)references/core-functions.md (opens in a new tab)references/examples.md (opens in a new tab)references/harnesses.md (opens in a new tab)references/media-and-files.md (opens in a new tab)references/migration-v6-to-v7.md (opens in a new tab)references/telemetry.md (opens in a new tab)references/tools.md (opens in a new tab)references/ui-hooks.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub laguagu/claude-code-nextjs-skills --plugin nextjs-ai-skills24 skills in this plugin
/agent-harness-reviewReviews an agent harness or agent design against Anthropic's agent and model prompting guidance (Opus 5.5, Fable 5.2), Cognition's context principles and 2026 research on skill routing and skill-induced failures. Covers when subagents or parallel agents pay off, how to brief them, how many skills, plugins, MCP servers and hooks load every session, tool design and proportionate verification. Use when auditing a Claude Code or Codex setup, deciding whether to add subagents or a multi-agent workflow, trimming a skill library, or designing an agent loop in an app. For writing a new skill or measuring a skill's trigger rate with evals, use skill-creator./ai-appBuilds full-stack Next.js AI applications with the AI SDK and the shadcn/ui AI Elements patterns. Use when creating a chatbot, agent dashboard or custom AI application./ai-elementsMaintains AI chat UI built from elements.ai-sdk.dev AI Elements components already copied into the project. Use when changing or debugging those components (conversations, messages, prompt inputs, attachments, reasoning, tool output, sources). New chat UI uses the shadcn/ui AI Elements patterns (`shadcn` skill)./ai-sdkAnswer questions about the AI SDK and help build AI-powered features. Use when developers ask about Vercel AI SDK, generateText, streamText, ToolLoopAgent, useChat, AI SDK providers, tools, structured output, embeddings or streaming, or want to add AI features to a TypeScript or JavaScript app. First identify the installed major version and route version-specific work: use ai-sdk-7 for AI SDK 7 features/migrations such as WorkflowAgent, HarnessAgent, reasoning, runtime/tools context, toolApproval, telemetry, realtime, or v6-to-v7 upgrades; for v6 code read the docs shipped in the installed package./ai-sdk-6Vercel 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./cache-componentsExpert guidance for Next.js Cache Components and Partial Prerendering (PPR). Use when implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, instant navigation validation, 'use cache: private', pass-through/interleaving patterns, GET Route Handler caching, debugging cache issues, and reviewing Cache Component implementations.Other plugins' skills for the same job