convex

Convex backend development patterns, validators, indexes, actions, queries, mutations, file storage, scheduling, React hooks, components, and testing. Use when writing Convex code, debugging Convex issues, planning Convex architecture, or writing Convex tests.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "convex" with this command: npx skills add matiacone/dotfiles/matiacone-dotfiles-convex

Convex Development Guide

Provide comprehensive Convex development guidance to avoid common mistakes and ensure code compiles on first try.

Priorities

  1. Compile + typecheck on first try
  2. Respect Convex's constraints (indexes, limits, auth, schedulers, file storage)
  3. Avoid expensive / subtle bugs (wrong indexes, misuse of actions, broken hooks)

Mental Model

Convex is a hosted backend with:

  • Database: documents + indexes + full-text search
  • Functions: query, mutation, action, plus internal variants
  • Realtime queries: useQuery on the client auto-subscribes
  • File storage, Auth (via @convex-dev/auth), Scheduler (cron + runAfter)

Code layout:

  • Backend: convex/*.ts files
  • Client: React using convex/react (useQuery, useMutation)
  • Generated API: convex/_generated/api exports api + internal

Quick Reference

Functions

  • Import from ./_generated/server
  • Use query({ args, handler }) syntax
  • Always define args validators

Indexes (CRITICAL)

  • Never use .filter() - use .withIndex() instead
  • Never define by_creation_time index (it's built-in)
  • Never include _creationTime in custom index fields

Actions

  • Add "use node"; at top for Node modules
  • Never use ctx.db - use ctx.runQuery/ctx.runMutation
  • Only actions support dynamic imports

Scheduler

  • Auth does NOT propagate - use internal functions
  • Use function references (internal.file.fn), not the function itself

Migrations

  • Install @convex-dev/migrations component
  • Modify schema to allow old+new values → run migration → update schema to require new values
  • Use migrations.define({ table, migrateOne }) to define
  • Return object from migrateOne for auto-patch shorthand
  • Run via CLI: npx convex run migrations:run '{fn: "migrations:myMigration"}'
  • Use dryRun: true to validate before committing

React Hooks

  • Never call hooks conditionally
  • Use "skip" pattern: useQuery(api.foo, condition ? args : "skip")
  • usePaginatedQuery returns { results, status, loadMore } for infinite scroll

Testing

  • Use convex-test with Vitest
  • Pass schema to convexTest() for validation
  • Use t.withIdentity() for auth testing

Reference Files

Load these as needed based on the task:

TopicFileWhen to use
Schema & Validatorsschema-validators.mdDefining tables, validators, system fields
Functionsfunctions.mdQuery/mutation/action patterns, calling functions
Indexes & Queriesindexes-queries.mdDatabase queries, indexes, search
Paginationpagination.mdusePaginatedQuery, cursor-based pagination, infinite scroll
Actions & HTTPactions-http.mdActions, HTTP endpoints, external APIs
Schedulingscheduling.mdCron jobs, scheduled functions
File Storagefile-storage.mdUploads, downloads, file metadata
Migrationsmigrations.mdOnline migrations, schema changes, data transformations
Limitslimits.mdSize limits, time limits, design constraints
Environment Variablesenv-secrets.mdSecrets, API keys, environment setup
React Patternsreact-patterns.mduseQuery, useMutation, skip pattern
Authauth.mdAuthentication, user identity
Componentscomponents.mdPresence, ProseMirror, Resend components
TypeScript Fixestypescript-fixes.mdTS2589 errors, static API generation
Checklistchecklist.mdPre-commit verification checklist
Testingtesting.mdconvex-test, Vitest patterns

Process

  1. Check the quick reference above for common patterns
  2. Load specific reference files based on the task
  3. Verify against the checklist before finalizing code

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

yolo

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

code-quality

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

frontend-development

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

github

No summary provided by upstream source.

Repository SourceNeeds Review