vercel-ai-sdk

wsimmonds/claude-nextjs-skills · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/wsimmonds/claude-nextjs-skills --skill vercel-ai-sdk
0 commentsdiscussion
summary

Use this skill when:

skill.md

Vercel AI SDK v5 Implementation Guide

When to Use This Skill

Use this skill when:

  • Implementing AI chat interfaces with useChat hook
  • Creating API routes that generate or stream AI responses
  • Adding tool calling / function calling capabilities
  • Generating text embeddings for semantic search or RAG
  • Migrating from AI SDK v4 to v5
  • Integrating Model Context Protocol (MCP) servers
  • 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)
  - @modelcontextprotocol/sdk (MCP integration)
  - 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:

  1. ✅ Write correct implementation
  2. Install any required dependencies
  3. Run build and fix ALL errors
  4. Run tests and debug ALL failures
  5. Iterate until EVERYTHING passes
  6. 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:

  1. 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
    
  2. Identify the package from the import statement

    Error: Cannot find module '@ai-sdk/openai'
    Import: import { openai } from '@ai-sdk/openai'
    Package needed: @ai-sdk/openai
    
  3. Install with the CORRECT package manager

    # If pnpm-lock.yaml exists (MOST COMMON for Next.js evals):
    pnpm install @ai-sdk/openai
    # or
    pnpm add @ai-sdk/openai
    
    # If package-lock.json exists:
    npm install @ai-sdk/openai
    
    # If yarn.lock exists:
    yarn add @ai-sdk/openai
    
    # If bun.lockb exists:
    bun install @ai-sdk/openai
    
  4. Re-run build to verify

    npm run build
    # or pnpm run build, yarn build, bun run build
    
  5. 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:

  1. Read the FULL error message - don't skim it
  2. 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
  3. Apply the fix
  4. Re-run build
  5. Repeat until build passes

Test Failure Debugging Workflow

When tests fail:

  1. Read the FULL test error - understand what's expected
  2. Compare expected vs actual behavior
  3. Check your implementation against test assertions
  4. Fix the issue in your code
  5. Re-run tests
  6. Repeat until all tests pass

Success Criteria

Task is ONLY complete when:

  • ✅ Build passes (npm run build succeeds)
  • ✅ Lint passes (npm run lint succeeds)
  • ✅ Tests pass (npm run test succeeds)

NEVER stop at "code is correct" - achieve FULL PASSING status!

⚠️ 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 v5
    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 tool from 'ai' package: import { tool } from 'ai';
  • Wrapped tool definition with tool({ ... })
  • Used inputSchema property (NOT parameters)
  • Used zod schema: z.object({ ... })
  • Defined execute function with async callback
  • Added description string for the tool

⚠️ CRITICAL: Common v4 to v5 Breaking Changes

1. useChat Hook Changes

❌ WRONG (v4 pattern):

const { messages, input, setInput, append } = useChat();

// Sending message
append({ content: text, role: 'user' });

✅ CORRECT (v5 pattern):

const { messages, sendMessage } = useChat();
const [input, setInput] = useState('');

// Sending message
sendMessage({ text: input });

2. Message Structure

❌ WRONG (v4 simple content):

<div>{message.content}</div>

✅ CORRECT (v5 parts-based):

<div>
  {message.parts.map((part, index) =>
    part.type === 'text' ? <span key={index}>{part.text}</span> : null
  )}
</div>

3. Model Specification

✅ PREFER: String-based (v5 recommended):

import { generateText } from 'ai';

const result = await generateText({
  model: 'openai/gpt-4o',  // String format
  prompt: 'Hello',
});

✅ ALSO WORKS: Function-based (legacy support):

import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';

const result = await generateText({
  model: openai('gpt-4o'),  // Function format
  prompt: 'Hello',
});

Core API Reference

1. generateText - Non-Streaming Text Generation

Purpose: Generate text for non-interactive use cases (email drafts, summaries, agents with tools).

Signature:

import { generateText } from 'ai';

const result = await generateText({
  model: 'openai/gpt-4o',           // String format: 'provider/model-id'
  prompt: 'Your prompt here',        // User input
  system: 'Optional system message', // Optional system instructions
  tools?: { ... },                   // Optional tool calling
  maxSteps?: 5,                      // For multi-step tool calling
how to use vercel-ai-sdk

How to use vercel-ai-sdk on Cursor

AI-first code editor with Composer

1

Prerequisites

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
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/wsimmonds/claude-nextjs-skills --skill vercel-ai-sdk

The skills CLI fetches vercel-ai-sdk from GitHub repository wsimmonds/claude-nextjs-skills and configures it for Cursor.

3

Select 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
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/vercel-ai-sdk

Reload 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.

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. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 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

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.547 reviews
  • Pratham Ware· Dec 28, 2024

    vercel-ai-sdk is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Dhruvi Jain· Dec 24, 2024

    vercel-ai-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Hana White· Dec 24, 2024

    We added vercel-ai-sdk from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Camila Liu· Dec 24, 2024

    Registry listing for vercel-ai-sdk matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Sophia Gonzalez· Dec 20, 2024

    vercel-ai-sdk fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Soo Thomas· Dec 8, 2024

    Solid pick for teams standardizing on skills: vercel-ai-sdk is focused, and the summary matches what you get after install.

  • Diya Martinez· Nov 27, 2024

    vercel-ai-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Oshnikdeep· Nov 15, 2024

    Solid pick for teams standardizing on skills: vercel-ai-sdk is focused, and the summary matches what you get after install.

  • Sophia Ndlovu· Nov 15, 2024

    Useful defaults in vercel-ai-sdk — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Tariq Thompson· Nov 15, 2024

    vercel-ai-sdk reduced setup friction for our internal harness; good balance of opinion and flexibility.

showing 1-10 of 47

1 / 5