Skip to main content
rule CX Codex

ai-sdk — Claude Code rule for structured data

This Claude Code rule covers structured data generation with the Vercel AI SDK. It applies to TypeScript and TSX files.

AGPL-3.0 ★ 1,120 updated 2026-11-16

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/ai-sdk.mdc
Open on GitHub

What ai-sdk does

The rule steers Vercel AI SDK code toward generateText with an Output format, replacing the deprecated generateObject pattern. Zod schemas shape objects and arrays; Output.choice() selects from a fixed set, while Output.json() returns JSON without schema validation. Plain text uses Output.text().

For streamed arrays, the rule demonstrates elementStream. Field descriptions with .describe() add context to schema properties, and the error example checks for NoObjectGeneratedError. It also covers structured output alongside tools. The file patterns are **/*.ts and **/*.tsx.

What it helps with

  • replace generateObject with the current generation pattern
  • define object or array output with a Zod schema
  • consume array items as streaming completes
  • classify text using a fixed set of labels

Example prompts for the agent

  • Rewrite this generateObject call using generateText, Output.object(), and a Zod schema.
  • Show how to stream array items with elementStream.
  • Classify this text with Output.choice() and the options positive, negative, and neutral.

How to install ai-sdk

Manually: put the files in place

.cursor/rules/ai-sdk.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about ai-sdk

How do I install ai-sdk in Claude Code?

Add the rule file to the project at .claude/rules/ai-sdk.md.

What does ai-sdk do?

It provides Vercel AI SDK patterns for structured objects, arrays, and classification. The guidance also covers streaming and error handling.

Which files does ai-sdk apply to?

It matches TypeScript and TSX files using **/*.ts and **/*.tsx.

Similar IDE rules

All IDE rules for AI and ML →

From the same set25

The whole set →
server-actions This Claude Code rule guides the choice between Server Actions and API routes for reading or changing data. It applies when an agent writes server-side application logic. CX Codex +1 ★ 1,120repo stars input-label The input-label Claude Code rule sets how fields get their captions through the Input component. It applies to *.tsx files and disallows a separate caption above the field. CX Codex +1 ★ 1,120repo stars supabase-typed-mutations The supabase-typed-mutations Claude Code rule adds Database types to Supabase insert, update, and upsert calls. It applies while an agent works with these mutations. CX Codex +1 ★ 1,120repo stars use-shadcn This rule for Claude Code, Codex, and Cursor guides agents to reuse shadcn/ui components. When building UI, it directs them to look for existing project components first. CX Codex +1 ★ 1,120repo stars one-component-per-file The one-component-per-file Claude Code rule keeps each React component in its own file. It applies to *.tsx files. CX Codex +1 ★ 1,120repo stars realtime This Claude Code rule sets the pattern for Supabase Realtime subscriptions. It directs component code to useRealtimeSubscription instead of calling supabase.channel() directly. CX Codex +1 ★ 1,120repo stars dialog-trigger-pattern The dialog-trigger-pattern Claude Code rule defines how dialog components receive their trigger. It applies to .tsx files. CX Codex +1 ★ 1,120repo stars trigger.basic trigger.basic is a Claude Code rule for writing Trigger.dev tasks. It applies to TypeScript files matching **/trigger/**/*.ts. CX Codex +1 ★ 1,120repo stars

Project sponsors

Companies that keep this analytics open