ai-feature-architect

Implements streaming chat, tool calling, structured output, and RAG pipelines with Vercel AI SDK v6.

1|Updated May 4, 2026
One-click install
npx skills add https://github.com/Scardubu/SwarmXQ --skill ai-feature-architect-scardubu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-feature-architect
Source: https://github.com/Scardubu/SwarmXQ/tree/main/.ai/skills/ai-feature-architect
Command: npx skills add https://github.com/Scardubu/SwarmXQ --skill ai-feature-architect-scardubu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding AI capabilities to a web application involves many moving parts: streaming responses, tool calling, structured output validation, RAG over private documents, and multi-model routing. This Skill provides production-grade patterns for Vercel AI SDK v6 so you avoid outdated v3/v4 APIs and ship AI features with rate limiting, cost controls, and error handling built in. ## Core Features & Use Cases - Streaming Chat: Build Next.js chat endpoints with streamText and the useChat React hook, including rate limiting and token usage logging. - Structured Output & Tool Calling: Extract typed data with generateObject and Zod schemas, and let models take actions via tool calling with maxSteps limits. - RAG Pipelines: Ingest documents with embedMany, store vectors in pgvector, and answer questions with similarity-filtered retrieval. - Use Case: A user asks to "add a support chatbot that answers from our docs" — the Skill produces a streaming chat route, a pgvector-backed RAG pipeline, and a multi-model router that sends simple questions to a cheap model and complex ones to a stronger model. ## Quick Start Ask the AI to add a streaming chat feature to your Next.js app using Vercel AI SDK v6 with rate limiting and token usage logging.

Frequently Asked Questions about ai-feature-architect

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add streaming chat to a Next.js app with Vercel AI SDK?

Create a route handler that calls streamText with your model and messages, then return result.toDataStreamResponse(). On the client, use the useChat hook from ai/react to manage streaming state, input handling, and loading and error states.

How do I extract structured JSON from text using an LLM?

Use generateObject with a Zod schema defining the expected shape. The SDK validates the model output against the schema and returns a fully typed object, so you never need unsafe casts like as unknown as Type.

How do I build a RAG pipeline with pgvector and the AI SDK?

Chunk documents, embed them in batch with embedMany, and store vectors in a PostgreSQL pgvector column. At query time, embed the user query with embed, run a cosine similarity search, and inject the top chunks into the streamText system prompt.

Does Vercel AI SDK v6 support tool calling with Claude?

Yes. Define tools with the tool() helper, providing a description, Zod parameters schema, and an execute function. Pass them to streamText and set maxSteps to cap how many tool calls the model can make before producing a final response.

How do I prevent runaway costs in AI API routes?

Set maxTokens on every streamText or generateText call, add per-IP and per-user rate limiting, and log token usage in the onFinish callback. For tool calling, always set maxSteps to prevent infinite tool-call loops.

When should I use multi-model routing instead of one model?

Use routing when request complexity varies: send simple queries to a cheap fast model like gpt-4o-mini and complex or reasoning tasks to stronger models like claude-sonnet or claude-opus. Classify each request first, then select the model accordingly.