convex-best-practices

Standardize Convex app development with domain-based organization and validation.

78|18|Updated Feb 20, 2025
One-click install
npx skills add https://github.com/nakafaai/nakafa.com --skill convex-best-practices-nakafaai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: convex-best-practices
Source: https://github.com/nakafaai/nakafa.com/tree/main/.agents/skills/convex-best-practices
Command: npx skills add https://github.com/nakafaai/nakafa.com --skill convex-best-practices-nakafaai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a standardized set of Convex development guidelines that help teams build maintainable, scalable Convex apps by enforcing consistent function organization, query patterns, validation, TypeScript usage, and robust error handling.

Core Features & Use Cases

  • Domain-driven function organization: Structure code by domain (e.g., users.ts, tasks.ts) with explicit schema usage and clear boundaries.
  • Validation & error handling: Require return validators, use ConvexError for user-facing errors, and implement idempotent mutations to prevent retries from causing inconsistencies.
  • TypeScript-centric practices: Emphasize strict typing with Id/Doc types, typed inputs/outputs, and end-to-end type safety.
  • Use Case: Onboarding a new Convex project team by refactoring to domain-based modules and documenting conventions.

Quick Start

Review the Convex Best Practices guidelines and apply them to your project by organizing functions by domain, adding schema definitions, and implementing explicit validators and 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 organize Convex functions for a large TypeScript project?

Structure Convex functions by domain, such as users.ts or tasks.ts, to enforce clear boundaries. This domain-driven file organization scales maintainably from small to large projects and accelerates new developer onboarding.

What is the best way to handle validation and errors in Convex mutations?

Require explicit return validators and use ConvexError for user-facing exceptions to handle validation robustly. Implementing idempotent mutations prevents data inconsistencies during system retries.

How does TypeScript integration work with Convex schema definitions?

TypeScript integration uses strict Id and Doc types derived from schema definitions. Emphasizing typed inputs and outputs ensures end-to-end type safety throughout your Convex application.

Why should I use explicit return validators in Convex queries?

Explicit return validators enforce consistent coding standards and guarantee runtime data shapes match expectations. This practice strengthens end-to-end type safety between Convex queries and clients.

When do I need idempotent mutations in Convex to prevent data issues?

Implement idempotent mutations in Convex to prevent duplicate side effects during automatic network retries. This practice ensures data consistency and robust error handling across your application.

Can I use domain-driven design for small Convex apps or is it only for large teams?

Domain-driven design in Convex applies to both small and large projects. Structuring code by domain with explicit schema usage standardizes function organization and scales smoothly as your application grows.