vercel-ai-sdk▌
fluid-tools/claude-skills · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Use this skill when:
Vercel AI SDK v6 Implementation Guide
When to Use This Skill
Use this skill when:
- Implementing AI chat interfaces with
useChathook - Creating API routes that generate or stream AI responses
- Building agentic applications with
ToolLoopAgent - Adding tool calling / function calling capabilities
- Generating structured output with
Output.object(),Output.array(), etc. - Generating text embeddings for semantic search or RAG
- Migrating from AI SDK v5 to v6
- Integrating Model Context Protocol (MCP) servers
- Implementing middleware for caching, logging, or guardrails
- Building workflow patterns (sequential, parallel, routing, etc.)
- Working with streaming responses or message persistence
Structured Implementation Workflow
NEVER accept "Module not found" errors as environment issues
YOU must install the required packages with the CORRECT package manager
Common packages needed:
- ai (core AI SDK)
- @ai-sdk/openai (OpenAI provider)
- @ai-sdk/anthropic (Anthropic provider)
- @ai-sdk/mcp (MCP integration)
- @modelcontextprotocol/sdk (MCP client SDK)
- zod (for tool schemas)
</critical>
"Code is correct" is NOT enough
You must achieve FULL PASSING status
This is what it means to be an autonomous agent
</critical>
⚠️ AUTONOMOUS AGENT MINDSET
You are not just writing code - you are COMPLETING TASKS AUTONOMOUSLY.
This means:
- ✅ Write correct implementation
- ✅ Install any required dependencies
- ✅ Run build and fix ALL errors
- ✅ Run tests and debug ALL failures
- ✅ Iterate until EVERYTHING passes
- ✅ Never make excuses or give up
Common Failure Patterns to AVOID
❌ WRONG: "The code is correct, but the package isn't installed - that's an environment issue" ✅ CORRECT: "Build failed due to missing package - installing it now with npm install [package]"
❌ WRONG: "Tests pass but build fails - not my problem" ✅ CORRECT: "Build is failing - debugging the error and fixing it now"
❌ WRONG: "There's a framework bug, can't fix it" ✅ CORRECT: "Framework error detected - researching the issue, trying workarounds, debugging until I find a solution"
❌ WRONG: "The implementation is complete" (with failing tests) ✅ CORRECT: "Tests are failing - debugging and fixing until they all pass"
Dependency Installation Workflow
When you encounter "Module not found" errors:
-
Detect the package manager FIRST - Check for lockfiles:
ls -la | grep -E "lock" # Look for: pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb -
Identify the package from the import statement
Error: Cannot find module '@ai-sdk/anthropic' Import: import { anthropic } from '@ai-sdk/anthropic' Package needed: @ai-sdk/anthropic -
Install with the CORRECT package manager
# If pnpm-lock.yaml exists (MOST COMMON for Next.js evals): pnpm install @ai-sdk/anthropic # or pnpm add @ai-sdk/anthropic # If package-lock.json exists: npm install @ai-sdk/anthropic # If yarn.lock exists: yarn add @ai-sdk/anthropic # If bun.lockb exists: bun install @ai-sdk/anthropic -
Re-run build to verify
npm run build # or pnpm run build, yarn build, bun run build -
Fix any new errors that appear
⚠️ CRITICAL WARNING: Using the WRONG package manager (e.g., npm when the project uses pnpm) will:
- Create a second conflicting lockfile
- Install different versions of dependencies
- Cause dependency version mismatches
- Break the build with cryptic errors like "Cannot read properties of null"
Build Error Debugging Workflow
When build fails:
- Read the FULL error message - don't skim it
- Identify the root cause:
- Module not found → Install package
- Type error → Fix types
- Config error → Check config files
- Next.js error → Research, try different approaches
- Apply the fix
- Re-run build
- Repeat until build passes
Test Failure Debugging Workflow
When tests fail:
- Read the FULL test error - understand what's expected
- Compare expected vs actual behavior
- Check your implementation against test assertions
- Fix the issue in your code
- Re-run tests
- Repeat until all tests pass
Success Criteria
Task is ONLY complete when:
- ✅ Build passes (
npm run buildsucceeds) - ✅ Lint passes (
npm run lintsucceeds) - ✅ Tests pass (
npm run testsucceeds)
NEVER stop at "code is correct" - achieve FULL PASSING status!
⚠️ CRITICAL v6 CHANGES: Structured Output
In v6, generateObject and streamObject are DEPRECATED. Use generateText/streamText with Output helpers instead.
❌ WRONG - Deprecated v5 Pattern
// DO NOT USE - DEPRECATED in v6
import { generateObject } from "ai";
const result = await generateObject({
model: anthropic("claude-sonnet-4-5"),
schema: z.object({
sentiment: z.enum(["positive", "neutral", "negative"]),
}),
prompt: "Analyze sentiment",
});
✅ CORRECT - v6 Output Pattern
import { generateText, Output } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { z } from "zod";
const { output } = await generateText({
model: anthropic("claude-sonnet-4-5"),
output: Output.object({
schema: z.object({
sentiment: z.enum(["positive", "neutral", "negative"]),
topics: z.array(z.string()),
}),
}),
prompt: "Analyze this feedback...",
});
// Access typed output
console.log(output.sentiment); // 'positive' | 'neutral' | 'negative'
console.log(output.topics); // string[]
Output Helper Types
| Helper | Purpose | Example |
|---|---|---|
Output.object() |
Generate typed object | Output.object({ schema: z.object({...}) }) |
Output.array() |
Generate typed array | Output.array({ schema: z.string() }) |
Output.choice() |
Generate enum value | Output.choice({ choices: ['A', 'B', 'C'] }) |
Output.json() |
Unstructured JSON | Output.json() |
⚠️ CRITICAL: Tool Calling API - MUST USE tool() Helper
When implementing tool calling, you MUST use the tool() helper function from the 'ai' package.
❌ WRONG - Plain Object (WILL CAUSE BUILD ERROR)
// DO NOT DO THIS - This pattern is INCORRECT
import { z } from 'zod';
tools: {
myTool: {
description: 'My tool',
parameters: z.object({...}), // ❌ WRONG - "parameters" doesn't exist in v6
execute: async ({...}) => {...},
}
}
This will fail with: Type '{ description: string; parameters: ... }' is not assignable to type '{ inputSchema: FlexibleSchema<any>; ... }'
✅ CORRECT - Use tool() Helper (REQUIRED)
// ALWAYS DO THIS - This is the ONLY correct pattern
import { tool } from 'ai'; // ⚠️ MUST import tool
import { z } from 'zod';
tools: {
myTool: tool({ // ⚠️ MUST wrap with tool()
description: 'My tool',
inputSchema: z.object({...}), // ⚠️ MUST use "inputSchema" (not "parameters")
execute: async ({...}) => {...},
}),
}
Tool Calling Checklist
Before implementing any tool, verify:
- [ ] Imported
toolfrom 'ai' package:import { tool } from 'ai'; - [ ] Wrapped tool definition with
tool({ ... }) - [ ] Used
inputSchemaproperty (NOTparameters) - [ ] Used zod schema:
z.object({ ... }) - [ ] Defined
executefunction with async callback - [ ] Added
descriptionstring for the tool
⚠️ NEW in v6: ToolLoopAgent for Agentic Applications
Agent Definition
import { ToolLoopAgent, tool, stepCountIs } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { z } from "zod";
const myAgent = new ToolLoopAgent({
model: anthropic("claude-sonnet-4-5"),
instructions: "You are a helpful assistant that can search and analyze data.",
tools: {
how to use vercel-ai-sdkHow to use vercel-ai-sdk on Cursor
AI-first code editor with Composer
1Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add vercel-ai-sdk
2Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
$npx skills add https://github.com/fluid-tools/claude-skills --skill vercel-ai-sdkThe skills CLI fetches vercel-ai-sdk from GitHub repository fluid-tools/claude-skills and configures it for Cursor.
3Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
◆ Which agents do you want to install to?││ ── Universal (.agents/skills) ── always included ────│ • Amp│ • Antigravity│ • Cline│ • Codex│ ●Cursor(selected)│ • Cursor│ • Windsurf4Verify installation
Confirm successful installation by checking the skill directory location:
.cursor/skills/vercel-ai-sdkReload or restart Cursor to activate vercel-ai-sdk. Access the skill through slash commands (e.g., /vercel-ai-sdk) or your agent's skill management interface.
⚠Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
Additional Resources
List & Monetize Your Skill
Submit your Claude Code skill and start earning
GET_STARTED →Use Cases▌
Task Automation & Efficiency
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
✓Save 3-5 hours per week on routine tasks
Knowledge Enhancement
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
✓Accelerate learning and skill development by 2x
Quality Improvement
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
✓Improve work quality by 30-40% with less effort
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Installation Steps
- 1.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 5.Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices▌
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This▌
✓ Use When
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid When
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
general reviewsRatings
4.7★★★★★38 reviews- ★★★★★Dhruvi Jain· Dec 28, 2024
Useful defaults in vercel-ai-sdk — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Camila Garcia· Dec 20, 2024
I recommend vercel-ai-sdk for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Ira Martinez· Dec 4, 2024
vercel-ai-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Nia Martin· Nov 23, 2024
Useful defaults in vercel-ai-sdk — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Oshnikdeep· Nov 19, 2024
vercel-ai-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Camila Haddad· Nov 11, 2024
Solid pick for teams standardizing on skills: vercel-ai-sdk is focused, and the summary matches what you get after install.
- ★★★★★Ira Torres· Oct 14, 2024
I recommend vercel-ai-sdk for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Ganesh Mohane· Oct 10, 2024
Solid pick for teams standardizing on skills: vercel-ai-sdk is focused, and the summary matches what you get after install.
- ★★★★★Fatima Sharma· Oct 2, 2024
vercel-ai-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Rahul Santra· Sep 25, 2024
We added vercel-ai-sdk from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
showing 1-10 of 38
1 / 4