[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AJ9RKJED8VDW1DVC2AH7EQ":3,"skill-same:01M7AJ9RKJED8VDW1DVC2AH7EQ":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":5,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7AJ9RKJED8VDW1DVC2AH7EQ","ai-sdk-ui",null,"Frontend React hooks for AI-powered chat interfaces, completions, and streaming UIs with Vercel AI SDK v5.\nIncludes useChat, useCompletion, and useObject hooks for building interactive AI applications.\n\nUse when: building React chat interfaces, implementing AI completions in UI, streaming AI responses to frontend,\nhandling chat message state, building Next.js AI apps, managing file attachments with AI, or encountering\nerrors like \"useChat failed to parse stream\", \"useChat no response\", unclosed streams, or streaming issues.\n\nKeywords: ai sdk ui, useChat hook, useCompletion hook, useObject hook, react ai chat, ai chat interface,\nstreaming ai ui, nextjs ai chat, vercel ai ui, react streaming, ai sdk react, chat message state,\nai file attachments, message persistence, useChat error, streaming failed ui, parse stream error,\nuseChat no response, react ai hooks, nextjs app router ai, nextjs pages router ai","davidanthonyn\u002Fagent-skills","davidanthonyn","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F55152980?v=4","01M7AJ4MY8S5C2RJCGX6626J0G","01M7AJ4MZB7EC7CAP27ANCSE7N",1,"MIT","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fai-sdk-ui\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: ai-sdk-ui\ndescription: |\n  Frontend React hooks for AI-powered chat interfaces, completions, and streaming UIs with Vercel AI SDK v5.\n  Includes useChat, useCompletion, and useObject hooks for building interactive AI applications.\n\n  Use when: building React chat interfaces, implementing AI completions in UI, streaming AI responses to frontend,\n  handling chat message state, building Next.js AI apps, managing file attachments with AI, or encountering\n  errors like \"useChat failed to parse stream\", \"useChat no response\", unclosed streams, or streaming issues.\n\n  Keywords: ai sdk ui, useChat hook, useCompletion hook, useObject hook, react ai chat, ai chat interface,\n  streaming ai ui, nextjs ai chat, vercel ai ui, react streaming, ai sdk react, chat message state,\n  ai file attachments, message persistence, useChat error, streaming failed ui, parse stream error,\n  useChat no response, react ai hooks, nextjs app router ai, nextjs pages router ai\nlicense: MIT\n---\n\n# AI SDK UI - Frontend React Hooks\n\nFrontend React hooks for AI-powered user interfaces with Vercel AI SDK v5.\n\n**Version**: AI SDK v5.0.76+ (Stable)\n**Framework**: React 18+, Next.js 14+\n**Last Updated**: 2025-10-22\n\n---\n\n## Quick Start (5 Minutes)\n\n### Installation\n\n```bash\nnpm install ai @ai-sdk\u002Fopenai\n```\n\n### Basic Chat Component (v5)\n\n```tsx\n\u002F\u002F app\u002Fchat\u002Fpage.tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function Chat() {\n  const { messages, sendMessage, isLoading } = useChat({\n    api: '\u002Fapi\u002Fchat',\n  });\n  const [input, setInput] = useState('');\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    sendMessage({ content: input });\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv>\n      \u003Cdiv>\n        {messages.map(m => (\n          \u003Cdiv key={m.id}>\n            \u003Cstrong>{m.role}:\u003C\u002Fstrong> {m.content}\n          \u003C\u002Fdiv>\n        ))}\n      \u003C\u002Fdiv>\n      \u003Cform onSubmit={handleSubmit}>\n        \u003Cinput\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n          placeholder=\"Type a message...\"\n          disabled={isLoading}\n        \u002F>\n      \u003C\u002Fform>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### API Route (Next.js App Router)\n\n```typescript\n\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\n\nexport async function POST(req: Request) {\n  const { messages } = await req.json();\n\n  const result = streamText({\n    model: openai('gpt-4-turbo'),\n    messages,\n  });\n\n  return result.toDataStreamResponse();\n}\n```\n\n**Result**: A functional chat interface with streaming AI responses in ~10 lines of frontend code.\n\n---\n\n## useChat Hook - Complete Reference\n\n### Basic Usage (v5 Pattern)\n\n```tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function ChatComponent() {\n  const { messages, sendMessage, isLoading, error } = useChat({\n    api: '\u002Fapi\u002Fchat',\n  });\n  const [input, setInput] = useState('');\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    if (!input.trim()) return;\n\n    sendMessage({ content: input });\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv className=\"flex flex-col h-screen\">\n      {\u002F* Messages *\u002F}\n      \u003Cdiv className=\"flex-1 overflow-y-auto p-4\">\n        {messages.map(message => (\n          \u003Cdiv\n            key={message.id}\n            className={message.role === 'user' ? 'text-right' : 'text-left'}\n          >\n            \u003Cdiv className=\"inline-block p-2 rounded bg-gray-100\">\n              {message.content}\n            \u003C\u002Fdiv>\n          \u003C\u002Fdiv>\n        ))}\n        {isLoading && \u003Cdiv className=\"text-gray-500\">AI is thinking...\u003C\u002Fdiv>}\n      \u003C\u002Fdiv>\n\n      {\u002F* Input *\u002F}\n      \u003Cform onSubmit={handleSubmit} className=\"p-4 border-t\">\n        \u003Cinput\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n          placeholder=\"Type a message...\"\n          disabled={isLoading}\n          className=\"w-full p-2 border rounded\"\n        \u002F>\n      \u003C\u002Fform>\n\n      {\u002F* Error *\u002F}\n      {error && \u003Cdiv className=\"text-red-500 p-4\">{error.message}\u003C\u002Fdiv>}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Full API Reference\n\n```typescript\nconst {\n  \u002F\u002F Messages\n  messages,           \u002F\u002F Message[] - Chat history\n  setMessages,        \u002F\u002F (messages: Message[]) => void - Update messages\n\n  \u002F\u002F Actions\n  sendMessage,        \u002F\u002F (message: { content: string }) => void - Send message (v5)\n  reload,             \u002F\u002F () => void - Reload last response\n  stop,               \u002F\u002F () => void - Stop current generation\n\n  \u002F\u002F State\n  isLoading,          \u002F\u002F boolean - Is AI responding?\n  error,              \u002F\u002F Error | undefined - Error if any\n\n  \u002F\u002F Data\n  data,               \u002F\u002F any[] - Custom data from stream\n  metadata,           \u002F\u002F object - Response metadata\n} = useChat({\n  \u002F\u002F Required\n  api: '\u002Fapi\u002Fchat',   \u002F\u002F API endpoint\n\n  \u002F\u002F Optional\n  id: 'chat-1',       \u002F\u002F Chat ID for persistence\n  initialMessages: [], \u002F\u002F Initial messages (controlled mode)\n\n  \u002F\u002F Callbacks\n  onFinish: (message, options) => {},  \u002F\u002F Called when response completes\n  onError: (error) => {},              \u002F\u002F Called on error\n\n  \u002F\u002F Configuration\n  headers: {},        \u002F\u002F Custom headers\n  body: {},           \u002F\u002F Additional body data\n  credentials: 'same-origin', \u002F\u002F Fetch credentials\n\n  \u002F\u002F Streaming\n  streamProtocol: 'data', \u002F\u002F 'data' | 'text' (default: 'data')\n});\n```\n\n### v4 → v5 Breaking Changes\n\n**CRITICAL: useChat no longer manages input state in v5!**\n\n**v4 (OLD - DON'T USE):**\n```tsx\nconst { messages, input, handleInputChange, handleSubmit, append } = useChat();\n\n\u003Cform onSubmit={handleSubmit}>\n  \u003Cinput value={input} onChange={handleInputChange} \u002F>\n\u003C\u002Fform>\n```\n\n**v5 (NEW - CORRECT):**\n```tsx\nconst { messages, sendMessage } = useChat();\nconst [input, setInput] = useState('');\n\n\u003Cform onSubmit={(e) => {\n  e.preventDefault();\n  sendMessage({ content: input });\n  setInput('');\n}}>\n  \u003Cinput value={input} onChange={(e) => setInput(e.target.value)} \u002F>\n\u003C\u002Fform>\n```\n\n**Summary of v5 Changes:**\n1. **Input management removed**: `input`, `handleInputChange`, `handleSubmit` no longer exist\n2. **`append()` → `sendMessage()`**: New method for sending messages\n3. **`onResponse` removed**: Use `onFinish` instead\n4. **`initialMessages` → controlled mode**: Use `messages` prop for full control\n5. **`maxSteps` removed**: Handle on server-side only\n\nSee `references\u002Fuse-chat-migration.md` for complete migration guide.\n\n### Tool Calling in UI\n\nWhen your API uses tools, useChat automatically handles tool invocations in the message stream:\n\n```tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\n\nexport default function ChatWithTools() {\n  const { messages } = useChat({ api: '\u002Fapi\u002Fchat' });\n\n  return (\n    \u003Cdiv>\n      {messages.map(message => (\n        \u003Cdiv key={message.id}>\n          {\u002F* Text content *\u002F}\n          {message.content && \u003Cp>{message.content}\u003C\u002Fp>}\n\n          {\u002F* Tool invocations *\u002F}\n          {message.toolInvocations?.map((tool, idx) => (\n            \u003Cdiv key={idx} className=\"bg-blue-50 p-2 rounded my-2\">\n              \u003Cdiv className=\"font-bold\">Tool: {tool.toolName}\u003C\u002Fdiv>\n              \u003Cdiv className=\"text-sm\">\n                \u003Cstrong>Args:\u003C\u002Fstrong> {JSON.stringify(tool.args, null, 2)}\n              \u003C\u002Fdiv>\n              {tool.result && (\n                \u003Cdiv className=\"text-sm\">\n                  \u003Cstrong>Result:\u003C\u002Fstrong> {JSON.stringify(tool.result, null, 2)}\n                \u003C\u002Fdiv>\n              )}\n            \u003C\u002Fdiv>\n          ))}\n        \u003C\u002Fdiv>\n      ))}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### File Attachments\n\nUpload files (images, PDFs, etc.) alongside messages:\n\n```tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function ChatWithAttachments() {\n  const { messages, sendMessage, isLoading } = useChat({ api: '\u002Fapi\u002Fchat' });\n  const [input, setInput] = useState('');\n  const [files, setFiles] = useState\u003CFileList | null>(null);\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n\n    sendMessage({\n      content: input,\n      experimental_attachments: files\n        ? Array.from(files).map(file => ({\n            name: file.name,\n            contentType: file.type,\n            url: URL.createObjectURL(file),\n          }))\n        : undefined,\n    });\n\n    setInput('');\n    setFiles(null);\n  };\n\n  return (\n    \u003Cdiv>\n      {\u002F* Messages *\u002F}\n      {messages.map(m => (\n        \u003Cdiv key={m.id}>\n          {m.content}\n          {m.experimental_attachments?.map((att, idx) => (\n            \u003Cdiv key={idx}>\n              \u003Cimg src={att.url} alt={att.name} \u002F>\n            \u003C\u002Fdiv>\n          ))}\n        \u003C\u002Fdiv>\n      ))}\n\n      {\u002F* Input *\u002F}\n      \u003Cform onSubmit={handleSubmit}>\n        \u003Cinput\n          type=\"file\"\n          multiple\n          onChange={(e) => setFiles(e.target.files)}\n          accept=\"image\u002F*\"\n        \u002F>\n        \u003Cinput\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n        \u002F>\n        \u003Cbutton type=\"submit\" disabled={isLoading}>Send\u003C\u002Fbutton>\n      \u003C\u002Fform>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Message Persistence\n\nSave and load chat history to localStorage:\n\n```tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useEffect } from 'react';\n\nexport default function PersistentChat() {\n  const chatId = 'my-chat-1';\n\n  const { messages, setMessages, sendMessage } = useChat({\n    api: '\u002Fapi\u002Fchat',\n    id: chatId,\n    initialMessages: loadMessages(chatId),\n  });\n\n  \u002F\u002F Save messages whenever they change\n  useEffect(() => {\n    saveMessages(chatId, messages);\n  }, [messages, chatId]);\n\n  return (\n    \u003Cdiv>\n      {messages.map(m => (\n        \u003Cdiv key={m.id}>{m.role}: {m.content}\u003C\u002Fdiv>\n      ))}\n      {\u002F* Input form... *\u002F}\n    \u003C\u002Fdiv>\n  );\n}\n\n\u002F\u002F Helper functions\nfunction loadMessages(chatId: string) {\n  const stored = localStorage.getItem(`chat-${chatId}`);\n  return stored ? JSON.parse(stored) : [];\n}\n\nfunction saveMessages(chatId: string, messages: any[]) {\n  localStorage.setItem(`chat-${chatId}`, JSON.stringify(messages));\n}\n```\n\n---\n\n## useCompletion Hook - Complete Reference\n\n### Basic Usage\n\n```tsx\n'use client';\nimport { useCompletion } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function Completion() {\n  const { completion, complete, isLoading, error } = useCompletion({\n    api: '\u002Fapi\u002Fcompletion',\n  });\n  const [input, setInput] = useState('');\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    complete(input);\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv>\n      \u003Cform onSubmit={handleSubmit}>\n        \u003Ctextarea\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n          placeholder=\"Enter a prompt...\"\n          rows={4}\n          className=\"w-full p-2 border rounded\"\n        \u002F>\n        \u003Cbutton type=\"submit\" disabled={isLoading}>\n          {isLoading ? 'Generating...' : 'Generate'}\n        \u003C\u002Fbutton>\n      \u003C\u002Fform>\n\n      {completion && (\n        \u003Cdiv className=\"mt-4 p-4 bg-gray-50 rounded\">\n          \u003Ch3>Result:\u003C\u002Fh3>\n          \u003Cp>{completion}\u003C\u002Fp>\n        \u003C\u002Fdiv>\n      )}\n\n      {error && \u003Cdiv className=\"text-red-500\">{error.message}\u003C\u002Fdiv>}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Full API Reference\n\n```typescript\nconst {\n  completion,         \u002F\u002F string - Current completion text\n  complete,           \u002F\u002F (prompt: string) => void - Trigger completion\n  setCompletion,      \u002F\u002F (completion: string) => void - Update completion\n  isLoading,          \u002F\u002F boolean - Is generating?\n  error,              \u002F\u002F Error | undefined - Error if any\n  stop,               \u002F\u002F () => void - Stop generation\n} = useCompletion({\n  api: '\u002Fapi\u002Fcompletion',\n  id: 'completion-1',\n\n  \u002F\u002F Callbacks\n  onFinish: (prompt, completion) => {},\n  onError: (error) => {},\n\n  \u002F\u002F Configuration\n  headers: {},\n  body: {},\n});\n```\n\n### API Route for useCompletion\n\n```typescript\n\u002F\u002F app\u002Fapi\u002Fcompletion\u002Froute.ts\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\n\nexport async function POST(req: Request) {\n  const { prompt } = await req.json();\n\n  const result = streamText({\n    model: openai('gpt-3.5-turbo'),\n    prompt,\n    maxOutputTokens: 500,\n  });\n\n  return result.toDataStreamResponse();\n}\n```\n\n---\n\n## useObject Hook - Complete Reference\n\n### Basic Usage\n\nStream structured data (e.g., forms, JSON objects) with live updates:\n\n```tsx\n'use client';\nimport { useObject } from 'ai\u002Freact';\nimport { z } from 'zod';\n\nconst recipeSchema = z.object({\n  recipe: z.object({\n    name: z.string(),\n    ingredients: z.array(z.string()),\n    instructions: z.array(z.string()),\n  }),\n});\n\nexport default function RecipeGenerator() {\n  const { object, submit, isLoading, error } = useObject({\n    api: '\u002Fapi\u002Frecipe',\n    schema: recipeSchema,\n  });\n\n  return (\n    \u003Cdiv>\n      \u003Cbutton onClick={() => submit('pasta carbonara')} disabled={isLoading}>\n        Generate Recipe\n      \u003C\u002Fbutton>\n\n      {isLoading && \u003Cdiv>Generating recipe...\u003C\u002Fdiv>}\n\n      {object?.recipe && (\n        \u003Cdiv className=\"mt-4\">\n          \u003Ch2 className=\"text-2xl font-bold\">{object.recipe.name}\u003C\u002Fh2>\n\n          \u003Ch3 className=\"text-xl mt-4\">Ingredients:\u003C\u002Fh3>\n          \u003Cul>\n            {object.recipe.ingredients?.map((ingredient, idx) => (\n              \u003Cli key={idx}>{ingredient}\u003C\u002Fli>\n            ))}\n          \u003C\u002Ful>\n\n          \u003Ch3 className=\"text-xl mt-4\">Instructions:\u003C\u002Fh3>\n          \u003Col>\n            {object.recipe.instructions?.map((step, idx) => (\n              \u003Cli key={idx}>{step}\u003C\u002Fli>\n            ))}\n          \u003C\u002Fol>\n        \u003C\u002Fdiv>\n      )}\n\n      {error && \u003Cdiv className=\"text-red-500\">{error.message}\u003C\u002Fdiv>}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Full API Reference\n\n```typescript\nconst {\n  object,             \u002F\u002F Partial\u003CT> - Partial object (updates as stream progresses)\n  submit,             \u002F\u002F (input: string) => void - Trigger generation\n  isLoading,          \u002F\u002F boolean - Is generating?\n  error,              \u002F\u002F Error | undefined - Error if any\n  stop,               \u002F\u002F () => void - Stop generation\n} = useObject({\n  api: '\u002Fapi\u002Fobject',\n  schema: zodSchema,  \u002F\u002F Zod schema\n\n  \u002F\u002F Callbacks\n  onFinish: (object) => {},\n  onError: (error) => {},\n});\n```\n\n### API Route for useObject\n\n```typescript\n\u002F\u002F app\u002Fapi\u002Frecipe\u002Froute.ts\nimport { streamObject } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\nimport { z } from 'zod';\n\nexport async function POST(req: Request) {\n  const { prompt } = await req.json();\n\n  const result = streamObject({\n    model: openai('gpt-4'),\n    schema: z.object({\n      recipe: z.object({\n        name: z.string(),\n        ingredients: z.array(z.string()),\n        instructions: z.array(z.string()),\n      }),\n    }),\n    prompt: `Generate a recipe for ${prompt}`,\n  });\n\n  return result.toTextStreamResponse();\n}\n```\n\n---\n\n## Next.js Integration\n\n### App Router Complete Example\n\n**Directory Structure:**\n```\napp\u002F\n├── api\u002F\n│   └── chat\u002F\n│       └── route.ts      # Chat API endpoint\n├── chat\u002F\n│   └── page.tsx          # Chat page\n└── layout.tsx\n```\n\n**Chat Page:**\n```tsx\n\u002F\u002F app\u002Fchat\u002Fpage.tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent, useRef, useEffect } from 'react';\n\nexport default function ChatPage() {\n  const { messages, sendMessage, isLoading, error } = useChat({\n    api: '\u002Fapi\u002Fchat',\n  });\n  const [input, setInput] = useState('');\n  const messagesEndRef = useRef\u003CHTMLDivElement>(null);\n\n  \u002F\u002F Auto-scroll to bottom\n  useEffect(() => {\n    messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });\n  }, [messages]);\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    if (!input.trim()) return;\n\n    sendMessage({ content: input });\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv className=\"flex flex-col h-screen max-w-2xl mx-auto\">\n      {\u002F* Messages *\u002F}\n      \u003Cdiv className=\"flex-1 overflow-y-auto p-4 space-y-4\">\n        {messages.map(message => (\n          \u003Cdiv\n            key={message.id}\n            className={`flex ${\n              message.role === 'user' ? 'justify-end' : 'justify-start'\n            }`}\n          >\n            \u003Cdiv\n              className={`max-w-[70%] p-3 rounded-lg ${\n                message.role === 'user'\n                  ? 'bg-blue-500 text-white'\n                  : 'bg-gray-200 text-gray-900'\n              }`}\n            >\n              {message.content}\n            \u003C\u002Fdiv>\n          \u003C\u002Fdiv>\n        ))}\n        {isLoading && (\n          \u003Cdiv className=\"flex justify-start\">\n            \u003Cdiv className=\"bg-gray-200 p-3 rounded-lg\">\n              \u003Cdiv className=\"flex space-x-2\">\n                \u003Cdiv className=\"w-2 h-2 bg-gray-500 rounded-full animate-bounce\">\u003C\u002Fdiv>\n                \u003Cdiv className=\"w-2 h-2 bg-gray-500 rounded-full animate-bounce delay-100\">\u003C\u002Fdiv>\n                \u003Cdiv className=\"w-2 h-2 bg-gray-500 rounded-full animate-bounce delay-200\">\u003C\u002Fdiv>\n              \u003C\u002Fdiv>\n            \u003C\u002Fdiv>\n          \u003C\u002Fdiv>\n        )}\n        \u003Cdiv ref={messagesEndRef} \u002F>\n      \u003C\u002Fdiv>\n\n      {\u002F* Error *\u002F}\n      {error && (\n        \u003Cdiv className=\"p-4 bg-red-50 border-t border-red-200 text-red-700\">\n          Error: {error.message}\n        \u003C\u002Fdiv>\n      )}\n\n      {\u002F* Input *\u002F}\n      \u003Cform onSubmit={handleSubmit} className=\"p-4 border-t\">\n        \u003Cdiv className=\"flex space-x-2\">\n          \u003Cinput\n            value={input}\n            onChange={(e) => setInput(e.target.value)}\n            placeholder=\"Type a message...\"\n            disabled={isLoading}\n            className=\"flex-1 p-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500\"\n          \u002F>\n          \u003Cbutton\n            type=\"submit\"\n            disabled={isLoading || !input.trim()}\n            className=\"px-4 py-2 bg-blue-500 text-white rounded-lg disabled:bg-gray-300 disabled:cursor-not-allowed\"\n          >\n            Send\n          \u003C\u002Fbutton>\n        \u003C\u002Fdiv>\n      \u003C\u002Fform>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n**API Route:**\n```typescript\n\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\n\nexport async function POST(req: Request) {\n  const { messages } = await req.json();\n\n  const result = streamText({\n    model: openai('gpt-4-turbo'),\n    messages,\n    system: 'You are a helpful AI assistant.',\n    maxOutputTokens: 1000,\n  });\n\n  return result.toDataStreamResponse();\n}\n```\n\n### Pages Router Complete Example\n\n**Directory Structure:**\n```\npages\u002F\n├── api\u002F\n│   └── chat.ts           # Chat API endpoint\n└── chat.tsx              # Chat page\n```\n\n**Chat Page:**\n```tsx\n\u002F\u002F pages\u002Fchat.tsx\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function ChatPage() {\n  const { messages, sendMessage, isLoading } = useChat({\n    api: '\u002Fapi\u002Fchat',\n  });\n  const [input, setInput] = useState('');\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    sendMessage({ content: input });\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv className=\"container mx-auto p-4\">\n      \u003Ch1 className=\"text-2xl font-bold mb-4\">AI Chat\u003C\u002Fh1>\n\n      \u003Cdiv className=\"border rounded p-4 h-96 overflow-y-auto mb-4\">\n        {messages.map(m => (\n          \u003Cdiv key={m.id} className=\"mb-4\">\n            \u003Cstrong>{m.role === 'user' ? 'You' : 'AI'}:\u003C\u002Fstrong> {m.content}\n          \u003C\u002Fdiv>\n        ))}\n      \u003C\u002Fdiv>\n\n      \u003Cform onSubmit={handleSubmit} className=\"flex space-x-2\">\n        \u003Cinput\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n          placeholder=\"Type a message...\"\n          disabled={isLoading}\n          className=\"flex-1 p-2 border rounded\"\n        \u002F>\n        \u003Cbutton\n          type=\"submit\"\n          disabled={isLoading}\n          className=\"px-4 py-2 bg-blue-500 text-white rounded\"\n        >\n          Send\n        \u003C\u002Fbutton>\n      \u003C\u002Fform>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n**API Route:**\n```typescript\n\u002F\u002F pages\u002Fapi\u002Fchat.ts\nimport type { NextApiRequest, NextApiResponse } from 'next';\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const { messages } = req.body;\n\n  const result = streamText({\n    model: openai('gpt-4-turbo'),\n    messages,\n  });\n\n  \u002F\u002F Pages Router uses pipeDataStreamToResponse\n  return result.pipeDataStreamToResponse(res);\n}\n```\n\n**Key Difference**: App Router uses `toDataStreamResponse()`, Pages Router uses `pipeDataStreamToResponse()`.\n\n---\n\n## Top UI Errors & Solutions\n\nSee `references\u002Ftop-ui-errors.md` for complete documentation. Quick reference:\n\n### 1. useChat Failed to Parse Stream\n\n**Error**: `SyntaxError: Unexpected token in JSON at position X`\n\n**Cause**: API route not returning proper stream format.\n\n**Solution**:\n```typescript\n\u002F\u002F ✅ CORRECT\nreturn result.toDataStreamResponse();\n\n\u002F\u002F ❌ WRONG\nreturn new Response(result.textStream);\n```\n\n### 2. useChat No Response\n\n**Cause**: API route not streaming correctly.\n\n**Solution**:\n```typescript\n\u002F\u002F App Router - use toDataStreamResponse()\nexport async function POST(req: Request) {\n  const result = streamText({ \u002F* ... *\u002F });\n  return result.toDataStreamResponse(); \u002F\u002F ✅\n}\n\n\u002F\u002F Pages Router - use pipeDataStreamToResponse()\nexport default async function handler(req, res) {\n  const result = streamText({ \u002F* ... *\u002F });\n  return result.pipeDataStreamToResponse(res); \u002F\u002F ✅\n}\n```\n\n### 3. Streaming Not Working When Deployed\n\n**Cause**: Deployment platform buffering responses.\n\n**Solution**: Vercel auto-detects streaming. Other platforms may need configuration.\n\n### 4. Stale Body Values with useChat\n\n**Cause**: `body` option captured at first render only.\n\n**Solution**:\n```typescript\n\u002F\u002F ❌ WRONG - body captured once\nconst { userId } = useUser();\nconst { messages } = useChat({\n  body: { userId },  \u002F\u002F Stale!\n});\n\n\u002F\u002F ✅ CORRECT - use controlled mode\nconst { userId } = useUser();\nconst { messages, sendMessage } = useChat();\n\nsendMessage({\n  content: input,\n  data: { userId },  \u002F\u002F Fresh on each send\n});\n```\n\n### 5. React Maximum Update Depth\n\n**Cause**: Infinite loop in useEffect.\n\n**Solution**:\n```typescript\n\u002F\u002F ❌ WRONG\nuseEffect(() => {\n  saveMessages(messages);\n}, [messages, saveMessages]); \u002F\u002F saveMessages triggers re-render!\n\n\u002F\u002F ✅ CORRECT\nuseEffect(() => {\n  saveMessages(messages);\n}, [messages]); \u002F\u002F Only depend on messages\n```\n\nSee `references\u002Ftop-ui-errors.md` for 7 more common errors.\n\n---\n\n## Streaming Best Practices\n\n### Performance\n\n**Always use streaming for better UX:**\n```tsx\n\u002F\u002F ✅ GOOD - Streaming (shows tokens as they arrive)\nconst { messages } = useChat({ api: '\u002Fapi\u002Fchat' });\n\n\u002F\u002F ❌ BAD - Non-streaming (user waits for full response)\nconst response = await fetch('\u002Fapi\u002Fchat', { method: 'POST' });\n```\n\n### UX Patterns\n\n**Show loading states:**\n```tsx\n{isLoading && \u003Cdiv>AI is typing...\u003C\u002Fdiv>}\n```\n\n**Provide stop button:**\n```tsx\n{isLoading && \u003Cbutton onClick={stop}>Stop\u003C\u002Fbutton>}\n```\n\n**Auto-scroll to latest message:**\n```tsx\nuseEffect(() => {\n  messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });\n}, [messages]);\n```\n\n**Disable input while loading:**\n```tsx\n\u003Cinput disabled={isLoading} \u002F>\n```\n\nSee `references\u002Fstreaming-patterns.md` for comprehensive best practices.\n\n---\n\n## When to Use This Skill\n\n### Use ai-sdk-ui When:\n- Building React chat interfaces\n- Implementing AI completions in UI\n- Streaming AI responses to frontend\n- Building Next.js AI applications\n- Handling chat message state\n- Displaying tool calls in UI\n- Managing file attachments with AI\n- Migrating from v4 to v5 (UI hooks)\n- Encountering useChat\u002FuseCompletion errors\n\n### Don't Use When:\n- Need backend AI functionality → Use **ai-sdk-core** instead\n- Building non-React frontends (Svelte, Vue) → Check official docs\n- Need Generative UI \u002F RSC → See https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-rsc\n- Building native apps → Different SDK required\n\n### Related Skills:\n- **ai-sdk-core** - Backend text generation, structured output, tools, agents\n- Compose both for full-stack AI applications\n\n---\n\n## Package Versions\n\n**Required:**\n```json\n{\n  \"dependencies\": {\n    \"ai\": \"^5.0.76\",\n    \"@ai-sdk\u002Fopenai\": \"^2.0.53\",\n    \"react\": \"^18.2.0\",\n    \"zod\": \"^3.23.8\"\n  }\n}\n```\n\n**Next.js:**\n```json\n{\n  \"dependencies\": {\n    \"next\": \"^14.0.0\",\n    \"react\": \"^18.2.0\",\n    \"react-dom\": \"^18.2.0\"\n  }\n}\n```\n\n**Version Notes:**\n- AI SDK v5.0.76+ (stable)\n- React 18+ (React 19 supported)\n- Next.js 14+ recommended (13.4+ works)\n- Zod 3.23.8+ for schema validation\n\n---\n\n## Links to Official Documentation\n\n**Core UI Hooks:**\n- AI SDK UI Overview: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Foverview\n- useChat: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fchatbot\n- useCompletion: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fcompletion\n- useObject: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fobject-generation\n\n**Advanced Topics (Link Only):**\n- Generative UI (RSC): https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-rsc\u002Foverview\n- Stream Protocols: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fstream-protocols\n- Message Metadata: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fmessage-metadata\n\n**Next.js Integration:**\n- Next.js App Router: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fgetting-started\u002Fnextjs-app-router\n- Next.js Pages Router: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fgetting-started\u002Fnextjs-pages-router\n\n**Migration & Troubleshooting:**\n- v4→v5 Migration: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fmigration-guides\u002Fmigration-guide-5-0\n- Troubleshooting: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Ftroubleshooting\n- Common Issues: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Ftroubleshooting\u002Fcommon-issues\n\n**Vercel Deployment:**\n- Vercel Functions: https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\n- Streaming on Vercel: https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fstreaming\n\n---\n\n## Templates\n\nThis skill includes the following templates in `templates\u002F`:\n\n1. **use-chat-basic.tsx** - Basic chat with manual input (v5 pattern)\n2. **use-chat-tools.tsx** - Chat with tool calling UI rendering\n3. **use-chat-attachments.tsx** - File attachments support\n4. **use-completion-basic.tsx** - Basic text completion\n5. **use-object-streaming.tsx** - Streaming structured data\n6. **nextjs-chat-app-router.tsx** - Next.js App Router complete example\n7. **nextjs-chat-pages-router.tsx** - Next.js Pages Router complete example\n8. **nextjs-api-route.ts** - API route for both App and Pages Router\n9. **message-persistence.tsx** - Save\u002Fload chat history\n10. **custom-message-renderer.tsx** - Custom message components with markdown\n11. **package.json** - Dependencies template\n\n## Reference Documents\n\nSee `references\u002F` for:\n\n- **use-chat-migration.md** - Complete v4→v5 migration guide\n- **streaming-patterns.md** - UI streaming best practices\n- **top-ui-errors.md** - 12 common UI errors with solutions\n- **nextjs-integration.md** - Next.js setup patterns\n- **links-to-official-docs.md** - Organized links to official docs\n\n---\n\n**Production Tested**: WordPress Auditor (https:\u002F\u002Fwordpress-auditor.webfonts.workers.dev)\n**Last Updated**: 2025-10-22\n","# AI SDK UI - Frontend React Hooks\n\nFrontend React hooks for AI-powered user interfaces with Vercel AI SDK v5.\n\n**Version**: AI SDK v5.0.76+ (Stable)\n**Framework**: React 18+, Next.js 14+\n**Last Updated**: 2025-10-22\n\n---\n\n## Quick Start (5 Minutes)\n\n### Installation\n\n```bash\nnpm install ai @ai-sdk\u002Fopenai\n```\n\n### Basic Chat Component (v5)\n\n```tsx\n\u002F\u002F app\u002Fchat\u002Fpage.tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function Chat() {\n  const { messages, sendMessage, isLoading } = useChat({\n    api: '\u002Fapi\u002Fchat',\n  });\n  const [input, setInput] = useState('');\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    sendMessage({ content: input });\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv>\n      \u003Cdiv>\n        {messages.map(m => (\n          \u003Cdiv key={m.id}>\n            \u003Cstrong>{m.role}:\u003C\u002Fstrong> {m.content}\n          \u003C\u002Fdiv>\n        ))}\n      \u003C\u002Fdiv>\n      \u003Cform onSubmit={handleSubmit}>\n        \u003Cinput\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n          placeholder=\"Type a message...\"\n          disabled={isLoading}\n        \u002F>\n      \u003C\u002Fform>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### API Route (Next.js App Router)\n\n```typescript\n\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\n\nexport async function POST(req: Request) {\n  const { messages } = await req.json();\n\n  const result = streamText({\n    model: openai('gpt-4-turbo'),\n    messages,\n  });\n\n  return result.toDataStreamResponse();\n}\n```\n\n**Result**: A functional chat interface with streaming AI responses in ~10 lines of frontend code.\n\n---\n\n## useChat Hook - Complete Reference\n\n### Basic Usage (v5 Pattern)\n\n```tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function ChatComponent() {\n  const { messages, sendMessage, isLoading, error } = useChat({\n    api: '\u002Fapi\u002Fchat',\n  });\n  const [input, setInput] = useState('');\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    if (!input.trim()) return;\n\n    sendMessage({ content: input });\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv className=\"flex flex-col h-screen\">\n      {\u002F* Messages *\u002F}\n      \u003Cdiv className=\"flex-1 overflow-y-auto p-4\">\n        {messages.map(message => (\n          \u003Cdiv\n            key={message.id}\n            className={message.role === 'user' ? 'text-right' : 'text-left'}\n          >\n            \u003Cdiv className=\"inline-block p-2 rounded bg-gray-100\">\n              {message.content}\n            \u003C\u002Fdiv>\n          \u003C\u002Fdiv>\n        ))}\n        {isLoading && \u003Cdiv className=\"text-gray-500\">AI is thinking...\u003C\u002Fdiv>}\n      \u003C\u002Fdiv>\n\n      {\u002F* Input *\u002F}\n      \u003Cform onSubmit={handleSubmit} className=\"p-4 border-t\">\n        \u003Cinput\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n          placeholder=\"Type a message...\"\n          disabled={isLoading}\n          className=\"w-full p-2 border rounded\"\n        \u002F>\n      \u003C\u002Fform>\n\n      {\u002F* Error *\u002F}\n      {error && \u003Cdiv className=\"text-red-500 p-4\">{error.message}\u003C\u002Fdiv>}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Full API Reference\n\n```typescript\nconst {\n  \u002F\u002F Messages\n  messages,           \u002F\u002F Message[] - Chat history\n  setMessages,        \u002F\u002F (messages: Message[]) => void - Update messages\n\n  \u002F\u002F Actions\n  sendMessage,        \u002F\u002F (message: { content: string }) => void - Send message (v5)\n  reload,             \u002F\u002F () => void - Reload last response\n  stop,               \u002F\u002F () => void - Stop current generation\n\n  \u002F\u002F State\n  isLoading,          \u002F\u002F boolean - Is AI responding?\n  error,              \u002F\u002F Error | undefined - Error if any\n\n  \u002F\u002F Data\n  data,               \u002F\u002F any[] - Custom data from stream\n  metadata,           \u002F\u002F object - Response metadata\n} = useChat({\n  \u002F\u002F Required\n  api: '\u002Fapi\u002Fchat',   \u002F\u002F API endpoint\n\n  \u002F\u002F Optional\n  id: 'chat-1',       \u002F\u002F Chat ID for persistence\n  initialMessages: [], \u002F\u002F Initial messages (controlled mode)\n\n  \u002F\u002F Callbacks\n  onFinish: (message, options) => {},  \u002F\u002F Called when response completes\n  onError: (error) => {},              \u002F\u002F Called on error\n\n  \u002F\u002F Configuration\n  headers: {},        \u002F\u002F Custom headers\n  body: {},           \u002F\u002F Additional body data\n  credentials: 'same-origin', \u002F\u002F Fetch credentials\n\n  \u002F\u002F Streaming\n  streamProtocol: 'data', \u002F\u002F 'data' | 'text' (default: 'data')\n});\n```\n\n### v4 → v5 Breaking Changes\n\n**CRITICAL: useChat no longer manages input state in v5!**\n\n**v4 (OLD - DON'T USE):**\n```tsx\nconst { messages, input, handleInputChange, handleSubmit, append } = useChat();\n\n\u003Cform onSubmit={handleSubmit}>\n  \u003Cinput value={input} onChange={handleInputChange} \u002F>\n\u003C\u002Fform>\n```\n\n**v5 (NEW - CORRECT):**\n```tsx\nconst { messages, sendMessage } = useChat();\nconst [input, setInput] = useState('');\n\n\u003Cform onSubmit={(e) => {\n  e.preventDefault();\n  sendMessage({ content: input });\n  setInput('');\n}}>\n  \u003Cinput value={input} onChange={(e) => setInput(e.target.value)} \u002F>\n\u003C\u002Fform>\n```\n\n**Summary of v5 Changes:**\n1. **Input management removed**: `input`, `handleInputChange`, `handleSubmit` no longer exist\n2. **`append()` → `sendMessage()`**: New method for sending messages\n3. **`onResponse` removed**: Use `onFinish` instead\n4. **`initialMessages` → controlled mode**: Use `messages` prop for full control\n5. **`maxSteps` removed**: Handle on server-side only\n\nSee `references\u002Fuse-chat-migration.md` for complete migration guide.\n\n### Tool Calling in UI\n\nWhen your API uses tools, useChat automatically handles tool invocations in the message stream:\n\n```tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\n\nexport default function ChatWithTools() {\n  const { messages } = useChat({ api: '\u002Fapi\u002Fchat' });\n\n  return (\n    \u003Cdiv>\n      {messages.map(message => (\n        \u003Cdiv key={message.id}>\n          {\u002F* Text content *\u002F}\n          {message.content && \u003Cp>{message.content}\u003C\u002Fp>}\n\n          {\u002F* Tool invocations *\u002F}\n          {message.toolInvocations?.map((tool, idx) => (\n            \u003Cdiv key={idx} className=\"bg-blue-50 p-2 rounded my-2\">\n              \u003Cdiv className=\"font-bold\">Tool: {tool.toolName}\u003C\u002Fdiv>\n              \u003Cdiv className=\"text-sm\">\n                \u003Cstrong>Args:\u003C\u002Fstrong> {JSON.stringify(tool.args, null, 2)}\n              \u003C\u002Fdiv>\n              {tool.result && (\n                \u003Cdiv className=\"text-sm\">\n                  \u003Cstrong>Result:\u003C\u002Fstrong> {JSON.stringify(tool.result, null, 2)}\n                \u003C\u002Fdiv>\n              )}\n            \u003C\u002Fdiv>\n          ))}\n        \u003C\u002Fdiv>\n      ))}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### File Attachments\n\nUpload files (images, PDFs, etc.) alongside messages:\n\n```tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function ChatWithAttachments() {\n  const { messages, sendMessage, isLoading } = useChat({ api: '\u002Fapi\u002Fchat' });\n  const [input, setInput] = useState('');\n  const [files, setFiles] = useState\u003CFileList | null>(null);\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n\n    sendMessage({\n      content: input,\n      experimental_attachments: files\n        ? Array.from(files).map(file => ({\n            name: file.name,\n            contentType: file.type,\n            url: URL.createObjectURL(file),\n          }))\n        : undefined,\n    });\n\n    setInput('');\n    setFiles(null);\n  };\n\n  return (\n    \u003Cdiv>\n      {\u002F* Messages *\u002F}\n      {messages.map(m => (\n        \u003Cdiv key={m.id}>\n          {m.content}\n          {m.experimental_attachments?.map((att, idx) => (\n            \u003Cdiv key={idx}>\n              \u003Cimg src={att.url} alt={att.name} \u002F>\n            \u003C\u002Fdiv>\n          ))}\n        \u003C\u002Fdiv>\n      ))}\n\n      {\u002F* Input *\u002F}\n      \u003Cform onSubmit={handleSubmit}>\n        \u003Cinput\n          type=\"file\"\n          multiple\n          onChange={(e) => setFiles(e.target.files)}\n          accept=\"image\u002F*\"\n        \u002F>\n        \u003Cinput\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n        \u002F>\n        \u003Cbutton type=\"submit\" disabled={isLoading}>Send\u003C\u002Fbutton>\n      \u003C\u002Fform>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Message Persistence\n\nSave and load chat history to localStorage:\n\n```tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useEffect } from 'react';\n\nexport default function PersistentChat() {\n  const chatId = 'my-chat-1';\n\n  const { messages, setMessages, sendMessage } = useChat({\n    api: '\u002Fapi\u002Fchat',\n    id: chatId,\n    initialMessages: loadMessages(chatId),\n  });\n\n  \u002F\u002F Save messages whenever they change\n  useEffect(() => {\n    saveMessages(chatId, messages);\n  }, [messages, chatId]);\n\n  return (\n    \u003Cdiv>\n      {messages.map(m => (\n        \u003Cdiv key={m.id}>{m.role}: {m.content}\u003C\u002Fdiv>\n      ))}\n      {\u002F* Input form... *\u002F}\n    \u003C\u002Fdiv>\n  );\n}\n\n\u002F\u002F Helper functions\nfunction loadMessages(chatId: string) {\n  const stored = localStorage.getItem(`chat-${chatId}`);\n  return stored ? JSON.parse(stored) : [];\n}\n\nfunction saveMessages(chatId: string, messages: any[]) {\n  localStorage.setItem(`chat-${chatId}`, JSON.stringify(messages));\n}\n```\n\n---\n\n## useCompletion Hook - Complete Reference\n\n### Basic Usage\n\n```tsx\n'use client';\nimport { useCompletion } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function Completion() {\n  const { completion, complete, isLoading, error } = useCompletion({\n    api: '\u002Fapi\u002Fcompletion',\n  });\n  const [input, setInput] = useState('');\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    complete(input);\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv>\n      \u003Cform onSubmit={handleSubmit}>\n        \u003Ctextarea\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n          placeholder=\"Enter a prompt...\"\n          rows={4}\n          className=\"w-full p-2 border rounded\"\n        \u002F>\n        \u003Cbutton type=\"submit\" disabled={isLoading}>\n          {isLoading ? 'Generating...' : 'Generate'}\n        \u003C\u002Fbutton>\n      \u003C\u002Fform>\n\n      {completion && (\n        \u003Cdiv className=\"mt-4 p-4 bg-gray-50 rounded\">\n          \u003Ch3>Result:\u003C\u002Fh3>\n          \u003Cp>{completion}\u003C\u002Fp>\n        \u003C\u002Fdiv>\n      )}\n\n      {error && \u003Cdiv className=\"text-red-500\">{error.message}\u003C\u002Fdiv>}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Full API Reference\n\n```typescript\nconst {\n  completion,         \u002F\u002F string - Current completion text\n  complete,           \u002F\u002F (prompt: string) => void - Trigger completion\n  setCompletion,      \u002F\u002F (completion: string) => void - Update completion\n  isLoading,          \u002F\u002F boolean - Is generating?\n  error,              \u002F\u002F Error | undefined - Error if any\n  stop,               \u002F\u002F () => void - Stop generation\n} = useCompletion({\n  api: '\u002Fapi\u002Fcompletion',\n  id: 'completion-1',\n\n  \u002F\u002F Callbacks\n  onFinish: (prompt, completion) => {},\n  onError: (error) => {},\n\n  \u002F\u002F Configuration\n  headers: {},\n  body: {},\n});\n```\n\n### API Route for useCompletion\n\n```typescript\n\u002F\u002F app\u002Fapi\u002Fcompletion\u002Froute.ts\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\n\nexport async function POST(req: Request) {\n  const { prompt } = await req.json();\n\n  const result = streamText({\n    model: openai('gpt-3.5-turbo'),\n    prompt,\n    maxOutputTokens: 500,\n  });\n\n  return result.toDataStreamResponse();\n}\n```\n\n---\n\n## useObject Hook - Complete Reference\n\n### Basic Usage\n\nStream structured data (e.g., forms, JSON objects) with live updates:\n\n```tsx\n'use client';\nimport { useObject } from 'ai\u002Freact';\nimport { z } from 'zod';\n\nconst recipeSchema = z.object({\n  recipe: z.object({\n    name: z.string(),\n    ingredients: z.array(z.string()),\n    instructions: z.array(z.string()),\n  }),\n});\n\nexport default function RecipeGenerator() {\n  const { object, submit, isLoading, error } = useObject({\n    api: '\u002Fapi\u002Frecipe',\n    schema: recipeSchema,\n  });\n\n  return (\n    \u003Cdiv>\n      \u003Cbutton onClick={() => submit('pasta carbonara')} disabled={isLoading}>\n        Generate Recipe\n      \u003C\u002Fbutton>\n\n      {isLoading && \u003Cdiv>Generating recipe...\u003C\u002Fdiv>}\n\n      {object?.recipe && (\n        \u003Cdiv className=\"mt-4\">\n          \u003Ch2 className=\"text-2xl font-bold\">{object.recipe.name}\u003C\u002Fh2>\n\n          \u003Ch3 className=\"text-xl mt-4\">Ingredients:\u003C\u002Fh3>\n          \u003Cul>\n            {object.recipe.ingredients?.map((ingredient, idx) => (\n              \u003Cli key={idx}>{ingredient}\u003C\u002Fli>\n            ))}\n          \u003C\u002Ful>\n\n          \u003Ch3 className=\"text-xl mt-4\">Instructions:\u003C\u002Fh3>\n          \u003Col>\n            {object.recipe.instructions?.map((step, idx) => (\n              \u003Cli key={idx}>{step}\u003C\u002Fli>\n            ))}\n          \u003C\u002Fol>\n        \u003C\u002Fdiv>\n      )}\n\n      {error && \u003Cdiv className=\"text-red-500\">{error.message}\u003C\u002Fdiv>}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Full API Reference\n\n```typescript\nconst {\n  object,             \u002F\u002F Partial\u003CT> - Partial object (updates as stream progresses)\n  submit,             \u002F\u002F (input: string) => void - Trigger generation\n  isLoading,          \u002F\u002F boolean - Is generating?\n  error,              \u002F\u002F Error | undefined - Error if any\n  stop,               \u002F\u002F () => void - Stop generation\n} = useObject({\n  api: '\u002Fapi\u002Fobject',\n  schema: zodSchema,  \u002F\u002F Zod schema\n\n  \u002F\u002F Callbacks\n  onFinish: (object) => {},\n  onError: (error) => {},\n});\n```\n\n### API Route for useObject\n\n```typescript\n\u002F\u002F app\u002Fapi\u002Frecipe\u002Froute.ts\nimport { streamObject } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\nimport { z } from 'zod';\n\nexport async function POST(req: Request) {\n  const { prompt } = await req.json();\n\n  const result = streamObject({\n    model: openai('gpt-4'),\n    schema: z.object({\n      recipe: z.object({\n        name: z.string(),\n        ingredients: z.array(z.string()),\n        instructions: z.array(z.string()),\n      }),\n    }),\n    prompt: `Generate a recipe for ${prompt}`,\n  });\n\n  return result.toTextStreamResponse();\n}\n```\n\n---\n\n## Next.js Integration\n\n### App Router Complete Example\n\n**Directory Structure:**\n```\napp\u002F\n├── api\u002F\n│   └── chat\u002F\n│       └── route.ts      # Chat API endpoint\n├── chat\u002F\n│   └── page.tsx          # Chat page\n└── layout.tsx\n```\n\n**Chat Page:**\n```tsx\n\u002F\u002F app\u002Fchat\u002Fpage.tsx\n'use client';\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent, useRef, useEffect } from 'react';\n\nexport default function ChatPage() {\n  const { messages, sendMessage, isLoading, error } = useChat({\n    api: '\u002Fapi\u002Fchat',\n  });\n  const [input, setInput] = useState('');\n  const messagesEndRef = useRef\u003CHTMLDivElement>(null);\n\n  \u002F\u002F Auto-scroll to bottom\n  useEffect(() => {\n    messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });\n  }, [messages]);\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    if (!input.trim()) return;\n\n    sendMessage({ content: input });\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv className=\"flex flex-col h-screen max-w-2xl mx-auto\">\n      {\u002F* Messages *\u002F}\n      \u003Cdiv className=\"flex-1 overflow-y-auto p-4 space-y-4\">\n        {messages.map(message => (\n          \u003Cdiv\n            key={message.id}\n            className={`flex ${\n              message.role === 'user' ? 'justify-end' : 'justify-start'\n            }`}\n          >\n            \u003Cdiv\n              className={`max-w-[70%] p-3 rounded-lg ${\n                message.role === 'user'\n                  ? 'bg-blue-500 text-white'\n                  : 'bg-gray-200 text-gray-900'\n              }`}\n            >\n              {message.content}\n            \u003C\u002Fdiv>\n          \u003C\u002Fdiv>\n        ))}\n        {isLoading && (\n          \u003Cdiv className=\"flex justify-start\">\n            \u003Cdiv className=\"bg-gray-200 p-3 rounded-lg\">\n              \u003Cdiv className=\"flex space-x-2\">\n                \u003Cdiv className=\"w-2 h-2 bg-gray-500 rounded-full animate-bounce\">\u003C\u002Fdiv>\n                \u003Cdiv className=\"w-2 h-2 bg-gray-500 rounded-full animate-bounce delay-100\">\u003C\u002Fdiv>\n                \u003Cdiv className=\"w-2 h-2 bg-gray-500 rounded-full animate-bounce delay-200\">\u003C\u002Fdiv>\n              \u003C\u002Fdiv>\n            \u003C\u002Fdiv>\n          \u003C\u002Fdiv>\n        )}\n        \u003Cdiv ref={messagesEndRef} \u002F>\n      \u003C\u002Fdiv>\n\n      {\u002F* Error *\u002F}\n      {error && (\n        \u003Cdiv className=\"p-4 bg-red-50 border-t border-red-200 text-red-700\">\n          Error: {error.message}\n        \u003C\u002Fdiv>\n      )}\n\n      {\u002F* Input *\u002F}\n      \u003Cform onSubmit={handleSubmit} className=\"p-4 border-t\">\n        \u003Cdiv className=\"flex space-x-2\">\n          \u003Cinput\n            value={input}\n            onChange={(e) => setInput(e.target.value)}\n            placeholder=\"Type a message...\"\n            disabled={isLoading}\n            className=\"flex-1 p-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500\"\n          \u002F>\n          \u003Cbutton\n            type=\"submit\"\n            disabled={isLoading || !input.trim()}\n            className=\"px-4 py-2 bg-blue-500 text-white rounded-lg disabled:bg-gray-300 disabled:cursor-not-allowed\"\n          >\n            Send\n          \u003C\u002Fbutton>\n        \u003C\u002Fdiv>\n      \u003C\u002Fform>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n**API Route:**\n```typescript\n\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\n\nexport async function POST(req: Request) {\n  const { messages } = await req.json();\n\n  const result = streamText({\n    model: openai('gpt-4-turbo'),\n    messages,\n    system: 'You are a helpful AI assistant.',\n    maxOutputTokens: 1000,\n  });\n\n  return result.toDataStreamResponse();\n}\n```\n\n### Pages Router Complete Example\n\n**Directory Structure:**\n```\npages\u002F\n├── api\u002F\n│   └── chat.ts           # Chat API endpoint\n└── chat.tsx              # Chat page\n```\n\n**Chat Page:**\n```tsx\n\u002F\u002F pages\u002Fchat.tsx\nimport { useChat } from 'ai\u002Freact';\nimport { useState, FormEvent } from 'react';\n\nexport default function ChatPage() {\n  const { messages, sendMessage, isLoading } = useChat({\n    api: '\u002Fapi\u002Fchat',\n  });\n  const [input, setInput] = useState('');\n\n  const handleSubmit = (e: FormEvent) => {\n    e.preventDefault();\n    sendMessage({ content: input });\n    setInput('');\n  };\n\n  return (\n    \u003Cdiv className=\"container mx-auto p-4\">\n      \u003Ch1 className=\"text-2xl font-bold mb-4\">AI Chat\u003C\u002Fh1>\n\n      \u003Cdiv className=\"border rounded p-4 h-96 overflow-y-auto mb-4\">\n        {messages.map(m => (\n          \u003Cdiv key={m.id} className=\"mb-4\">\n            \u003Cstrong>{m.role === 'user' ? 'You' : 'AI'}:\u003C\u002Fstrong> {m.content}\n          \u003C\u002Fdiv>\n        ))}\n      \u003C\u002Fdiv>\n\n      \u003Cform onSubmit={handleSubmit} className=\"flex space-x-2\">\n        \u003Cinput\n          value={input}\n          onChange={(e) => setInput(e.target.value)}\n          placeholder=\"Type a message...\"\n          disabled={isLoading}\n          className=\"flex-1 p-2 border rounded\"\n        \u002F>\n        \u003Cbutton\n          type=\"submit\"\n          disabled={isLoading}\n          className=\"px-4 py-2 bg-blue-500 text-white rounded\"\n        >\n          Send\n        \u003C\u002Fbutton>\n      \u003C\u002Fform>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n**API Route:**\n```typescript\n\u002F\u002F pages\u002Fapi\u002Fchat.ts\nimport type { NextApiRequest, NextApiResponse } from 'next';\nimport { streamText } from 'ai';\nimport { openai } from '@ai-sdk\u002Fopenai';\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const { messages } = req.body;\n\n  const result = streamText({\n    model: openai('gpt-4-turbo'),\n    messages,\n  });\n\n  \u002F\u002F Pages Router uses pipeDataStreamToResponse\n  return result.pipeDataStreamToResponse(res);\n}\n```\n\n**Key Difference**: App Router uses `toDataStreamResponse()`, Pages Router uses `pipeDataStreamToResponse()`.\n\n---\n\n## Top UI Errors & Solutions\n\nSee `references\u002Ftop-ui-errors.md` for complete documentation. Quick reference:\n\n### 1. useChat Failed to Parse Stream\n\n**Error**: `SyntaxError: Unexpected token in JSON at position X`\n\n**Cause**: API route not returning proper stream format.\n\n**Solution**:\n```typescript\n\u002F\u002F ✅ CORRECT\nreturn result.toDataStreamResponse();\n\n\u002F\u002F ❌ WRONG\nreturn new Response(result.textStream);\n```\n\n### 2. useChat No Response\n\n**Cause**: API route not streaming correctly.\n\n**Solution**:\n```typescript\n\u002F\u002F App Router - use toDataStreamResponse()\nexport async function POST(req: Request) {\n  const result = streamText({ \u002F* ... *\u002F });\n  return result.toDataStreamResponse(); \u002F\u002F ✅\n}\n\n\u002F\u002F Pages Router - use pipeDataStreamToResponse()\nexport default async function handler(req, res) {\n  const result = streamText({ \u002F* ... *\u002F });\n  return result.pipeDataStreamToResponse(res); \u002F\u002F ✅\n}\n```\n\n### 3. Streaming Not Working When Deployed\n\n**Cause**: Deployment platform buffering responses.\n\n**Solution**: Vercel auto-detects streaming. Other platforms may need configuration.\n\n### 4. Stale Body Values with useChat\n\n**Cause**: `body` option captured at first render only.\n\n**Solution**:\n```typescript\n\u002F\u002F ❌ WRONG - body captured once\nconst { userId } = useUser();\nconst { messages } = useChat({\n  body: { userId },  \u002F\u002F Stale!\n});\n\n\u002F\u002F ✅ CORRECT - use controlled mode\nconst { userId } = useUser();\nconst { messages, sendMessage } = useChat();\n\nsendMessage({\n  content: input,\n  data: { userId },  \u002F\u002F Fresh on each send\n});\n```\n\n### 5. React Maximum Update Depth\n\n**Cause**: Infinite loop in useEffect.\n\n**Solution**:\n```typescript\n\u002F\u002F ❌ WRONG\nuseEffect(() => {\n  saveMessages(messages);\n}, [messages, saveMessages]); \u002F\u002F saveMessages triggers re-render!\n\n\u002F\u002F ✅ CORRECT\nuseEffect(() => {\n  saveMessages(messages);\n}, [messages]); \u002F\u002F Only depend on messages\n```\n\nSee `references\u002Ftop-ui-errors.md` for 7 more common errors.\n\n---\n\n## Streaming Best Practices\n\n### Performance\n\n**Always use streaming for better UX:**\n```tsx\n\u002F\u002F ✅ GOOD - Streaming (shows tokens as they arrive)\nconst { messages } = useChat({ api: '\u002Fapi\u002Fchat' });\n\n\u002F\u002F ❌ BAD - Non-streaming (user waits for full response)\nconst response = await fetch('\u002Fapi\u002Fchat', { method: 'POST' });\n```\n\n### UX Patterns\n\n**Show loading states:**\n```tsx\n{isLoading && \u003Cdiv>AI is typing...\u003C\u002Fdiv>}\n```\n\n**Provide stop button:**\n```tsx\n{isLoading && \u003Cbutton onClick={stop}>Stop\u003C\u002Fbutton>}\n```\n\n**Auto-scroll to latest message:**\n```tsx\nuseEffect(() => {\n  messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });\n}, [messages]);\n```\n\n**Disable input while loading:**\n```tsx\n\u003Cinput disabled={isLoading} \u002F>\n```\n\nSee `references\u002Fstreaming-patterns.md` for comprehensive best practices.\n\n---\n\n## When to Use This Skill\n\n### Use ai-sdk-ui When:\n- Building React chat interfaces\n- Implementing AI completions in UI\n- Streaming AI responses to frontend\n- Building Next.js AI applications\n- Handling chat message state\n- Displaying tool calls in UI\n- Managing file attachments with AI\n- Migrating from v4 to v5 (UI hooks)\n- Encountering useChat\u002FuseCompletion errors\n\n### Don't Use When:\n- Need backend AI functionality → Use **ai-sdk-core** instead\n- Building non-React frontends (Svelte, Vue) → Check official docs\n- Need Generative UI \u002F RSC → See https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-rsc\n- Building native apps → Different SDK required\n\n### Related Skills:\n- **ai-sdk-core** - Backend text generation, structured output, tools, agents\n- Compose both for full-stack AI applications\n\n---\n\n## Package Versions\n\n**Required:**\n```json\n{\n  \"dependencies\": {\n    \"ai\": \"^5.0.76\",\n    \"@ai-sdk\u002Fopenai\": \"^2.0.53\",\n    \"react\": \"^18.2.0\",\n    \"zod\": \"^3.23.8\"\n  }\n}\n```\n\n**Next.js:**\n```json\n{\n  \"dependencies\": {\n    \"next\": \"^14.0.0\",\n    \"react\": \"^18.2.0\",\n    \"react-dom\": \"^18.2.0\"\n  }\n}\n```\n\n**Version Notes:**\n- AI SDK v5.0.76+ (stable)\n- React 18+ (React 19 supported)\n- Next.js 14+ recommended (13.4+ works)\n- Zod 3.23.8+ for schema validation\n\n---\n\n## Links to Official Documentation\n\n**Core UI Hooks:**\n- AI SDK UI Overview: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Foverview\n- useChat: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fchatbot\n- useCompletion: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fcompletion\n- useObject: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fobject-generation\n\n**Advanced Topics (Link Only):**\n- Generative UI (RSC): https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-rsc\u002Foverview\n- Stream Protocols: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fstream-protocols\n- Message Metadata: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fmessage-metadata\n\n**Next.js Integration:**\n- Next.js App Router: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fgetting-started\u002Fnextjs-app-router\n- Next.js Pages Router: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fgetting-started\u002Fnextjs-pages-router\n\n**Migration & Troubleshooting:**\n- v4→v5 Migration: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fmigration-guides\u002Fmigration-guide-5-0\n- Troubleshooting: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Ftroubleshooting\n- Common Issues: https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Ftroubleshooting\u002Fcommon-issues\n\n**Vercel Deployment:**\n- Vercel Functions: https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\n- Streaming on Vercel: https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fstreaming\n\n---\n\n## Templates\n\nThis skill includes the following templates in `templates\u002F`:\n\n1. **use-chat-basic.tsx** - Basic chat with manual input (v5 pattern)\n2. **use-chat-tools.tsx** - Chat with tool calling UI rendering\n3. **use-chat-attachments.tsx** - File attachments support\n4. **use-completion-basic.tsx** - Basic text completion\n5. **use-object-streaming.tsx** - Streaming structured data\n6. **nextjs-chat-app-router.tsx** - Next.js App Router complete example\n7. **nextjs-chat-pages-router.tsx** - Next.js Pages Router complete example\n8. **nextjs-api-route.ts** - API route for both App and Pages Router\n9. **message-persistence.tsx** - Save\u002Fload chat history\n10. **custom-message-renderer.tsx** - Custom message components with markdown\n11. **package.json** - Dependencies template\n\n## Reference Documents\n\nSee `references\u002F` for:\n\n- **use-chat-migration.md** - Complete v4→v5 migration guide\n- **streaming-patterns.md** - UI streaming best practices\n- **top-ui-errors.md** - 12 common UI errors with solutions\n- **nextjs-integration.md** - Next.js setup patterns\n- **links-to-official-docs.md** - Organized links to official docs\n\n---\n\n**Production Tested**: WordPress Auditor (https:\u002F\u002Fwordpress-auditor.webfonts.workers.dev)\n**Last Updated**: 2025-10-22\n",{"name":5,"license":14,"description":23},"Frontend React hooks for AI-powered chat interfaces, completions, and streaming UIs with Vercel AI SDK v5.\nIncludes useChat, useCompletion, and useObject hooks for building interactive AI applications.\n\nUse when: building React chat interfaces, implementing AI completions in UI, streaming AI responses to frontend,\nhandling chat message state, building Next.js AI apps, managing file attachments with AI, or encountering\nerrors like \"useChat failed to parse stream\", \"useChat no response\", unclosed streams, or streaming issues.\n\nKeywords: ai sdk ui, useChat hook, useCompletion hook, useObject hook, react ai chat, ai chat interface,\nstreaming ai ui, nextjs ai chat, vercel ai ui, react streaming, ai sdk react, chat message state,\nai file attachments, message persistence, useChat error, streaming failed ui, parse stream error,\nuseChat no response, react ai hooks, nextjs app router ai, nextjs pages router ai\n","main","6b73b29e4866f997b1eb47fe8d9631396265fc24",0,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn","2026-09-09 16:06:07",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add davidanthonyn\u002Fagent-skills --skill ai-sdk-ui",{"tool":36,"command":37},"bunx","bunx skills add davidanthonyn\u002Fagent-skills --skill ai-sdk-ui",{"tool":39,"command":40},"pnpm","pnpm dlx skills add davidanthonyn\u002Fagent-skills --skill ai-sdk-ui","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fai-sdk-ui\u002FSKILL.md",true,[44,50,54],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"README.md","REFERENCE","参考文档",7622,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fai-sdk-ui\u002FREADME.md",{"path":51,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":52,"sourceHtmlUrl":53},"SKILL.json",29183,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fai-sdk-ui\u002FSKILL.json",{"path":55,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":58,"sourceHtmlUrl":59},"SKILL.md.backup","OTHER","其他",26671,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fai-sdk-ui\u002FSKILL.md.backup",[61,68,76,83,90,99],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M7AQNJDXVNVMN08N5BHBGZBF","zustand-state-management","Production-tested setup for Zustand state management in React applications with TypeScript.\nThis skill provides comprehensive patterns for building scalable, type-safe global state.\n\nUse when: setting up global state in React, migrating from Redux or Context API, implementing\nstate persistence with localStorage, configuring TypeScript with Zustand, using slices pattern\nfor modular stores, adding devtools middleware for debugging, handling Next.js SSR hydration,\nor encountering hydration errors, TypeScript inference issues, or persist middleware problems.\n\nPrevents 5 documented issues: Next.js hydration mismatches, TypeScript double parentheses\nsyntax errors, persist middleware export errors, infinite render loops, and slices pattern\ntype inference failures.\n\nKeywords: zustand, state management, React state, TypeScript state, persist middleware,\ndevtools, slices pattern, global state, React hooks, create store, useBoundStore,\nStateCreator, hydration error, text content mismatch, infinite render, localStorage,\nsessionStorage, immer middleware, shallow equality, selector pattern, zustand v5","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzustand-state-management\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":72,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M7AQN2DW9DTPM8BYNZSHQANC","zetic-mlange","Help users integrate the ZETIC Melange (MLange) on-device AI SDK into Android (Kotlin\u002FJava) and iOS (Swift) mobile apps. Use this skill whenever the user mentions Zetic, MLange, Melange, ZeticMLangeModel, ZeticMLangeLLMModel, ZeticMLangeHFModel, on-device NPU inference for mobile, or deploying ML models to Android\u002FiOS with NPU acceleration. Also trigger when users ask about running LLMs on-device with GGUF quantization, mobile NPU model deployment, or converting PyTorch\u002FONNX models for mobile inference. Covers general model inference, LLM inference (streaming token generation), and HuggingFace model loading.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M7AQMEK370FBPC75N2W8WA4W","youtube-downloader","Download videos, audio, playlists, and channels from YouTube and 1000+ websites using yt-dlp. Supports quality selection, format conversion, subtitle download, playlist filtering, metadata extraction, thumbnail download, and batch operations. Use when downloading YouTube videos in any quality (4K, 8K, HDR), extracting audio as MP3\u002FM4A\u002FFLAC, downloading entire playlists\u002Fchannels, getting subtitles in multiple languages, converting to specific formats, downloading live streams, archiving content, or batch processing multiple URLs. Optimized for reliability with automatic retries, rate limiting, and error handling.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fyoutube-downloader\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":18},"01M7AQHKQ4VQB04NH6BG4SV9Q7","wordpress-plugin-core","This skill provides comprehensive knowledge for WordPress plugin development, covering core patterns, security best practices, database interactions, hooks\u002Ffilters, Settings API, custom post types, REST API, and AJAX. This skill should be used when creating WordPress plugins, troubleshooting security issues, implementing custom post types\u002Ftaxonomies, building admin interfaces, or working with the WordPress database.\n\nUse when: Creating new WordPress plugins, implementing nonces\u002Fsanitization\u002Fescaping, working with $wpdb and prepared statements, building Settings API pages, registering custom post types or taxonomies, implementing REST API endpoints, handling AJAX requests, debugging plugin activation\u002Fdeactivation issues, preventing SQL injection\u002FXSS\u002FCSRF vulnerabilities.\n\nKeywords: wordpress plugin development, wordpress security, wordpress hooks, wordpress filters, wordpress database, wpdb prepare, sanitize_text_field, esc_html, wp_nonce, custom post type, register_post_type, settings api, rest api, admin-ajax, wordpress sql injection, wordpress xss, wordpress csrf, plugin header, activation hook, deactivation hook, wordpress coding standards, wordpress plugin architecture","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwordpress-plugin-core\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":94,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":18},"01M7AQH4JW8F2MJFS1C43TZ2TY","webapp-testing","Test local web applications with Playwright. Use when asked to verify frontend functionality, debug UI behavior, capture browser screenshots, or inspect browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":18},"01M7AQH0PWD6Z1NN66V15DT25M","web-performance-audit","Audit web performance using Chrome DevTools MCP. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fweb-performance-audit\u002FSKILL.md",[],[]]