โ† Back to list
skillrecordings

ai-sdk

by skillrecordings

๐Ÿค– an AI agent for the support desk at Badass Courses

โญ 0๐Ÿด 0๐Ÿ“… Jan 25, 2026

SKILL.md


name: ai-sdk description: Comprehensive guide to AI SDK v6 for agent development, tool definitions, multi-step agentic workflows, and result extraction patterns

Vercel AI SDK v6 Patterns

Zod 4.x

This repo uses Zod 4.x (4.3.5+) directly:

// โœ… Standard Zod 4 import
import { z } from 'zod'

Zod 4's optimized types work well with AI SDK v6's recursive generics.


Comprehensive guide for Vercel AI SDK v6 (6.0+) patterns used in agent-first applications. Contains rules for provider setup, tool definitions, multi-step workflows, and result extraction.

When to Apply

Reference these guidelines when:

  • Setting up AI model providers
  • Defining agent tools with tool()
  • Implementing multi-step agentic workflows
  • Extracting results from generateText/streamText
  • Migrating from AI SDK v5 to v6

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Provider SetupCRITICALprovider-
2Text GenerationHIGHgenerate-
3Tool DefinitionsHIGHtool-
4Multi-Step AgentsHIGHagent-
5Result ExtractionMEDIUMresult-
6Message TypesMEDIUMmessage-
7Error HandlingMEDIUMerror-

Quick Reference

Critical v6 Breaking Changes

// โŒ v5 patterns that FAIL in v6:
import { type CoreMessage } from 'ai'     // โ†’ ModelMessage
parameters: z.object({...})               // โ†’ inputSchema
maxSteps: 5                               // โ†’ stopWhen: stepCountIs(5)
call.args                                 // โ†’ call.input
call.toolResult                           // โ†’ step.toolResults[].output

1. Provider Setup (CRITICAL)

  • provider-gateway - Use AI Gateway model strings (recommended)
import { generateText } from 'ai'

const result = await generateText({
  model: 'anthropic/claude-opus-4-5',  // AI Gateway string
  prompt: 'Hello',
})

No provider wrapper is required when using AI Gateway model strings.

2. Text Generation (HIGH)

  • generate-basic - Core generateText pattern

3. Tool Definitions (HIGH)

  • tool-input-schema - v6 uses inputSchema not parameters
  • tool-definition - Complete tool() pattern
import { tool } from 'ai'
import { z } from 'zod'

const myTool = tool({
  description: 'What this does',
  inputSchema: z.object({  // โœ… inputSchema not parameters
    param: z.string().describe('Description'),
  }),
  execute: async ({ param }) => {
    return { result: 'done' }
  },
})

4. Multi-Step Agents (HIGH)

  • agent-stop-when - v6 uses stopWhen not maxSteps
  • agent-multi-step - Complete agent pattern
import { generateText, stepCountIs } from 'ai'

const result = await generateText({
  model: 'anthropic/claude-opus-4-5',
  messages,
  tools: agentTools,
  stopWhen: stepCountIs(5),  // โœ… not maxSteps: 5
})

5. Result Extraction (MEDIUM)

  • result-tool-access - Access tool calls and results correctly
// โœ… Correct v6 pattern
const toolCalls = result.steps.flatMap((step) => {
  const resultsMap = new Map(
    (step.toolResults || []).map((r) => [r.toolCallId, r.output])
  )
  return (step.toolCalls || []).map((tc) => ({
    name: tc.toolName,
    args: tc.input,  // โœ… input not args
    result: resultsMap.get(tc.toolCallId),  // โœ… from toolResults
  }))
})

6. Message Types (MEDIUM)

  • message-model-message - Use ModelMessage type
import { type ModelMessage } from 'ai'  // โœ… not CoreMessage

const messages: ModelMessage[] = [
  { role: 'user', content: 'Hello' },
]

How to Use

Read individual rule files for detailed explanations and code examples:

rules/provider-gateway.md
rules/tool-input-schema.md
rules/agent-stop-when.md
rules/result-tool-access.md
rules/_sections.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Reference links

Key Imports

import {
  generateText,
  generateObject,
  streamText,
  streamObject,
  tool,
  stepCountIs,
  hasToolCall,
  type ModelMessage,
} from 'ai'
import { z } from 'zod'  // Zod 4.x

Model Strings (AI Gateway)

anthropic/claude-opus-4-5
anthropic/claude-sonnet-4
openai/gpt-4o
google/gemini-2.0-flash

Auth: Set AI_GATEWAY_API_KEY environment variable.

Score

Total Score

50/100

Based on repository quality metrics

โœ“SKILL.md

SKILL.mdใƒ•ใ‚กใ‚คใƒซใŒๅซใพใ‚Œใฆใ„ใ‚‹

+20
โ—‹LICENSE

ใƒฉใ‚คใ‚ปใƒณใ‚นใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

0/10
โ—‹่ชฌๆ˜Žๆ–‡

100ๆ–‡ๅญ—ไปฅไธŠใฎ่ชฌๆ˜ŽใŒใ‚ใ‚‹

0/10
โ—‹ไบบๆฐ—

GitHub Stars 100ไปฅไธŠ

0/15
โ—‹ๆœ€่ฟ‘ใฎๆดปๅ‹•

3ใƒถๆœˆไปฅๅ†…ใซๆ›ดๆ–ฐใŒใ‚ใ‚‹

0/10
โ—‹ใƒ•ใ‚ฉใƒผใ‚ฏ

10ๅ›žไปฅไธŠใƒ•ใ‚ฉใƒผใ‚ฏใ•ใ‚Œใฆใ„ใ‚‹

0/5
โœ“Issue็ฎก็†

ใ‚ชใƒผใƒ—ใƒณIssueใŒ50ๆœชๆบ€

+5
โœ“่จ€่ชž

ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชžใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5
โ—‹ใ‚ฟใ‚ฐ

1ใคไปฅไธŠใฎใ‚ฟใ‚ฐใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

0/5

Reviews

๐Ÿ’ฌ

Reviews coming soon