convex-best-practices

Codify Convex development practices for function organization, validation, and error handling.

1|Updated Feb 2, 2026
One-click install
npx skills add https://github.com/lulacoder/Hotel_management --skill convex-best-practices-lulacoder
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: convex-best-practices
Source: https://github.com/lulacoder/Hotel_management/tree/main/.opencode/skills/convex-best-practices
Command: npx skills add https://github.com/lulacoder/Hotel_management --skill convex-best-practices-lulacoder

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured, battle-tested approach to building Convex applications, ensuring teams can deliver robust, scalable data-driven apps with consistent patterns.

Core Features & Use Cases

  • Domain-based function organization: separate files by domain (e.g., users.ts, tasks.ts) to keep code maintainable.
  • Validation and error handling: always define argument/return validators and use ConvexError for user-facing errors.
  • Efficient data access: use indexes and withIndex for performant queries; design queries around reactive patterns.
  • TypeScript discipline: leverage Id and Doc types for strong typing across the data layer.
  • Internal vs public functions and governance: separate internal mutations from public API surface to protect sensitive operations.
  • Use case: a Convex-based app that needs clear architecture, reliable error handling, and scalable data access as the project grows from a handful of routes to a broader domain.

Quick Start

Apply the Convex best practices to your project by organizing functions by domain, adding validation, adopting index-based queries, and standardizing error handling.

Frequently Asked Questions about convex-best-practices

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

FAQPage Schema
How do I structure a Convex app to scale across multiple domains?▼

Separate internal mutations from public API functions to protect sensitive operations and establish clear governance. This separation enforces a secure public API surface while allowing internal mutations to handle sensitive operations safely across teams of any size.

How do I handle validation and errors in Convex functions?▼

Enforce return validators alongside argument validators to guarantee type-safe data flow across the data layer. This TypeScript discipline, combined with ConvexError for user-facing errors, ensures reliable data access and consistent reactive query patterns.

What's the best way to optimize Convex queries for performance?▼

Use Id and Doc types to leverage TypeScript discipline across the data layer, ensuring strong typing for all query and mutation results. This approach pairs with index-aware queries to maintain type safety and efficient data retrieval at scale.

Why should I separate internal mutations from public functions in Convex?▼

Apply idempotent mutations alongside domain-based function organization to prevent duplicate data writes in large-scale domain modeling. This pattern ensures robust, scalable data-driven apps by making mutations safely retryable without side effects.

Do I need TypeScript types for Convex data models?▼

Combine TypeScript discipline with idempotent mutations to build production-ready Convex applications that scale reliably. This approach prevents duplicate writes and ensures robust data layer integrity across teams of any size during large-scale domain modeling.