From laguagu-claude-code-nextjs-skills
Develops and migrates Vercel AI SDK v7 apps, covering agent architectures, telemetry, tool approval, and v6-to-v7 breaking changes.
How this skill is triggered — by the user, by Claude, or both
Slash command
/laguagu-claude-code-nextjs-skills:ai-sdk-7 [question or feature][question or feature]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use this skill for AI SDK 7-specific implementation, migrations, and agent
Use this skill for AI SDK 7-specific implementation, migrations, and agent
architecture. For AI SDK 6 projects, use ai-sdk-6. For unknown versions, use
ai-sdk first to inspect node_modules/ai/package.json and local docs.
package.json, lockfiles, and node_modules/ai/package.json.ai major version is 7 before applying this guide.node_modules/ai/docs/ and node_modules/ai/src/.apps/*/node_modules/ai/
and packages/*/node_modules/ai/.ai-sdk.dev or the
Vercel AI repository docs source before coding.AI SDK 7 requires Node.js >=22 and AI SDK packages are ESM-only. Convert
require() imports to import syntax before chasing downstream type errors.
Use the project's package manager and install only packages needed by the task:
bun add ai @ai-sdk/react
bun add @ai-sdk/openai # or the provider already used by the project
For durable agents, add @ai-sdk/workflow and workflow. For harness agents,
add @ai-sdk/harness, one harness adapter, and a sandbox provider.
| Task | Prefer in AI SDK 7 |
|---|---|
| Text generation | generateText / streamText |
| System prompt | top-level instructions, not system |
| Structured output | output: Output.object(...) on text functions |
| Loop limit | stopWhen: isStepCount(n) |
| Shared server state | runtimeContext |
| Per-tool state/secrets | tool contextSchema + toolsContext |
| Sensitive tools | toolApproval on generateText, streamText, or ToolLoopAgent |
| Durable long-running agents | WorkflowAgent from @ai-sdk/workflow |
| Running Claude Code/Codex/Pi | HarnessAgent from @ai-sdk/harness/agent |
| Observability | registerTelemetry(new OpenTelemetry()) |
| Stalled calls | timeout number or object |
In examples, __MODEL__ is a placeholder: resolve a current model via the
project's provider package (e.g. anthropic('...')) or a gateway model string,
following the model-ID guidance in the ai-sdk skill. Never hard-code a model
ID from memory.
import { generateText, isStepCount, Output } from 'ai';
import { z } from 'zod';
const result = await generateText({
model: __MODEL__,
instructions: 'Answer concisely.',
prompt: 'Classify this support ticket.',
reasoning: 'high',
stopWhen: isStepCount(3),
timeout: { totalMs: 60_000, stepMs: 15_000 },
output: Output.object({
schema: z.object({
priority: z.enum(['low', 'medium', 'high']),
summary: z.string(),
}),
}),
});
console.log(result.output);
Read only the reference needed for the current task:
ToolLoopAgent, WorkflowAgent, context, approvals.HarnessAgent, sessions, adapters, sandboxing, UI.generateText, streamText, output, result shape.useChat, typed tool parts, approvals, harness/workflow UI.uploadFile, uploadSkill, realtime, video.vercel/ai.result.usage now aggregates all steps. Use result.finalStep.usage for
previous final-step-only behavior.streamText, await result.finalStep before reading final-step-only
metadata.detach() or stop() instead of replaying the entire UI message history.WorkflowAgent is stream-first and durable; use ToolLoopAgent for simple
in-memory agents.toolApproval applies to AI SDK-executed tools. Provider-executed tools and
harness built-ins have separate approval/permission behavior.Scans a codebase for architectural friction, presents candidates as a visual HTML report with before/after diagrams, and guides you through deepening refactors.
npx claudepluginhub laguagu/claude-code-nextjs-skills