wsimmonds/claude-nextjs-skills/vercel-ai-sdk
Claude Code and agent skill by wsimmonds/claude-nextjs-skills
- community
Checking that the SKILL.md file is still in the repository.
Guide for Vercel AI SDK v5 implementation patterns including generateText, streamText, useChat hook, tool calling, embeddings, and MCP integration. Use when implementing AI chat interfaces, streaming responses, tool/function calling, text embeddings, or working with convertToModelMessages and toUIMessageStreamResponse. Activates for AI SDK integration, useChat hook usage, message streaming, or tool calling tasks.
Install
npx vskill@latest install wsimmonds/claude-nextjs-skills/vercel-ai-sdkSKILL.md
Vercel AI SDK v5 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
- 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
<workflow> <step id="1" name="verify-requirements"> <description>Understand the task requirements</description> <actions>
- Identify what AI functionality is needed (chat, generation, tools, embeddings)
- Determine if client-side (useChat) or server-side (API route) implementation
- Check if streaming or non-streaming response is required
- Verify model provider (OpenAI, Anthropic, etc.)
</actions> </step>
<step id="2" name="check-documentation"> <description>Verify current API patterns if uncertain</description> <actions>
- Use WebFetch to check https://ai-sdk.dev/docs/ if API patterns are unclear
- Confirm model specification format for the provider
- Verify function signatures for complex features
</actions> </step>
<step id="3" name="implement"> <description>Implement using correct v5 patterns</description> <actions>
- Use string-based model specification ('provider/model-id')
- For chat: use sendMessage (not append), parts-based messages
- For tools: MUST import and use tool() helper from 'ai', MUST use inputSchema (NOT parameters), MUST use zod
- For streaming: use toUIMessageStreamResponse() or toTextStreamResponse()
- For embeddings: use provider.textEmbeddingModel()
</actions> </step>
<step id="4" name="verify-types"> <description>Ensure TypeScript types are correct</description> <actions>
- Check for proper imports from 'ai' package
- Verify message types (UIMessage for useChat)
- Ensure tool parameter types are inferred correctly
- Add explicit types for async functions
</actions> </step>
<step id="5" name="install-dependencies"> <description>Install any missing dependencies with the CORRECT package manager</description> <actions>
- CRITICAL: Detect which package manager the project uses FIRST
- Check for lockfiles: pnpm-lock.yaml → use pnpm, package-lock.json → use npm, yarn.lock → use yarn, bun.lockb → use bun
- If pnpm-lock.yaml exists, you MUST use pnpm (NOT npm!)
- Check if all imported packages are installed
- If build fails with "Module not found", identify the package name from the error
- Add the package to package.json dependencies
- Install using the CORRECT package manager:
- If pnpm-lock.yaml exists:
pnpm install [package]orpnpm add [package] - If package-lock.json exists:
npm install [package] - If yarn.lock exists:
yarn add [package] - If bun.lockb exists:
bun install [package]orbun add [package] - Re-run build to verify installation succeeded
</actions> <critical> NEVER use the wrong package manager!
- Using npm when the project uses pnpm creates package-lock.json alongside pnpm-lock.yaml
- This causes dependency version mismatches and breaks the build
- ALWAYS check for existing lockfiles and use the matching package manager
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> </step>
<step id="6" name="verify-build"> <description>Run build and fix ALL errors until it passes</description> <actions>
- Run: npm run build (or bun run build)
- If build fails, read the FULL error message carefully
- Common fixes:
- "Module not found" → Install the package (go back to step 5)
- Type errors → Fix TypeScript types
- Config errors → Check next.config.js/ts
- Framework errors → Research the error, try different approaches
- Apply fix and re-run build
- REPEAT until build passes
</actions> <critical> NEVER stop at "build fails but code is correct" NEVER blame "environment" or "framework bugs" without debugging KEEP ITERATING until the build PASSES If you encounter a framework error, research it, try workarounds, debug it DO NOT give up until you have a passing build </critical> </step>
<step id="7" name="verify-tests"> <description>Run tests and debug ALL failures until they pass</description> <actions>
- Run: npm run test (or bun run test)
- If tests fail, read the FULL error message carefully
- Debug the failure:
- Check what the test expects vs what you're providing
- Look at test assertions
- Verify your implementation matches the requirements
- Check for type mismatches or missing properties
- Fix the implementation
- Re-run tests
- REPEAT until all tests pass
</actions> <critical> NEVER accept test failures without debugging NEVER dismiss failures as "test framework bugs" without investigation Each test failure is telling you something - LISTEN to it KEEP DEBUGGING until all tests pass Test failures are NOT acceptable - they mean your implementation is incomplete </critical> </step>
<step id="8" name="final-verification"> <description>Verify EVERYTHING passes</description> <actions>
- Run: npm run build && npm run lint && npm run test
- All three must pass: ✅ Build, ✅ Lint, ✅ Tests
- If any fail, go back and fix them
- Do not consider the task complete until ALL checks pass
</actions> <critical> The task is NOT complete until:
- ✅ Build passes
- ✅ Lint passes
- ✅ Tests pass
"Code is correct" is NOT enough You must achieve FULL PASSING status This is what it means to be an autonomous agent </critical> </step> </workflow>
⚠️ 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:
``bash 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/openai' Import: import { openai } from '@ai-sdk/openai' Package needed: @ai-sdk/openai ``
- Install with the CORRECT package manager
```bash # 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 ```
- Re-run build to verify
``bash 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: 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)
This will fail with: Type '{ description: string; parameters: ... }' is not assignable to type '{ inputSchema: FlexibleSchema<any>; ... }'
✅ CORRECT - Use tool() Helper (REQUIRED)
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
⚠️ CRITICAL: Common v4 to v5 Breaking Changes
1. useChat Hook Changes
❌ WRONG (v4 pattern):
✅ CORRECT (v5 pattern):
2. Message Structure
❌ WRONG (v4 simple content):
✅ CORRECT (v5 parts-based):
3. Model Specification
✅ PREFER: String-based (v5 recommended):
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingvercel-ai-sdk/SKILL.md
Popularity
- Repository stars
- 74
- Repository forks
- 9
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wsimmonds/claude-nextjs-skills/vercel-ai-sdk)