convex-schema-validator

Define and validate Convex database schemas with typed validators, indexes, and migration strategies.

1|Updated Oct 10, 2025
One-click install
npx skills add https://github.com/Rocktown-Labs/rivercitymd --skill convex-schema-validator-rocktown-labs
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: convex-schema-validator
Source: https://github.com/Rocktown-Labs/rivercitymd/tree/main/.cursor/skills/convex-schema-validator
Command: npx skills add https://github.com/Rocktown-Labs/rivercitymd --skill convex-schema-validator-rocktown-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing Convex database schemas correctly requires knowing validator types, index configuration, and safe migration patterns; mistakes like missing indexes or non-optional new fields break queries and existing data. ## Core Features & Use Cases - Schema Definition: Define tables with typed validators including strings, numbers, unions, literals, records, optional fields, and nested objects. - Index Configuration: Create single-field, compound, and full-text search indexes with consistent naming conventions that match query patterns. - Migration Strategies: Add optional fields, backfill data with internal mutations, and safely promote optional fields to required ones. - Use Case: When adding an avatarUrl column to an existing users table, define it as optional first, run a backfill mutation over batches of documents, then make it required once all rows are populated. ## Quick Start Ask the AI to define a Convex schema for your app's tables with proper validators and indexes following the schema validator guidelines.

Frequently Asked Questions about convex-schema-validator

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

FAQPage Schema
How do I define a schema in Convex?▼

Define a Convex schema in convex/schema.ts using defineSchema and defineTable with validators from convex/values. Each table declares field types like v.string(), v.number(), v.id(), and v.optional(), and can chain .index() calls for query optimization.

How do I add indexes to a Convex table?▼

Add indexes by chaining .index() on defineTable with a name and ordered field list, such as .index("by_channel_and_time", ["channelId", "sentAt"]). Use .searchIndex() for full-text search with a searchField and optional filterFields.

What is the difference between optional and nullable fields in Convex?▼

An optional field via v.optional(v.string()) may not exist on the document, while a nullable field via v.union(v.string(), v.null()) must exist but can hold null. You can combine both with v.optional(v.union(v.string(), v.null())).

How do I migrate a Convex schema when adding new fields?▼

Add new fields as optional first so existing documents remain valid, then run a backfill internal mutation that patches documents missing the field in batches. After all rows are populated, update the schema to make the field required.

Why does my Convex query fail with a missing index error?▼

Queries using withIndex require a corresponding index defined in the schema with matching fields in the same order. Define the index in schema.ts with .index() including all queried fields, then redeploy the schema.