addon-vercel-ai-labs
Add-on: Vercel AI Labs
Use this skill when a Next.js app needs Vercel AI SDK based chat, generation, or streaming interactions with typed boundaries.
Compatibility
- Best with
architect-nextjs-bun-app. - Can be combined with
addon-llm-translation,addon-langgraph-agent, oraddon-langchain-llm. - For Python-first stacks, prefer
addon-langchain-llmoraddon-langgraph-agent.
Inputs
Collect:
AI_PROVIDER:openai|anthropic|google|xai.AI_MODEL: provider model id.STREAM_MODE:yes|no(defaultyes).UI_SURFACE:chat|assistant|text-generation.MAX_INPUT_CHARS: default12000.
Integration Workflow
- Add dependencies:
# Use the project's package manager (examples):
bun add ai zod
pnpm add ai zod
- Provider packages as needed:
# Use the project's package manager (examples):
bun add @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google @ai-sdk/xai
pnpm add @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google @ai-sdk/xai
- Add files:
src/lib/ai/providers.ts
src/lib/ai/schemas.ts
src/app/api/ai/chat/route.ts
src/components/ai/chat-panel.tsx
- Keep model calls server-side:
- Route handlers own provider/model selection.
- Return typed JSON contract for non-streaming mode.
- For streaming mode, enforce bounded lifecycle and disconnect handling.
- Enforce schema and policy:
- Validate request inputs and size before model invocation.
- Restrict model/provider to explicit allow-list.
- Add timeout/retry boundaries and fallback behavior.
Required Template
src/lib/ai/schemas.ts
import { z } from "zod";
export const AiChatRequestSchema = z.object({
message: z.string().min(1).max(12000),
});
export const AiChatResponseSchema = z.object({
outputText: z.string().min(1),
model: z.string().min(1),
provider: z.string().min(1),
});
Guardrails
-
Documentation contract for generated code:
- Python: write module docstrings and docstrings for public classes, methods, and functions.
- Next.js/TypeScript: write JSDoc for exported components, hooks, utilities, and route handlers.
- Add concise rationale comments only for non-obvious logic, invariants, or safety constraints.
- Apply this contract even when using template snippets below; expand templates as needed.
-
Never expose API keys to client bundles.
-
Do not allow arbitrary model override from untrusted client input.
-
Bound token/character budgets and request duration.
-
Return controlled degraded response when provider is unavailable.
Validation Checklist
- Confirm generated code includes required docstrings/JSDoc and rationale comments for non-obvious logic.
# Use the project's package manager (examples):
bun run lint
bun run build
pnpm run lint
pnpm run build
test -f src/app/api/ai/chat/route.ts
rg -n "AiChatRequestSchema|AiChatResponseSchema|provider|model" src/lib/ai/schemas.ts
- Manual checks:
- Chat route validates input and returns typed output.
- Streaming path terminates cleanly on client disconnect.
Decision Justification Rule
- Every non-trivial decision must include a concrete justification.
- Capture the alternatives considered and why they were rejected.
- State tradeoffs and residual risks for the chosen option.
- If justification is missing, treat the task as incomplete and surface it as a blocker.
More from ajrlewis/ai-skills
architect-python-uv-fastapi-sqlalchemy
Use when scaffolding production-ready FastAPI services with uv, SQLAlchemy, Alembic, Postgres, Docker, and CI gates.
11addon-rag-ingestion-pipeline
Use when adding multi-format RAG ingest, chunk, embed, and retrieval pipelines; pair with architect-python-uv-batch or architect-python-uv-fastapi-sqlalchemy.
11addon-docling-legal-chunk-embed
Use when you need legal PDF to markdown extraction plus clause chunking and embedding prep; pair with addon-rag-ingestion-pipeline and architect-python-uv-batch.
10addon-llm-ancient-greek-translation
Use when adding Koine or Attic Greek translation to Next.js content flows; pair with ui-editorial-writing-surface and addon-nostr-nip23-longform.
10architect-python-uv-batch
Use when scaffolding production-ready Python uv batch or worker projects with Docker required by default.
10addon-human-pr-review-gate
Use when agent-generated code must pass a human PR review gate with trusted checks and merge blocks; pair with addon-decision-justification-ledger and architect-stack-selector.
9